Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble with DELETE in user lists

Status
Not open for further replies.

internetguy

Technical User
Nov 22, 2003
57
US
I have a database with users, but I want to make it so that an administrator can delete any users they see fit. The code seems correct and no error occurs but the user is still in the database. Here is my code.

<?php
$name = $_POST['name'];

if (!$name)
{
echo &quot;You did not input a user name, please try again\n&quot;;
echo &quot;<p><a href='user_del.php'>+Retry</a><br>\n&quot;;
echo &quot;<a href='../main.php'>+Main Page</a></p>\n&quot;;
}
else
{
$db = mysql_connect('localhost','root');
mysql_select_db('users');
$query = &quot;DELETE * FROM info WHERE name='&quot;.$name.&quot;'&quot; or die(mysql_error());
echo &quot;User has been deleted from the database\n&quot;;
echo &quot;<p><a href='user_del.php'>+Delete Another User?</a><br>\n&quot;;
echo &quot;<a href='../main.php'>+Main Page</a></p>\n&quot;;
}
?>
 
You never execute the query. (And you can omit * from the delete statement.)
 
Ok, I added a result variable and it works fine, thank you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top