PHP: Delete specific row in MySQL -


i'm trying delete row in mysql database. row deleted defined _get tag. if page url deletepage.php?id=5 wil delete row id=5.

here code far:

<?php  if (empty($_get)) {echo "error!";}  else {     include "../../includes/dke390d-ko.php";     $pageid = $_get['id'];;     $conn = mysql_connect($dbhost, $dbuser, $dbpasswd); if(! $conn ) {   die('could not connect: ' . mysql_error()); } $sql = 'delete page         id="$pageid"';  mysql_select_db($dbname); $retval = mysql_query( $sql, $conn ); if(! $retval ) {   die('could not delete data: ' . mysql_error()); } echo "deleted data successfully\n"; mysql_close($conn);     header("location: index.php");     }  ?> 

my problem when execute code getting error message saying: not delete data: unknown column 'id' in 'where clause'

i should put id in session. that'll come later.

best regards!

you have variable in string delimited single quotes. result variable not interpolated. swap quotes fix this:

$sql = "delete page         id='$pageid'"; 

like said in comments above, code obsolete , insecure. should make fixing high priority.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -