Jump to content

PHP Version 5.6.40, internal error for connect mysql


nitiphone2021

Recommended Posts

According to I have a project need to use PHP 5.6.40 connect to mysql version  5.7.34
This URL for phpinfo()
http://newlink.bdb.com.la/app/webroot/test.php

when I try to connect it by below coding
 

$servername = "localhost";
$username = "user";
$password = "pass";
$db_database    = 'db_unelr'; 
$db_port        = '3306';

// Create connection
$conn = mysqli_connect($servername, $username, $password,$db_database,$db_port);

// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";


 

it's show 500 internal error.
what should I check and fix this problem? it's private host, so I can run linux command to check


 

Link to comment
Share on other sites

http 500 errors are due to either php parse errors or fatal runtime errors. according the phpinfo output, you need to edit your php.ini and set error_reporting to E_ALL and set display_errors to ON so that php will help you by reporting and displaying all the errors it detects. stop and start your web server to get any changes made to the php.ini to take effect and then check in the phpinfo output to make sure the settings were actually changed.

note: since you are using the procedural mysqli_connect(), you cannot use $conn->connect_error to test for a connation error. you will just get a php notice about trying to get property 'connect_error' of non-object ... and the code will continue to run as though the connection was successful, which may be the cause of the http 500 error later in code that's trying to use the connection.

don't mix procedural and OOP mysqli statements. or even better yet, switch to use the simpler and more consistent PDO extension. it doesn't have all the problems that the mysqli extension has.

Link to comment
Share on other sites

the main target is I have a old software would like to use it and when I install. I got a error message about

Fatal error: Call to undefined function mysql_query() in /home/newlinkbdbcom/public_html/cake/libs/model/datasources/dbo/dbo_mysql.php on line 613

 

so that's why i created a new test file for create a sample connect to test service can work 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.