PHP7 MySQL Upgrade issues / ปัญหาในการอัพเกรด Php7

After an upgrade to PHP7 it is possible that (parts of) your website or application no longer work. In the case of WordPress this will usually be due to very outdated / no longer maintained plugins. You can then update or remove / replace these plugins. For custom applications, more work is sometimes required.

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect () in ...

Reason: All ext / mysql functions were removed

This can be temporarily solved via the following code in every PHP file that needs it (or by including it in an existing include file):

if(version_compare('5.6.0', PHP_VERSION) < 0)
{
	include_once('mysql.php');	
}



And the use of the mysql file below:

 
  https://github.com/dshafik/php7-mysql-shim/tree/master/lib

PHP Parse error: syntax error, unexpected 'new' (T_NEW)

Reason: New objects cannot be assigned by reference

Solution: remove & on the line mentioned in the error

สำหรับภาษาไทยดังนี้

          หลังจากอัพเกรดเป็น PHP7 บางส่วนของเว็ปไซต์ของท่านอาจจะใช้งานไม่ได้ นั่นหมายถึงว่า WordPress ของท่านเป็นเวอชั่นเก่าจนเกินไป หรือไม่มีตัวปลั๊กอินเสริมที่รองรับแล้ว ท่านสามารถอัพเดทหรือลบ หรือแม้กระทั้งติดตั้งปลั๊กอินทดแทนของเก่า แต่การแก้ไข Application ดังกล่างอาจต้องการการแก้ใขดังนี้

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect () in ...

เหตุผล: ext ทั้งหมด / mysql functions ได้ทำการลบ

ท่านสามารถแก้ใข้เบื้องต้นด้วยการแก้โค้ดใน PHP ไฟล์ที่ต้องการ

if(version_compare('5.6.0', PHP_VERSION) < 0)
{
	include_once('mysql.php');	
}

และปรับเปลี่ยนทดแทน mysql ไฟล์ทางด้านล่างในโฟลเดอร์  https://github.com/dshafik/php7-mysql-shim/tree/master/lib

PHP Parse error: syntax error, unexpected 'new' (T_NEW)

สาเหตุ : ท่านไม่สามารถเพิ่ม New Object ลงไปได้ทันที

วิธีการแก้ใข : ให้ทำการลบบรรทัดที่มีการ error ก่อน

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.