Jump to content

[SOLVED] Blank Page when connecting to MySQL


DOS_6.1

Recommended Posts

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

Link to comment
Share on other sites

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>";

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

It finally works!  Thanks guys  ;D!  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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.