Beauford2016 Posted April 14, 2020 Share Posted April 14, 2020 Can someone please, please, please tell me wtf is going here before I go totally postal and shoot up my ISP. If I insert this code at the top of any of my web pages it halts the page and nothing below it gets processed. I just get a blank page. Even if I try to make an error on purpose, nothing, just a blank page. All this works perfectly on PHP 5.4 and under. Currently using 5.6 which I downgraded from 7.2 thinking maybe that was an issue. Running on Linux Mint 19. I thought this might be a good hobby since I had a spare laptop just lying around, but maybe I was mistaken - too much time already wasted today on this. Not like the old Slackware days. I have tried the "serverhost" etc without quotes as well. I can't post all what I have done today, but I must have been on a 100 websites and tried 100 different iterations of the below code. Thanks <?php define("serverhost", "localhost"); define("serveruser", "test"); define("serverpass", "pass"); $db = "mydb"; $connect = mysqli_connect("serverhost", "serveruser", "serverpass", $db); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/310565-mysqli_connect-what-am-i-doing-wrong/ Share on other sites More sharing options...
benanamen Posted April 14, 2020 Share Posted April 14, 2020 (edited) Take the quotes off the constant connection parameters in the connect string. It is also standard practice to use all UPPERCASE for constants. $connect = mysqli_connect(serverhost, serveruser, serverpass, $db); Edited April 14, 2020 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/310565-mysqli_connect-what-am-i-doing-wrong/#findComment-1576798 Share on other sites More sharing options...
Beauford2016 Posted April 15, 2020 Author Share Posted April 15, 2020 21 hours ago, benanamen said: Take the quotes off the constant connection parameters in the connect string. It is also standard practice to use all UPPERCASE for constants. $connect = mysqli_connect(serverhost, serveruser, serverpass, $db); From my original post...... I have tried the "serverhost" etc without quotes as well. I have just tried the exact same code on Windows 10 running apache/mysql/php7.2 and it works like a charm, so I am thinking maybe there is something wrong with PHP or MySQL on the Linux machine. Possibly in php.ini or my.cnf. As before, wherever the code is inserted to connect to the mysql server, the script halts and nothing after it is displayed. Anyone?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/310565-mysqli_connect-what-am-i-doing-wrong/#findComment-1576861 Share on other sites More sharing options...
Beauford2016 Posted April 15, 2020 Author Share Posted April 15, 2020 Resolved. mysqli not enabled in php.ini. Quote Link to comment https://forums.phpfreaks.com/topic/310565-mysqli_connect-what-am-i-doing-wrong/#findComment-1576899 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.