1

I am trying to allow DELETE-ion of employees in a database. I have stored the query string being passed into a variable named $id. When I run my SQL DELETE statement, it echo's out but is not echo-ing or recognizing the $id variable I instantiated. Any ideas?

PHP

//QUERY STRING
"<td><a href='delete.php?id=" . $row['empid']  . "'>Delete</a></td>" .

//ID VARIABLE
 $id = (isset($REQUEST['id']) ? $_REQUEST['id'] : '');

SQL

//SQL STATEMENT
$sql = "DELETE FROM employees WHERE empid= '" . $id . "';";

//WHAT ECHOS OUT IS BELOW
echo($sql);

//RUN SQL Command
mysqli_query($connect,$sql) or die(mysql_error());
print("User " . $id . " deleted from the database.");
print("Return to <a href='index.php'>Return To Main Page</a>");

DELETE FROM employees WHERE empid= '';

When I click delete from the index.php the employee I tried to delete is still there.

CodeConnoisseur
  • 1,452
  • 4
  • 21
  • 49

1 Answers1

3

You need to change this line

$id = (isset($REQUEST['id']) ? $_REQUEST['id'] : '');

to

$id = (isset($_REQUEST['id']) ? $_REQUEST['id'] : '');

Simon R
  • 3,732
  • 4
  • 31
  • 39