title: PHP delete form for deleting data from MySQL database
body: <p>I'm making a PHP script for deleting data out of a MySQL table. 
  But it isn't working, could someone tell me what I'm doing wrong?
  Below you can see my two php scripts for deleting the information out the database.</p>
  
  <p>First script
      
  
  <pre><code>// Connect to server and select database.
  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
  
  // select record from mysql 
  $sql="SELECT * FROM $tbl_name";
  $result=mysql_query($sql);
  var_dump($sql)
  ?&gt;
  
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;strong&gt;Hardware verwijderen&lt;/strong&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;strong&gt;HardwareID&lt;/strong&gt;&lt;/td&gt;
  &lt;td&gt;&lt;strong&gt;Merk&lt;/strong&gt;&lt;/td&gt;
  &lt;td&gt;&lt;strong&gt;Producttype&lt;/strong&gt;&lt;/td&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php
  while($rows=mysql_fetch_array($result)){
  ?&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;? echo $rows['hardwareID']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;? echo $rows['merknaam']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;? echo $rows['producttype']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;a href="delete_hardware.php?id=&lt;? echo $rows['id']; ?&gt;"&gt;delete&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php
  // close while loop 
  }
  ?&gt;
  
  &lt;/table&gt;
  
  &lt;?php
  // close connection; 
  mysql_close();
  ?&gt;
  </code></pre>
  
  <p>Second script</p>
  
  <pre><code>    &lt;?php
  $host="localhost"; // Host name 
  $username="root"; // Mysql username 
  $password=""; // Mysql password 
  $db_name="helpdesk_middenpolder"; // Database name 
  $tbl_name="hardware"; // Table name 
  
  // Connect to server and select database.
  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
  
  // get value of id that sent from address bar 
  $id=$_GET['id'];
  
  // Delete data in mysql from row that has this id 
  $sql="DELETE FROM $tbl_name WHERE hardwareID='$id'";
  $result=mysql_query($sql);
  
  // if successfully deleted
  if($result){
  echo "Deleted Successfully";
  echo "&lt;BR&gt;";
  echo "&lt;a href='testinlogpagina.php'&gt;Terug naar de startpagina&lt;/a&gt;";
  }
  
  else {
  echo $sql . '. Details: ' . mysql_error();
  }
  ?&gt; 
  
  &lt;?php
  // close connection 
  mysql_close();
  ?&gt;
  </code></pre>
  
  <p>**edit</p>
  
  <p>result from var_dump: string 'SELECT * FROM hardware' (length=22)</p>