Cluster Cluster - 3 months ago 21
MySQL Question

PHP, MySQL - How to correctly pass a variable in to a link

So what I have is:

$id = $_POST['id'];
$loann = $_POST['loann'];
$dater = $_POST['dater'];
$apaid = $_POST['apaid'];

... and:

$result = mysql_query("UPDATE _loan SET loana='$loann', dater = CONCAT_WS(',', dater, '$dater' ), apaid = CONCAT_WS(',', apaid , '$apaid' ) WHERE id=$id");

echo $id;

Everything works fine now the problem shows when I tray to pass the value of $id into:

echo ('<meta http-equiv="refresh" content="1;url=view_details.php?id=$id">');

What I would get in the browser would be:$id

Instead of:

Any help is greatly appreciated.


You're using a single-quoted string, which doesn't expand variables. Either use a double-quoted string:

"<meta http-equiv=\"refresh\" content=\"1;url=view_details.php?id=$id\">"

or concatenate the strings:

'<meta http-equiv="refresh" content="1;url=view_details.php?id=' . $id . '">'

Side note: Your code is vulnerable to SQL injection. You should start reading here and here.