Please answer questions from various PHP experts! & Lt ;? Php $ serverLink = @ mysql_connect (& quot; localhost & quot;, & quot; root & quot;, & quot;) ordie (& quot; failed to connect to the server! I have trouble answering various PHP experts!
$ ServerLink = @ mysql_connect ("localhost", "root", "") or die ("failed to connect to the server! Program interrupted execution! ");
Mysql_query ("set names 'gbk '");
$ DbLink = @ mysql_select_db ("student", $ serverLink) or die ("The current connection to the server failed! Program interrupted execution! ");
If ($ dbLink ){
Echo "select student database as the current database! ";
}
$ Close = @ mysql_close ($ serverLink );
?>
When I run this program, the page displays always ("The current connection to the server failed! Program interrupted execution! "), And I want to display" select student database as the current database! ";
What should I do?
------ Solution --------------------
$ ServerLink = mysql_connect ("localhost", "root", "") or die (mysql_error ());
Mysql_query ("set names 'gbk '");
$ DbLink = mysql_select_db ("student", $ serverLink) or die (mysql_error ());
In this way, the program will tell you where the error is.
------ Solution --------------------
Your last question is more specific than this. I think you are talking about creating student as a data table, which means that the student database does not exist at all. CREATe DATABASE student first. Log on to PHPMYADMIN to view the details.
If the database student exists, remove the @ symbol and let the system report a detailed SQL error.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.