Newbie question : delete via php fails

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
redmosquito
Forum Newbie
Posts: 2
Joined: Sat Mar 10, 2007 9:05 pm

Newbie question : delete via php fails

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
redmosquito
Forum Newbie
Posts: 2
Joined: Sat Mar 10, 2007 9:05 pm

Post by redmosquito »

a reboot of my laptop fixed it. Do I need to re-initialize the mysql daemons to apply the updated privileges?
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

after any changes to mysql privileges you need to issue the following

Code: Select all

mysql>flush privileges;
Post Reply