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.