andytymeiz Posted June 22, 2007 Share Posted June 22, 2007 Tearing hair out, have apache 2.2.4, mySql 5.0 and php 5.2.3 installed, apache can find php but cannot find mySql, have been through the various topics on this site but to no avail. Firefox keeps loading blank pages, can't find a way round. I am testing with: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>My SQL connection test</title> </head> <body> <h2> <?php $connection = mysql_connect( "localhost", "root", "" ) or die( "sorry - unable to connect you to MySQL" ); echo( "Congratulations - you connected to MySQL" ); ?> </h2> </body> </html> I have configured php.ini correctly (I hope, attached), but still it goes belly up, any suggestions would be appreciated. Many thanks, Andy [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/ Share on other sites More sharing options...
Wildbug Posted June 22, 2007 Share Posted June 22, 2007 What OS? Try printing mysql_error() after an offending mysql* call. Post the result. Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280191 Share on other sites More sharing options...
wildteen88 Posted June 22, 2007 Share Posted June 22, 2007 Your configuration appears to be fine. What is the file name this code is in? You must place PHP code within a .php file. You cannot place PHP code in .html files or any other file extension unless the server is configured to parse these files with PHP interpreter. Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280282 Share on other sites More sharing options...
andytymeiz Posted June 22, 2007 Author Share Posted June 22, 2007 Win Xp Pro but being a novice I misinterpreted the rest.... Thanks for checking the .ini file, the test was a .php document not .html but still no joy Appreciate the help Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280284 Share on other sites More sharing options...
Wildbug Posted June 22, 2007 Share Posted June 22, 2007 <?php $connection = mysql_connect( "localhost", "root", "" ) or die( "sorry - unable to connect you to MySQL\nError: " . mysql_error() ); echo( "Congratulations - you connected to MySQL" ); ?> Try that; post any error resulting. Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280299 Share on other sites More sharing options...
wildteen88 Posted June 22, 2007 Share Posted June 22, 2007 Do you see a mysql heading/section when you run phpinfo() on its own: <?php phpinfo(); ?> If you can't find a mysql heading/section then check that PHP is reading the php.ini file you are editing. You can check this by searching for either Configuration File (php.ini) Path or Loaded Configuration File (when you have ran phpinfo function) and seeing what they are set to. If either of the paths stated is not correct then PHP is not reading your php.ini Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280308 Share on other sites More sharing options...
andytymeiz Posted June 22, 2007 Author Share Posted June 22, 2007 I have tried the code sent but blank page and no error message, running the php_info file returns the php data page showing config file path as c:\windows but the loaded config file in C:\PHP\php.ini so I guess the loaded file is incorrect, where do I change this parameter? Thanks for your patience! Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280504 Share on other sites More sharing options...
wildteen88 Posted June 23, 2007 Share Posted June 23, 2007 Is your php.ini in C:\PHP? If so PHP is reading your php.ini Also did you manage to find a MySQL section/heading when you ran phpinfo? You didn't reply when I asked you that question earlier. If you cannot find a MySQL section/heading then it looks like PHP is having trouble loading the mysql extension - even though you have enabled the extension in the php.in If you answer Yes and No for the above questions then I may know what the problem could be. Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280800 Share on other sites More sharing options...
andytymeiz Posted June 23, 2007 Author Share Posted June 23, 2007 Running phpinfo gives me: System Windows NT D3NN192J 5.1 build 2600 Build Date May 31 2007 09:36:39 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" Server API Apache 2.0 Handler Virtual Directory Support enabled Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\PHP\php.ini PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Debug Build no Thread Safety enabled Zend Memory Manager enabled IPv6 Support enabled Registered PHP Streams php, file, data, http, ftp, compress.zlib Registered Stream Socket Transports tcp, udp Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.* So no mysql heading or section, I note that the config file path and the loaded config file are different, is this correct? I appear to have more php.ini files than I need, one in windows and one in c:\PHP. If the one in PHP is deleted will it default to the one in windows? Many thanks again - us beginners must be a pain! Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280811 Share on other sites More sharing options...
wildteen88 Posted June 23, 2007 Share Posted June 23, 2007 Only one path needs to be true. This one is duff: Configuration File (php.ini) Path C:\WINDOWS However this one is correct: Loaded Configuration File C:\PHP\php.ini When PHP reports C:\WINDOWS that means it cannot find a php.ini file. But on your setup PHP is reading the correct .ini file. Ok what I need you to do now is to go into the php.ini and turn a setting called display_startup_errors on. By changing its default value from Off to On. Save the php.ini and restart Apache. If PHP is having trouble loading extensions that you have uncommented in the php.ini it will notify you when Apache starts up again. Can you post the error messages you get. Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280816 Share on other sites More sharing options...
andytymeiz Posted June 23, 2007 Author Share Posted June 23, 2007 Aha! Light at end of tunnel... Error: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysqltest.php on line 11 sorry - unable to connect you to MySQL Error: Access denied for user 'root'@'localhost' (using password: NO) Is this just a password insertion required? Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280820 Share on other sites More sharing options...
andytymeiz Posted June 23, 2007 Author Share Posted June 23, 2007 Sorted! Thank you for your patience and help, hugely appreciated - I am really keen to get stuck in now and learn php, was on the point of giving up! Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/56732-solved-mysql-and-php-dont-want-to-work-together/#findComment-280823 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.