tags:

views:

71

answers:

1

Hi,

I'm new to PHP and i've been learning some php for the past couple of days, now i'm trying to execute a script with MySql code in it but unfortunately the browser comes up with an error about httpd.exe!

it's just a simple code making a mysql connection:

<?php

$conn = mysql_connect("localhost", "root", "");
echo "$conn";
mysql_close($conn);

?>

before i had the problem of an undefined function in php mysql_connect which has been fixed. I have Apache 2.2.16 & PHP 5.2.6, running on windows xp.

A: 

My guess is that it's probably crashing on echo "$conn", because you're trying to force PHP to cast a MySQL resource to a string. If you want to inspect the connection object, use var_dump or print_r.

Daniel Vandersluis
Nope. Still crashing. :(btw i'm following a tutorial from a book.
Mahie
What's the error?
Daniel Vandersluis
httpd.exe just crashes, an unhandled win32 exception.
Mahie
Is MySQL installed and running? Have you set up PHP to use MySQL? (see http://ca.php.net/manual/en/mysql.installation.php) Is "root" with no password a valid user for your MySQL?
Daniel Vandersluis
yes, i've done that i used to receive a different error message about an undefined function mysql_connect, so i'm pretty sure mysql is installed properly now. I'm not sure what the problem is, maybe something to do with apache.
Mahie
Everythings fixed, i added the wrong path directory in the path variable under environment variables in the system properties. Thank goodness it works! on the shit side, all the tuts i worked on are now deleted cause i had to install a slightly older version of apache even though that wasn't the problem.
Mahie