我真的不知道为什么我尝试连接并从MySQL数据库中提取一些数据,但它不起作用。我有一个名为“ my_db”的数据库和一个名为“ men”的列;这是我的代码
$servername = "localhost";
$username = "myusername";
$password = "";
$db = "my_db";
$conn = new mysqli($servername, $username, $password, $db);
$sql="SELECT * FROM men where 'surname' = Smith";
$result = $conn->query($sql);
我要去哪里错了?
答案 0 :(得分:0)
请尝试以下代码:
$servername = "localhost";
$username = "myusername";
$password = "";
$db = "my_db";
$conn = new mysqli($servername, $username, $password, $db);
$sql="SELECT * FROM men where surname = 'Smith'";
$result = $conn->query($sql);