Jump to content

Testing PHP


lewmur

Recommended Posts

This is my first attempt at using Apache, PHP and MySQL to create a Web page to access a database. I've installed MySQL and successfully used Navicat to import my database. I install Apache2 for Windows and can use my browser to access the index.html @ http://localhost. I d/l PHP ver 4.3 and followed the instructions to install it as an Apache2 module. It finds the php_apache2.dll and doesn't show any errors when starting Apache. So far everything looks OK.However, when I try to use Dreamweaver to create a PHP file to connect to the Database, I get an error saying there is no Testing Server running. How can I create a test html to check if PHP is connecting to MySQL? I know I can create an file and name it index.html and put it in the Apache directory, but what commands to I use in the file to test the connection?

Link to comment
Share on other sites

Dreamweaver will have to be configured. Somewhere in the settings, you should have options to configure the locations and paths for the PHP server files.Also, you'll need to save your files that you want to run as PHP in the web root directory configured in Apache.I'd suggest using plain code to figure out whether PHP and/or MySQL is indeed even working yet...Try this:

<?phpif (@mysql_connect("ServerName", "Username", "Password"))	echo "Successfully Connected to Database";else	echo "ERROR Connecting to Database";?>

Replace the placeholders with the appropriate text and save this as <yourfilename>.php in your Apache web root directory.If this outputs one of the messages above as coded ("Success..." or "ERROR conn..."), PHP is working. MySQL can be determined to be working or not working by which message is displayed, of course ;)If you see this exact code output to your browser window OR if your browser prompts you to download the file, PHP is not working.

Edited by epp_b
Link to comment
Share on other sites

I'd suggest using plain code to figure out whether PHP and/or MySQL is indeed even working yet...Try this:
Thanks. That proved that PHP is working but it isn't connecting to MySQL. I got the error message and not the code. I know MySQL itself is working because I can access the database using Navicat. Now I just have to figure out why PHP can't connect to it. Edited by lewmur
Link to comment
Share on other sites

I thik there is a plugin for either MySQL or PHP, to link the two together in linux. Since I am not running Windows, I do not know f it is setup the same way.

Link to comment
Share on other sites

Check your php.ini file and make sure to uncomment the mysql driver line. Double-check that you've copied all the php dll files into C:\Windows\System32.

Link to comment
Share on other sites

Check your php.ini file and make sure to uncomment the mysql driver line. Double-check that you've copied all the php dll files into C:\Windows\System32.

I had already done that. Would it help to try PHP 5? I chose 4.3 thinking it would be more stable. Or should I try an older version of Apache instead of Apache2?
Link to comment
Share on other sites

Thanks.  That proved that PHP is working but it isn't connecting to MySQL.  I got the error message and not the code.  I know MySQL itself is working because I can access the database using Navicat.  Now I just have to figure out why PHP can't connect to it.

I went ahead and installed PHP5 and now you're code is showing a successful connection. Hurray! So far. But Dreamweaver still isn't connecting. All of the documentation I can find only shows how to connect to a remote location and I'm trying to test this on my local machine. Edited by lewmur
Link to comment
Share on other sites

I went ahead and installed PHP5 and now you're code is showing a successful connection.  Hurray!  So far.  But Dreamweaver still isn't connecting.  All of the documentation I can find only shows how to connect to a remote location and I'm trying to test this on my local machine.

I found this site and carefully followed the instructions. It worked.http://computerbookshelf.com/phpdw/install1.php
Link to comment
Share on other sites

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.   Paste as plain text instead

  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...