Page 1 of 1

Newbie question : delete via php fails

Posted: Sat Mar 10, 2007 9:17 pm
by redmosquito
I have a small piece of code that is failing and have no idea why ..

function delete($User){
$query = "delete from test where name='{$User}'";
echo "<BR>$query<BR>";
mysql_query($query) or die ('Query failed');
}

I get query failed every time I run it. The same script has functions for querying and adding data and they work fine. the user has delete privileges on the table.

I am a UNIX administrator trying to put together a website for system and password management. Is there anything already out there that I can use quickly? I am quite comfortable with shell scripting, but php is a little out of my domain. I don't want to re-invent the wheel here ....

Thanks,
Red

Posted: Sat Mar 10, 2007 9:19 pm
by John Cartwright
Try this instead

Code: Select all

function delete($User){
   $query = "delete from test where name='{$User}'";
   echo "<BR>$query<BR>";
   mysql_query($query) or die (mysql_error());
}
And please use tags in the future.

Posted: Sun Mar 11, 2007 2:39 pm
by redmosquito
a reboot of my laptop fixed it. Do I need to re-initialize the mysql daemons to apply the updated privileges?

Posted: Sun Mar 11, 2007 2:48 pm
by mikeq
after any changes to mysql privileges you need to issue the following

Code: Select all

mysql>flush privileges;