Error deleting record: You have an error in your SQL syntax;
<p><br>
I am using php code from w3schools that will let me delete a row from my database. I am getting an error "Error deleting record: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version"<br>
I can't seem to find the correct code for the server version that I am using. <br>
This is my delete.php</p>

<pre><code>&lt;?php
$servername = "";
$username = "";
$password = "";
$dbname = "";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn-&gt;connect_error) {
    die("Connection failed: " . $conn-&gt;connect_error);
} 

// sql to delete a record
$sql = "DELETE FROM users WHERE id=$id";

if ($conn-&gt;query($sql) === TRUE) {
    echo "Record deleted successfully";
} else {
    echo "Error deleting record: " . $conn-&gt;error;
}

$conn-&gt;close();
?&gt;
</code></pre>

<p>This is the page that links to my delete.php<br></p>

<pre><code>&lt;HTML&gt;

&lt;?php

$db = mysql_connect("", "", "");
mysql_select_db("",$db);
$result = mysql_query("SELECT * FROM users",$db);
echo "&lt;TABLE BORDER=10&gt;";
echo"&lt;TR&gt;&lt;TD&gt;&lt;B&gt;Username&lt;/B&gt;&lt;TD&gt;&lt;B&gt;Password&lt;/B&gt;&lt;TD&gt;&lt;B&gt;Email&lt;/B&gt;&lt;TD&gt;&lt;B&gt;City&lt;/B&gt;&lt;TD&gt;&lt;B&gt;Zip&lt;/B&gt;&lt;/TR&gt;";
while ($myrow = mysql_fetch_array($result))
{
echo "&lt;TR&gt;&lt;TD&gt;".$myrow["username"]."&lt;TD&gt;".$myrow["password"]."&lt;TD&gt;".$myrow["email"]."&lt;TD&gt;".$myrow["city"]."&lt;TD&gt;".$myrow["street"];
echo "&lt;TD&gt;&lt;a href=\"adminEdit.php?id=".$myrow[id]."\"&gt;Edit&lt;/a&gt;";
echo "&lt;a href=\"adminDelete.php?id=".$myrow[id]."\"&gt;Delete&lt;/a&gt;";
}
echo "&lt;/TABLE&gt;";

?&gt;
&lt;/HTML&gt;
</code></pre>