0

I really don't know why I try to connect and extract some data from a MySQL db and it doesn't work. I have a db named "my_db" and a column named "men"; here's my code

$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);

Where am I going wrong?

Lorenzo Tosone
  • 393
  • 3
  • 10

1 Answers1

0

Please try below code:

$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);