Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mySQL connection - no evidence of connection

Status
Not open for further replies.

golcarlad

Programmer
Nov 23, 2004
232
GB
When using the code below the browser shows absolutely nothing, not even the debug message "Unable to connect to MySQL"....why is this happening, is there something wrong with the way mySQL is setup or Apache??
It does manage to print out simple variable values in the browser, but I get no response when trying to connect to my database. Any help much appreciated.



<?php

$username = "foousername";
$password = "foopass";
$hostname = "localhost";
echo $username;
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";
// you're going to do lots more here soon
mysql_close($dbh);
?>
 
echo $username;

do you see the $username value? may be you have a problem with the apache config in order to interpretate the php script.
 
Hi,

just looked in the error.log for Apache and it says

Code:
[client 127.0.0.1] PHP Fatal error:  Call to undefined function mysql_connect() in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\Elkosite\\test.php on line 7
[Wed Feb 02 16:01:25 2005] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/favicon.ico
 
hmmmm... you have windowz...
it looks like you have php compiled with no mysql support, that's quite weird... or you have a file missing...

what's your php version?
 
Hey thanks Chaclinc, have sorted it now - apparently you have to do some dll copy pasting and edit the php.ini file to enable an extension for mySQL. Apparently you dont have this setup by default at version 5 of php, where in earlier versions you didnt have this problem - no wonder its not mentioned in many computer help books.
 
great, thank for post the solution. It will help for others!

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top