Reply to Re: mysql DELETE syntax on 3.23.58

Your name:

Reply:


Posted by Mark D. Smith on 04/23/06 23:12

"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

Mark

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация