heh, i did it too.
John,
oh, good to know, thanks. $final should be composed of strings, not
integers, so i guess that is his problem. i just read that it is
best to quote every variable, now I know why... so you can change
implementations later and not have to worry about types (and php
Jordan Miller wrote:
you need single quotes around $subnum in the sql statement. don't know
why you seem to be arbitrarily leaving them off (put them around $uv
and $duration, too!).
It's not needed if those fields are integers.
*damnit, that's twice today I've replied to the poster and no
you need single quotes around $subnum in the sql statement. don't
know why you seem to be arbitrarily leaving them off (put them around
$uv and $duration, too!).
also, you should never insert stuff directly from a user into a
database. first escape every variable with:
http://www.php.net/m
> I tried to use the final array values in a insert statement, but the
values are not inserted.
> the code is
>
> foreach ($final as $subnum){
> $res = $db->query("INSERT INTO
substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,u
ltrasonic,duration,cdate,ctime,comment)
>
VA
Hi,
I tried to use the final array values in a insert statement, but the values are
not inserted.
the code is
foreach ($final as $subnum){
$res = $db->query("INSERT INTO
substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,ultrasonic,duration,cdate,ctime,comment)
I think I finally understand what you are trying to do. I don't see
any reason why you need to use the token functions, and I would
recommend using array functions instead (also, it is exceedingly easy
to sort the elements of an array... see the end).
I believe this will do what you are try
$str=10,12,14-18;
$tok = strtok($str, ',');
while ($tok !== false) {
$toks[] = $tok;
$tok = strtok(',');
}
foreach ($toks as $token){
if (strpos($token,'-')){
stringtokenize($token);
}else{
$finaltokens[]= $token;
}
}
function stringtokenize($nstr){
$ntok1= strtok($nstr,'-');
7 matches
Mail list logo