Apache stopped working when connecting to mysql. pls help

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Apache stopped working when connecting to mysql. pls help

Postby rockrob » 19. August 2009 10:25

<?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
rockrob
 
Posts: 2
Joined: 19. August 2009 10:10

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

Postby rockrob » 19. August 2009 11:15

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";
?>
rockrob
 
Posts: 2
Joined: 19. August 2009 10:10


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 101 guests