PHP, apache and mysql installed but can't connect

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Coxster
Forum Newbie
Posts: 14
Joined: Tue Nov 01, 2005 3:22 am

PHP, apache and mysql installed but can't connect

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if that's your entire script and the code succeeded, nothing would be output.. what are you expecting?
Hyarion
Forum Newbie
Posts: 12
Joined: Tue Nov 01, 2005 4:30 am
Location: South Africa

Post 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!";
Coxster
Forum Newbie
Posts: 14
Joined: Tue Nov 01, 2005 3:22 am

Post 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
Coxster
Forum Newbie
Posts: 14
Joined: Tue Nov 01, 2005 3:22 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

have a look through your error logs, an error may have gone there instead of being displayed on the page.
Coxster
Forum Newbie
Posts: 14
Joined: Tue Nov 01, 2005 3:22 am

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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');
Post Reply