pcw Posted March 16, 2009 Share Posted March 16, 2009 Hi, I am using this link to delete a row from a mysql database: <a href='admin.php?cmd=delete&username=".$row['username']."'>Delete</a> This successfully carries over the username to delete and runs the script below, but it is not deleting the row from the database. <?php if($_GET["cmd"]=="delete") { include_once("data/required.php"); mysql_connect("$hostname", $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); $query = "DELETE FROM profiles WHERE username='$username'"; $result = mysql_query($query); echo "Row deleted!"; } ?> Any help is much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/149645-deleting-row/ Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 I don't see where you GET username. Put or die(mysql_error()) at the end of your query and see what it says. Quote Link to comment https://forums.phpfreaks.com/topic/149645-deleting-row/#findComment-785796 Share on other sites More sharing options...
Zane Posted March 16, 2009 Share Posted March 16, 2009 use $_GET['username'] instead of $username Quote Link to comment https://forums.phpfreaks.com/topic/149645-deleting-row/#findComment-785797 Share on other sites More sharing options...
PFMaBiSmAd Posted March 16, 2009 Share Posted March 16, 2009 If you develop and debug your code on a system with error_reporting set to E_ALL and display_errors set to ON you will get immediate feedback about variables that are not being set in your code and other problems that php detects that will help you develop and debug your code quicker. Quote Link to comment https://forums.phpfreaks.com/topic/149645-deleting-row/#findComment-785804 Share on other sites More sharing options...
pcw Posted March 16, 2009 Author Share Posted March 16, 2009 Thanks for your help all Quote Link to comment https://forums.phpfreaks.com/topic/149645-deleting-row/#findComment-785805 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.