DOS_6.1 Posted September 13, 2008 Share Posted September 13, 2008 Hey all. I am very new at MySQL and PHP although I've been programming for years in other languages. I have read the installation post by WildTeen but it hasn't helped. Here is the problem: I have PHP 5.2.5 running with Apache 2.2.8 on a winXP pro computer. I also have MySQL 5.0.51a installed. All three installed with no problems and PHP alone works fine. My problem is that when I try to connect to MySQL the whole PHP script seems to stop. Here is an example. Say my PHP script is simply the script below: <?PHP Echo "Line 1</br>"; Echo "Line 2</br>"; ?> OK, so very basic but it will do for this problem. Both lines show up and I see Line 1 Line 2 displayed on the web browser. All good. The user named "user" with password "password" was added to MySQL prior to running this. So now I add a line in between the two to connect to MySQL so I have: <?PHP Echo "Line 1</br>"; $link = mysql_connect('localhost', 'user', 'password'); Echo "Line 2</br>"; ?> Now when I try to load the page all I see in the web browser is: Line 1 Did the PHP script simply stop when it tried to connect or did something else go wrong? Any ideas? -DOS Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 Add: <?php ini_set('display_errors', 1); error_reporting(E_ALL); ?> Also, don't capitalize the PHP tags and language constructs and functions and stuff. Just makes it harder too look at. >_> Quote Link to comment Share on other sites More sharing options...
DOS_6.1 Posted September 13, 2008 Author Share Posted September 13, 2008 Thanks for the tip. I got the following error/output: Line 1 Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\test\test.php on line 7 Current php script: <?php ini_set('display_errors', 1); error_reporting(E_ALL); ?> <?php echo "Line 1</br>"; $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); echo "Line 2</br>"; ?> Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 13, 2008 Share Posted September 13, 2008 This is classic symptoms of the mysql extension not being enabled. Have a read of this sticky Quote Link to comment Share on other sites More sharing options...
DOS_6.1 Posted September 13, 2008 Author Share Posted September 13, 2008 I had read that. My php.ini file didn't have the line ;extension=php_mysql.dll in it. I've added it but the same error occurs. I have copied php_mysql.dll to both the windows/system32 and my php/ext directory (that is the directory defined in my php.ini file as the extensions dir. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 13, 2008 Share Posted September 13, 2008 If the php_mysql.dll was not already in the php/ext folder that means you got php from somewhere that did not provide all the necessary files. How and where you get the php package? Was this the .msi installer package? Was this the full .zip package? Quote Link to comment Share on other sites More sharing options...
Mchl Posted September 13, 2008 Share Posted September 13, 2008 Have a look at WampServer. It's PHP Apache Mysql All-in-one bundle, which works well with Windows XP. Just be sure to uninstall your current Apache, PH and Mysql to avoid interferences. Quote Link to comment Share on other sites More sharing options...
DOS_6.1 Posted September 13, 2008 Author Share Posted September 13, 2008 I had used the .msi from the PHP site. I had to find the libraries online seperately. I will check out the Wampserver. Thanks for all the help so far guys! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 13, 2008 Share Posted September 13, 2008 The .msi installer expects you to use the Windows control panel add/remove to install php extensions (which I don't think is documented anywhere and lack of documentation is what kills most application.) If you are installing Apache/php/mysql individually, use the php .zip package, not the .msi installer. Quote Link to comment Share on other sites More sharing options...
DOS_6.1 Posted September 13, 2008 Author Share Posted September 13, 2008 Cool, will do. I'll let you know how it works. Sorry for the n00b questions =P Quote Link to comment Share on other sites More sharing options...
DOS_6.1 Posted September 14, 2008 Author Share Posted September 14, 2008 It finally works! Thanks guys ! For anyone with a similar problem I had to do the following: 1) Downloaded and installed WAMP (all extensions install automatically). 2) Added the PHP and PHP extension directories to windows path and finally 3) copied the libmysql.dll to windows. Restarted the ole laptop and it worked. Thanks all! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 14, 2008 Share Posted September 14, 2008 After you add the php folder to the Windows path statement (and reboot your computer or log off and log back on to get the change to take effect), step 3 is not necessary. 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.