lmhart Posted October 21, 2009 Share Posted October 21, 2009 I have a page that lists the user and has an option to delete the record. But I can not get it to delete the record. I believe that I am passing the correct information but it just will not delete. It just goes to delete.php and displays a blank name. The pop up that I have before it switches pages post the correct info. Where am I going wrong? ->addColumnAfter('actions', '<a href="#edit.php?id=$user_id$">Edit</a> - <a href="delete.php?id=$id_user$" onclick="return confirm('Are you sure you want to delete user $id_user$?')">Delete</a> ', 'Actions', array('align' => 'center')) delete.php <php include 'dbc.php'; $id_user = $_GET[id]; echo $id_user; echo "<br>"; echo $id; mysql_query("Delete From users where id_user = $id_user"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/178474-solved-deleting-a-row/ Share on other sites More sharing options...
smerny Posted October 21, 2009 Share Posted October 21, 2009 generally, if you print your query statement you can see the problem. if you printed it you would probably see "Delete From users where id_user = $id_user" when in fact you want "Delete From users where id_user = [the actual user ID]" try this: mysql_query("Delete From users where id_user = '".$id_user."'"); Quote Link to comment https://forums.phpfreaks.com/topic/178474-solved-deleting-a-row/#findComment-941164 Share on other sites More sharing options...
lmhart Posted October 21, 2009 Author Share Posted October 21, 2009 Ok I changed my code to the above and it did nothing. So I commented out the query so it would just echo what is passed and all I get is a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/178474-solved-deleting-a-row/#findComment-941175 Share on other sites More sharing options...
lmhart Posted October 21, 2009 Author Share Posted October 21, 2009 Well I took a close look at the code and I was missing the first ? at the top <? here is code that works! Thanks for all the help <?php include 'dbc.php'; $id_user = $_GET[id]; echo "the user to be deleted is - "; echo $id_user; echo "<br>"; echo $id; mysql_query("Delete From users where id_user = ".$id_user.""); ?> Quote Link to comment https://forums.phpfreaks.com/topic/178474-solved-deleting-a-row/#findComment-941182 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.