![]() |
PHP experts .. please help!!
I'm trying to make a script to delete a row from a mysql table ......
Can someone tell me what's wrong ??!? Please take a look on the last 7 lines .. without them it works (but the script is not complete) PHP Code:
|
$sql = "DELETE FROM poly_links WHERE id='$id';";
$result = mysql_query($sql); Try this |
Does have $id a vaule??
Just put on top print "id value :$id<br>\n"; then you know it has a value..otherwise there is nothing to delete |
Code:
{ You can verify this by putting: Code:
die("SQL QUERY: " . $sql); DELETE FROM poly_links WHERE id= then that's not valid SQL. Grumpy's quoting suggestion is good practice. |
The quoting isn't necessary for numeric characters, if the field id is in fact numeric. You should write a function to convert all your empty numeric values to NULL and to quote all your strings. A lot of people call these clean up functions, etc. Also mysql_query does not return anything on DELETE or INSERT. So there is no sense in setting $result to nothing :)
I don't know what error you're getting, but chances are you have no value in $id as suggested previously. Also - I am *guessing* that I cannot see your entire script - but if that *is* the whole script, you need register_globals on...which is a very, very bad thing to do. register_globals if for pretend environments. |
All times are GMT -7. The time now is 02:31 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123