PHP连接MYSQL操作数据库
<?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } if (mysql_query("CREATE DATABASE MYDB1",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } mysql_selectdb("MYDB1",$con); $sql=' CREATE TABLE Persons ( FirstName varchar(15), LastName varchar(15), age int ) '; if(mysql_query($sql,$con)) { echo 'Table Created'; } else { echo mysql_error(); } mysql_close($con); ?>