nitiphone2021 Posted June 5, 2021 Share Posted June 5, 2021 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 Quote Link to comment https://forums.phpfreaks.com/topic/312862-php-version-5640-internal-error-for-connect-mysql/ Share on other sites More sharing options...
Barand Posted June 5, 2021 Share Posted June 5, 2021 Syntax for host and port is host:port try $conn = mysqli_connect("$servername:$db_port", $username, $password,$db_database); Quote Link to comment https://forums.phpfreaks.com/topic/312862-php-version-5640-internal-error-for-connect-mysql/#findComment-1587023 Share on other sites More sharing options...
mac_gyver Posted June 5, 2021 Share Posted June 5, 2021 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. Quote Link to comment https://forums.phpfreaks.com/topic/312862-php-version-5640-internal-error-for-connect-mysql/#findComment-1587025 Share on other sites More sharing options...
nitiphone2021 Posted June 5, 2021 Author Share Posted June 5, 2021 Fatal error: Call to undefined function mysql_connect() in /home/newlinkbdbcom/public_html/app/webroot/test.php on line 5 $link = mysql_connect('localhost:3306', 'user', 'password','dbname'); still error again. it's about mysql driver or sometime? Quote Link to comment https://forums.phpfreaks.com/topic/312862-php-version-5640-internal-error-for-connect-mysql/#findComment-1587027 Share on other sites More sharing options...
Barand Posted June 5, 2021 Share Posted June 5, 2021 52 minutes ago, nitiphone2021 said: mysql_connect() You're mssing an "i" Quote Link to comment https://forums.phpfreaks.com/topic/312862-php-version-5640-internal-error-for-connect-mysql/#findComment-1587029 Share on other sites More sharing options...
mac_gyver Posted June 5, 2021 Share Posted June 5, 2021 why have you thrown away the code at that start of this thread, using the mysqli extension, and are now trying to use the mysql extension? what is the overall goal/end point of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/312862-php-version-5640-internal-error-for-connect-mysql/#findComment-1587030 Share on other sites More sharing options...
nitiphone2021 Posted June 5, 2021 Author Share Posted June 5, 2021 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 Quote Link to comment https://forums.phpfreaks.com/topic/312862-php-version-5640-internal-error-for-connect-mysql/#findComment-1587041 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.