Page 1 of 1

PHP, apache and mysql installed but can't connect

Posted: Tue Nov 01, 2005 4:49 am
by Coxster
Hi, I have php apache, php my admin and mysql installed as per this sites instructions:
http://mpcon.org/apacheguide/apache.php

I tried using mysql_connect() but nothing happens.

Code: Select all

<?php
	error_reporting(E_ALL);

	mysql_connect("localhost", "username", "password") or die("...");
?>
The web page I see is blank, there are no errors displayed. Mysql is working because I created a new user, database and table with MySQL Administrator.

Does anyone know what my problem could be?

Posted: Tue Nov 01, 2005 8:18 am
by feyd
if that's your entire script and the code succeeded, nothing would be output.. what are you expecting?

Posted: Tue Nov 01, 2005 8:20 am
by Hyarion
Your script isn't outputting anything to the page, so you wouldn't see anything if it was working. Actually, the fact that you are not getting an error is probably because it is in fact working. ;)

After your last line try adding

Code: Select all

echo "Connected to Mysql Database Successfully!";

Posted: Tue Nov 01, 2005 9:29 am
by Coxster
Hi, sorry. That was a test code.

Previously I had code (taken from the php book that I'm using to learn php) that cycled through databases displaying their names and tables.

This didn't work. It use to output html until the mysql_connect and then that was it.

Didn't even close the body and html tags. Left them open, but there were no error messages or anything. Something wen wrong but it doesn't tell me what

Posted: Tue Nov 01, 2005 9:33 am
by Coxster
Hyarion wrote:After your last line try adding

Code: Select all

echo "Connected to Mysql Database Successfully!";
Tried this. The page was blank. No error message and nothing echoed to the screen.

Posted: Tue Nov 01, 2005 9:59 am
by feyd
have a look through your error logs, an error may have gone there instead of being displayed on the page.

Posted: Tue Nov 01, 2005 11:17 am
by Coxster
Where can I find the error logs for mysql?

I've been through lots of folders in the MySQL folder in Programme but I can't see anything like an error log.

Posted: Tue Nov 01, 2005 12:41 pm
by Chris Corbyn
He means your PHP error logs. If mysql was giving errors you'd probably see the issues show in PHP.

It sounds as though error reporting is turned off in PHP and display errors may be off too.

Code: Select all

//Top of your php script
error_reporting(E_ALL);
ini_set('display_errors', 'On');