Reply to Re: strange behaviour using arrays to update records

Your name:

Reply:


Posted by Norman Peelman on 08/07/06 10:20

"mantrid" <ian.dandav@virgin.net> wrote in message
news:aNvBg.125538$sz1.84593@newsfe6-gui.ntli.net...
> Hello
> Im having problems working out why the following code does not work. I
dont
> think its the sql as the error occurs on the first update which ever one
is
> put there ($q1 or $q2). Ive swapped then around to test this.
> Help greatly appreciated
>
> The error is Unknown column 'A' in 'field list'
> but there is no field 'A'. im thinking that the 'A' may be first letter of
> the word Array, as if it is using this as a variable, but i dont know how.
>
>
> $commindexarray=$_POST['commindex'];
> $catarray=addslashes($_POST['category']);
> $commarray=addslashes($_POST['comm']);
> $availarray=$_POST['avail'];
> $delarray=$_POST['del'];
>
> if($delarray==''){
> for ($i = 0; $i < count($commindexarray); $i++){
> $currtime=date('YmdHis');
> $q2 ="UPDATE usercomms SET typeid={$catarray[$i]} WHERE userid=
> ".$_SESSION['userid']." AND commindex ={$commindexarray[$i]}";//
> $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={$catarray[$i]},
comment='{$commarray[$i]}',
> available={$availarray[$i]}, timestp='$currtime', globalavail=0 WHERE
> commindex={$commindexarray[$i]}";//
> $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>');
>
> }
> }
>
>

Not to mention that you are intermixing two styles of string
concatination... try:

$q2 ="UPDATE usercomms SET typeid={$catarray[$i]} WHERE
userid={$_SESSION['userid']} AND commindex ={$commindexarray[$i]}";

Norm
--
FREE Avatar hosting at www.easyavatar.com

[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

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