I am just a php and mysql beginner and I want to learn both, so I turned Apache and MySQL on with help of this article, and i created some databases and tables using CocoaMySQL (with username "root" and empty password). But when I write this basic script
to Library/WebServer/Documents/index.php and I go to localhost with Safari, I get this message:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Library/WebServer/Documents/index.php on line 2
What am I doing wrong?
Code:
<?php
$link=mysql_connect ("localhost", "root", "") or die ("bad");
echo("good");
mysql_close ($link);
?>
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Library/WebServer/Documents/index.php on line 2
What am I doing wrong?