$connection => a string to be called for the connection. This string can be stated by any name such as db, connection,...
mysql_connect() requires a host name, user name and password (in that order).
Add a die() function to the mysql_connect() line to cause the script to end and a message to display if the connection fails.
Within the die() function, use the mysql_error() function in order to print out the exact error sent by MySQL.
the full code will be input like this:
However, the connection error is shown:
the error cause the problem is mysql_connect function. It lacks of @ so we can fix like
the problem still happen:
This error mean I use wrong user name and pass in order to connect to MySQL Database server.
Other method to connect
Creating 4 variables such as :
// This is to connect to localhost server, it can be domain name hoặc IP address
$SERVER = " localhost";
//account user name which logins MySQL server, is root
$USERNAME = " root";
//account password to login mysql server
$PASSWORD="";
With MySQL syntax:
mysql_connect($server_address, $username, $password)
I have some lines of code :
No comments:
Post a Comment