Page 1 of 1

Apache stopped working when connecting to mysql. pls help

PostPosted: 19. August 2009 10:25
by rockrob
<?php

mysql_connect(localhost,"root","******");
@mysql_select_db("test") or die( "Unable to select database");
$query="SELECT * FROM test1";
$result=mysql_query($query);

$num=mysql_numrows($result);
echo $num;
mysql_close();

?>

When I try it windows displays message "Apache stopped working..."

p.s. I used wrong password, then this works correctly and show "Unable to select database".
probably error is in mysql_query($result); or @mysql_select_db("test")

Any help would be appriciated

Re: Apache stopped working when connecting to mysql. pls help

PostPosted: 19. August 2009 11:15
by rockrob
never mind.

incase if anyone have same problem this is working code;



<?php
$username="root";
$password="*****************";
$database="test";

$con = mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM contacts";
$result=mysql_query($query);

mysql_close($con);
/*this is where i made it wrong*/
echo "done";
?>