Page 1 of 1

Help Can't Connect to MySQL!!!

Posted: Thu Jan 14, 2010 1:18 am
by crazycompsci
I'm relatively new to the whole PHP and MySQL thing here but definitely not a new developer. Here's what I've got:

Code: Select all

 
<html>
<body>
 
<?php
 
ini_set('display_errors', 1); 
error_reporting(E_ALL);
 
$conection = mysql_connect("localhost","root","",true);
 
if (!$connection)
{
  die('<div>Could not connect: ' . mysql_error() . '</div>');
}
else
{
  echo("Connected");
}
 
mysql_close($connection);
?>
 
</body>
</html>
 
It's producing this output:

Code: Select all

 
Notice: Undefined variable: connection in /Library/WebServer/Documents/index.php on line 11
Could not connect:
 
Now I know things are set up correctly since I can connect to MySQL using the workbench and command line. And the really odd thing is I have a WordPress blog set up as well and that has absolutely no issues connecting at all. I tried to see how it was doing the connection and was unsuccessful at replicating it. Any help would be MUCH appreciated.

Re: Help Can't Connect to MySQL!!!

Posted: Thu Jan 14, 2010 1:22 am
by flying_circus
looks like you're missing an "n" in line 10?

Re: Help Can't Connect to MySQL!!!

Posted: Thu Jan 14, 2010 1:32 am
by crazycompsci
yeah I just found it... thats what you get for coding at 2:30 in the morning with no sleep... :)