简单的mysqli_query SELECT返回false

时间:2015-04-06 15:40:56

标签: php mysql

我真的不明白为什么下面的东西会抛弃我(假)



// Create connection
$conn = mysqli_connect($servername, $username, $password);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";


$sql = "SELECT id FROM maxims ORDER BY RAND() LIMIT 1";
var_dump(mysqli_query($conn, $sql)) or die(mysql_error());




1 个答案:

答案 0 :(得分:1)

 mysqli_connect("myhost","myuser","mypassw","mydb");

 e.g

 $conn = mysqli_connect('localhost','user','password','database1');

http://php.net/manual/en/function.mysqli-connect.php