I am a newbie to PHP and to the net world, and trying to connect to a mySQL Db using this PHP code:
<?php echo "Hello World \n"; $mysql_host = "MySQL Host"; // this is what specified to use in mySQL management page at my host $mysql_database = "mysql_database"; $mysql_user = "mysql_user"; $mysql_password = "mysql_password"; echo $mysql_host; $conn = mysql_connect($mysql_host, $mysql_user, $mysql_password); if (!$con) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($mysql_database); if (!$db_selected) { die ('Can\'t use '.$mysql_database.' : ' . mysql_error()); } ?> please, what can be wrong with this code? I couldn't find any syntax error and still - I am not able to connect to the Db
can it be and the problem is related to the host only?
MySQL Host. More likely it islocalhoston a shared hosting service.mysqlerror();