why can't connect to the mysql
Question
one: i using this code to connect mysql databse which on a shared host.
<?php
mysql_connect("localhost", "user", "123") or die(mysql_error());
echo "Connected to MySQL<br />";
?>;
the user and password are created by the cpanel.which are the database's user and password.
two: i use this line mysql -hlocalhost -uuser -p123
in my window operation system MS-DOS window. but it still can't connect the mysql. why?
Solution
I think you need to declare a variable. ie $link = mysql_connect("...")
...
or you might want to specify which db you want to connect to, the db name.
OTHER TIPS
mysqli_connect("host_parameter", "user_parameter", "password_parameter, "database_parameter");
$link= mysqli_connect("localhost","root","root_password","my_database");
if(empty($link)){
die("Error:" . mysqli_error());
}
if it's your first time ( mysql user_parameter = root and password = "")
HOPE IT HELP U
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow