Reply to Re: strange behaviour using arrays to update records

Your name:

Reply:


Posted by mantrid on 08/07/06 15:49

> > *****
> > $delarray=$_POST['del'];//not needed in the sql of first two queries so
isnt
> > in for loop
> >
> > if(count($delarray)==0){
> > for ($i = 0; $i < count($commindexarray); $i++){
> > $currtime=date('YmdHis');
> > $cat = intval($_POST['category'][$i]);
> > $comm = mysql_real_escape_string($_POST['comm'][$i]);
> > $avail =$_POST['avail'][$i];
> > $commindex = intval($_POST['commindex'][$i]);
> >
> > $q2 ="UPDATE usercomms SET typeid=$cat WHERE
userid=".$_SESSION['userid']."
> > AND commindex =$commindex";//
> > $updateusercomm = mysql_query($q2) or die('<br><span
> > class=RedWarning>Sorry, there was a problem updating. Try
> > again.<br><br>Error - 1 '.count($delarray). mysql_error().'</span>');
> > $q="UPDATE comments SET typeid=$cat, comment='$comm', available=$avail,
> > timestp='$currtime', globalavail=0 WHERE commindex=$commindex";//
> > $updatecomm = mysql_query($q) or die('<br><span class=RedWarning>Sorry,
> > there was a problem updating some records. Try again.<br><br>Error - 2
> > '.count($delarray).mysql_error().'</span>');
> > }
> > }
>
> I would print out $q and $q2 to ensure that $_SESSION['userid'] contains
> what you thought it does.
>

This I did and it is as expected,
Another thing I tried was to put the queries outside of the loop and
substitute the values from the arrays (which are also ok as i checked them
when i ran phpinfo()) with numbers as shown below


$q2 ="UPDATE usercomms SET typeid=1 WHERE userid=".$_SESSION['userid']." AND
commindex =339";
$updateusercomm = mysql_query($q2) or die('<br><span class=RedWarning>Sorry,
there was a problem updating. Try again.<br><br>Error - 1
'.count($delarray). mysql_error().'</span>');

$q="UPDATE comments SET typeid=1, comment='ggdsffgdsfg', available=1,
timestp='$currtime', globalavail=0 WHERE commindex=339"; $updatecomm =
mysql_query($q) or die('<br><span class=RedWarning>Sorry, there was a
problem updating some records. Try again.<br><br>Error - 2
'.count($delarray).mysql_error().'</span>');

And this worked. so it looks like it is the loop or something

by the way miguel I like your photos. i to love travelling but havent put
mine on the web, something i'd like to do. much of mine are still on paper
so a lot of work to do.

Ian

[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

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