var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: for loop sql query headaches
im trying to write code to update some tables in my db. an array is built from exploding a string taken from a textarea. like so....
if(!empty( $formVars [ "PCRRunSample" ]))
$sampstring = rtrim ( $formVars [ "PCRRunSample" ]);
$sampstring = preg_replace ( "/(\r\n)+/" , "\r\n" , $sampstring );
$sampstring = explode ( "\r\n" , $sampstring );
i had it all working for one element in a foreach loop but as i needed to update two ive used a for loop. however when i run the script only the first elements of the array are updated with further iterations only returning zeros. here the loop:
ive hardset the $counter just to make sure that there was nothing wrong when evaluating termination.
if(!empty( $posstring ) && !empty( $sampstring ))
for( $counter = 0 ; $counter < 3 ; $counter ++)
$query = "INSERT INTO PCRPosition SET PCRRun_idPCRRun = $idPCRRun , PCRPositionNum = " . intval ( $posstring [ $counter ]) .
", Sample_idSample = " . intval ( $sampstring [ $counter ]);
if(!(@ mysql_query ( $query , $connection )))
can someone please point out to me whats going wrong? im confused.
Re: for loop sql query headaches
The problem with you code is that you are using inval on an array which is not permitted on array and objects.
For you purpose use this kind of code
"select * from table where tab_id='$var[$counter]'";
This will work instead of using inval.