delete from sql with a delete.php file -


i wanting build delete page use delete data database.

when put id in works fine wanting pull id url

www.example.com/delete.php?id=1234

<?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) {   die('could not connect: ' . mysql_error()); } $sql = 'delete mytable         created=<?php echo $_get["id"]; ?>';  mysql_select_db('ely'); $retval = mysql_query( $sql, $conn ); if(! $retval ) {   die('could not delete data: ' . mysql_error()); } echo "deleted data successfully\n"; mysql_close($conn); ?> 

the part im having issues part

 created=<?php echo $_get["id"]; ?>'; 

the error getting "could not delete data: have error in sql syntax; check manual corresponds mysql server version right syntax use near '=' @ line 2"

<?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) {   die('could not connect: ' . mysql_error()); } $id = mysql_real_escape_string($_get['id']); $sql = "delete mytable         created='$id'";  mysql_select_db('ely'); $retval = mysql_query( $sql, $conn ); if(! $retval ) {   die('could not delete data: ' . mysql_error()); } echo "deleted data successfully\n"; mysql_close($conn); ?> 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -