由于PHP5.5版本之后不再推荐使用mysql_query()函数,建议用以下2种代替方法

mysqli_query()
PDO::_query()

示例

<?php
$host = 'localhost:3306';
$user = 'root';
$pass = '';
$dbname = 'mydb';

$conn = mysqli_connect($host, $user, $pass, $dbname);
if(!$conn){
	die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';

$sql = "create table emp5 (id INT AUTO_INCREMENT,name VARCHAR(20) NOT NULL,emp_salary INT NOT NULL, Primary key (id))";
if(mysqli_query($conn,$sql))
{
	echo "Table emp5 created successfully";
}else{
	echo "Could not create table: ".mysqli_error($conn);
}

mysqli_close($conn);
?>

执行上述代码,输出结果如下:

Connected successfully
Table emp5 created successfully