我的代码只显示一个没有文字的空白页。为什么mysql_connect
无法连接到数据库?
我使用的 MySQL 版本是 5.0.77,PHP 版本是 5.1.6
$user = "user";
$password = "user";
#$database = "database";
$con = mysql_connect("localhost",$user,$password);
if (!con) {
echo "could not connect";
} else {
echo "connected";
}
if (mysql_query("CREATE DATABASE my_db",$con)) {
echo "databse created";
}
#@mysql_select_db($database) or die( "Unable to select database");
#$query="CREATE TABLE tablename(id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,field1-name varchar(20) NOT NULL,field2-name varchar(20) NOT NULL,field3-name varchar(20) NOT NULL,field4-name varchar(30) NOT NULL,field5-name varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
#mysql_query($query);
mysql_close($con);