bryandc Posted March 23, 2007 Share Posted March 23, 2007 Hi, help! I have PHP installed and works fine via localhost. I have Mysql installed and have fill access and utility via the Mysql CLI. However, when I attempt to use the code below to connect: <?php $location = "localhost"; $username = "administrator"; $password = "bc99mard"; $database = "bryan"; $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect MySQL"); mysql_select_db($database,$conn) or die ("Could not open database"); ?> All i get is the pretties white screen. No connection, no error, nada. I tried setting up an ODBC to talk to mysql but there is no connection type for mysql. When I use Mysql via the CLI it does ask for a password which is the same as my admin login password. It never asks for a userid and I don't know what it see as a userid. I suspect that therein lies my problem but I really don't know. i have no issue with the DB itself as i have done many projects in Access, SQLserver, and to a lesser extent Oracle. Is there a way to config MySql so that it doesn't require a userid, password? if not what do you think it is using as a userid? I am quite perplexed. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/ Share on other sites More sharing options...
wildteen88 Posted March 23, 2007 Share Posted March 23, 2007 Open your php.ini file and turn display_errors on and make sure error_reporting is set to E_ALL Save the php.ini and restart IIS. Re-run your script. If there is any errors PHP finds they will now be displayed to the browser. Post all error messages you get here in full. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-213691 Share on other sites More sharing options...
bryandc Posted March 26, 2007 Author Share Posted March 26, 2007 I just don't get it. I made the changes you suggested. I do have one issue however. I have 3 php.ini files and am not sure how I got 3. One is in c:\WINDOWS One is in C:\Program Files One is in C:WINDOWS\system32 I am not sure which one it talks to but I changed all 3 to be safe. Here's the rub. I do not get any errors. I just get white screen. i downloaded the Zend development tool and all works as should withing the tool. I get my connectivity to MySql etc. When I open the tested / debugged source code (believe me at this stage is the simplest of code) i get no output whatsoever. Any HTML code will display proper results (i.e. a <p>content</p>). The browser will display all PHP content properly as well but as soon as I add a connectvity string I getr no output. All I see is white screen. It seems as though there is a disjoint between PHP and MySql when I run as localhost and yet it has no issue in Zend. I will perform whatever tests, actions, wrist slicing, that you may suggest. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-215624 Share on other sites More sharing options...
bryandc Posted March 26, 2007 Author Share Posted March 26, 2007 Additional info. the user of 'root' is correct as opposed to 'administrator' shown above. the password is correct. This is not the issue. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-215639 Share on other sites More sharing options...
wildteen88 Posted March 27, 2007 Share Posted March 27, 2007 Only have one php.ini, delete all others. I would recommend you to keep the php.ini that is located in C:\WINDOWS For turning a setting called display_errors to On in the php.ini you simply search for the following line: ; server, your database schema or other information. Beneath that line will be the display_errors setting. change Off to On Now change a setting called error_reporting (which is just a few lines above the setting your just changed) to E_ALL. Now save the php.ini and restart IIS. Re run your code and if there is any problems with the script PHP will display errors messages this time, these errors message will help debug your code. Post all error messages you get here Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-216193 Share on other sites More sharing options...
kung Posted April 1, 2007 Share Posted April 1, 2007 I wish you posted your solution if you solved this because this is exactly the same problem I am having. I enabled all of the errors that was mentioned and still Zero output. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-218928 Share on other sites More sharing options...
kung Posted April 1, 2007 Share Posted April 1, 2007 Forget it, it was almost embarrisingly simple Solved - aaghhh Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-219003 Share on other sites More sharing options...
bryandc Posted April 2, 2007 Author Share Posted April 2, 2007 By all means please embarras me. i still can't get it to work. What was your solution? Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-219879 Share on other sites More sharing options...
bryandc Posted April 2, 2007 Author Share Posted April 2, 2007 I made the changes as suggested. I now have only 1 php.ini that is sitting in C:\WINDOWS I made the changes to the php.ini to turn on error reporting. The rub is that I do not get any error. I only get a pure white screen. THIS IS A SAMPLE PHP PAGE THAT WORKS JUST FINE: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php phpInfo(); ?> </body> </html> THIS IS MY CONNECT TEST. THIS PRODUCES NOTHING BUT WHITE SCREEN. THIS SAME FILE IN ZEND CONNECTS PERFECTLY. <?php $dbcnx = @mysql_connect('localhost', 'root', 'bc99mard'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } echo 'Connected successfully'; mysql_close($link); ?> I am mystified and stupified. I am attaching my php.ini file I am attaching a screenshot of my phpInfo() screen. The user named Kung says he solved it but he posted no solution. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-219900 Share on other sites More sharing options...
wildteen88 Posted April 2, 2007 Share Posted April 2, 2007 Remove the @ from in front of mysql_connect. The @ suppresses errors so if have that in front of a line/function call then any errors returned will be ignored. Also when you make any changes to server configuration files, you must restart the server. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-219935 Share on other sites More sharing options...
bryandc Posted April 2, 2007 Author Share Posted April 2, 2007 Aha progress. perhaps this message is telltale. Fatal error: Call to undefined function mysql_connect() in C:\Inetpub\wwwroot\PHP\connect1.php on line 3 This is launching thru localhost so I don't get the reference to C:\Inetpub... seems like it should say /localhost Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-219999 Share on other sites More sharing options...
wildteen88 Posted April 2, 2007 Share Posted April 2, 2007 The mysql extension hasn't been enabled or PHP is having issues loading the extension. I see in your php.ini you have set up the extension_dir to point to PHP's extension folder which is correct and that you have enabled the mysql extension line in the php.ini Those are correct steps to take for enabling the mysql extension. There is an external library called libmysql.dll in order for the mysql extension to function correctly. Where is the location of this file? Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-220068 Share on other sites More sharing options...
bryandc Posted April 3, 2007 Author Share Posted April 3, 2007 I actually have 10 such files in: c:\WINDOWS c:\downloads\php (my own folder) c:\mysql\bin * c:\WINDOWS\system32 c:\mysql\lib\debug * c:\mysql\lib\opt * c:\Program Files\MySQL\MYSQL Server 5.0\bin * c:\Program Files\MySQL\MYSQL Server 5.0\debug c:\Program Files\MySQL\MYSQL Server 5.0\opt c:\Program Files\Zend\ZendStudio-5.5.0\bin\php5 The ones above marked with an * are identified as libmySQL as opposed to libmysql Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-220282 Share on other sites More sharing options...
wildteen88 Posted April 3, 2007 Share Posted April 3, 2007 libmySQL and libmysql are the same. Just different case. do you get any start up errors when IIS starts up? Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-220623 Share on other sites More sharing options...
bryandc Posted April 3, 2007 Author Share Posted April 3, 2007 I have no errors with IIS, I have no errors with PHP, I have no errors with MySql (in command mode). My only error is in trying to connect to MySql from within PHP. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-220689 Share on other sites More sharing options...
kung Posted April 5, 2007 Share Posted April 5, 2007 I don't think it was exectly the same problem. FYI - once I checked the log files I had infact connected and disconnected from MySQL. Hence my embarressment. Of course there was no output, I had not scripted any output beyond the back end stuff. Sorry if that wasnt any help to you Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-221843 Share on other sites More sharing options...
bryandc Posted April 5, 2007 Author Share Posted April 5, 2007 Thanks for the info. I, unfortunately, still cannot connect. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-222316 Share on other sites More sharing options...
bryandc Posted April 6, 2007 Author Share Posted April 6, 2007 is ther nothing that I can do to remedy this situation? Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-222690 Share on other sites More sharing options...
wildteen88 Posted April 6, 2007 Share Posted April 6, 2007 I have just re-read the whole thread and I have gotten a little confused my self and I noticed I have missed out a few important bits. Have you uncommented the mysql extension line in the php.ini? Change this line: ;extension=php_mysql.dll to extension=php_mysql.dll also ensure that you have set the extension_dir directive to point to your PHP extension folder, I believe its C:\downloads\PHP\ext So make sure you set extension_dir line like this: extension_dir = "C:\downloads\PHP\ext" Save any changes you make to the php.ini and restart IIS Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-222841 Share on other sites More sharing options...
bryandc Posted April 7, 2007 Author Share Posted April 7, 2007 I think you can check this one as solved. The problem appeasrs to have been this line: extension_dir = "C:\downloads\PHP\ext" I had the ext mapped as C:\PHP\ext As soon as I added downloads to the map it connected and I have run many test reads on DB and tables. Thanks so much for the help. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-223344 Share on other sites More sharing options...
wildteen88 Posted April 7, 2007 Share Posted April 7, 2007 no problem. I will mark it as solved. Quote Link to comment https://forums.phpfreaks.com/topic/43916-solved-cant-connect-in-iis/#findComment-223495 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.