Posted by J.O. Aho on 04/24/06 06:54
Mark D. Smith wrote:
> "J.O. Aho" <user@example.net> wrote in message
> news:4b1ve0Fvh1iiU1@individual.net...
>> Mark D. Smith wrote:
>>> Hi
>>>
>>> i can INSERT and UPDATE but DELETE is not working
>>>
>>> $sql = "DELETE FROM table WHERE ID='$ID'";
>>> $sql_result = mysql_query($sql,$connection) or die ("Couldn't execute
> Delete
>>> of row $ID.");
>>>
>>> $ID is the primary key and i want to delete the entire row based on the
>>> users selection.
>>
>> $sql="DELETE FROM table WHERE ID='$ID'";
>>
>> if(!($del_res=mysql_query($sql))) {
>> $sql="SELECT ID FROM table WHERE ID='$ID'";
>> if($sel_res=mysql_query($sql)) {
>> if(mysql_num_rows($sel_res)) {
>> echo "Couldn't delete $ID\n";
>> } else {
>> echo "False positive result, there is no $ID in the table\n";
>> }
>> } else {
>> echo "There aren't any $ID in the table\n";
>> }
>> } else {
>> if($rows=mysql_affected_rows($del_res)) {
>> echo "Number of entries deleted: $rows\n";
>> } else {
>> echo "There wasn't anything to delete\n";
>> }
>> }
>>
>> This should give you a better understanding why the delete failed.
>>
>>
>> //Aho
>
> I get back "There aren't any 59 in the table"
> where 59 is the row i am trying to delete
The user you login as to the sql server, does that user have the privilige to
delete from the table?
//Aho
Navigation:
[Reply to this message]
|