joziv Posted August 30, 2009 Share Posted August 30, 2009 I have installed PHP 5, Apache and MySQL on my machine, which runs on Windows Vista. Apache tells me it's working (at http://localhost/), and the status bar in the Apache Service Monitor tells me it's connected to PHP/5.2.10. However I seem to be having problems connecting to my database. I am using a simple php page to test the connection to the database, but it just returns a blank page, which has nothing in the source code. My test.php file is: <?php $mysqli = new mysqli("localhost", "root", "password", "db"); if (mysqli_connect_errno()) { printf("Connection failed: %s\n", mysqli_connect_error()); exit(); } else { printf("Host information: %s\n", mysqli_get_host_info($mysqli)); mysqli_close($mysqli); } ?> I can use MySQL on the database through a MySQL Line Client, so I'm not sure where the error is - I think it may be in the php.ini file? I have not altered it yet. After many hours of googling the problem, and reinstalling everything, I'm getting a bit fed up. I have added the PHP directory to the windows path. Any help will be greatly appreciated! Cheers. Quote Link to comment Share on other sites More sharing options...
ldb358 Posted August 30, 2009 Share Posted August 30, 2009 the error you described is the one i get when it cannot connect to the database either i forget to import my connection file or a username/password is incorrect so i would assume the error is somewhere in there Quote Link to comment Share on other sites More sharing options...
joziv Posted August 30, 2009 Author Share Posted August 30, 2009 Hmm ok. Well I've now changed some error settings in php.ini and it produces this error: Fatal error: Class 'mysqli' not found in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test.php on line 2 I've been looking up this error and tried various things, but to no avail yet. Anyone else seen this error before? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 30, 2009 Share Posted August 30, 2009 it just returns a blank page There are likely fatal runtime errors due to the mysqli php language extension not being enabled. Edit: I'm guessing you did this - You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you. You will save a lot of time. Stop and start your web server to get any change made to php.ini to take effect and verify any change using a phpinfo(); statement. If you manually installed php from the .zip package, all you should need to do in uncomment the extension=php_mysqli.dll line in your php.ini and stop and start your web server. If you did something like use the .msi installer package to install php, you will need to use the Windows control panel add/remove (they named it something else in Vista) to enable the mysqli extension (or remove what the .msi installer did and install php manually using the .zip package.) Quote Link to comment Share on other sites More sharing options...
joziv Posted August 30, 2009 Author Share Posted August 30, 2009 Thanks, I uncommented that earlier - sorry forgot to mention that! I did install php using the zip file. If it's any help, I can't see any details about MySQLi in my phpinfo page? I've read you should be able to see some sql information there...? Quote Link to comment Share on other sites More sharing options...
joziv Posted August 30, 2009 Author Share Posted August 30, 2009 Ok so I've made a discovery. Maybe this will shed some light on the situation for someone? Using the code below, it turns out I don't have the mysqli libraries. if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) { echo 'We don\'t have mysqli!!!'; } else { echo 'Phew we have it!'; } Does this help anything? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 30, 2009 Share Posted August 30, 2009 Someone already mentioned that - There are likely fatal runtime errors due to the mysqli php language extension not being enabled. As long as the php.ini that you are changing is the one that php is using and you have uncommented the php_mysqli.dll line in the php.ini and restarted your web server and the axuiliary .dll file libmysql.dll that is used by that extension is in a folder that is part of the Windows PATH statement, it should work. Have you checked the web server log file for any related errors? Quote Link to comment Share on other sites More sharing options...
joziv Posted August 30, 2009 Author Share Posted August 30, 2009 And it's working! It was of course a mis-type on my behalf. In php.ini, it used to read: ; Directory in which the loadable extensions (modules) reside. extension_dir = "\ext\" However, after looking into the Apache log errors I discovered it was looking to "\\ext\\" - which obviously has too many slashes making the directory very wrong. Simply changing it and resetting the server sorted it all out. ; Directory in which the loadable extensions (modules) reside. extension_dir = "ext" Many thanks to PFMaBiSmAd for suggesting to look in the log files. Quote Link to comment 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.