I have a call to a PHP script from my home page which I do like this:
echo '<a href="/problems/delete_problem.php?problem_id='.$problem_id.'">Delete</a>';
So it is pretty standard.
Then in my PHP I have this code:
<?php
// delete_problem
include '../connect.php'; // Here I have db connection settings
error_log ( ".......in delete problem");
$problem_id = mysql_real_escape_string($_GET["problem_id"]);
?>
And the last line where I try to get the problem_id is throwing the undefined index error. Any idea why?
Thanks!
Have you got an actual connection inside connect.php? Or does it just store variables and the like?
mysql_real_escape_stringmay be causing a problem as if a connection is not available it will fail.Beyond that, try echoing out the contents of the GET variable. You can also check whether it exists by using
(isset($_GET["problem_id"])).