[imp] Re: 10. Gettting From address from sql db (Gennaro) imp Digest, Vol 261, Issue 1

Mike Cochrane mike at graftonhall.co.nz
Fri Jan 3 01:51:50 PST 2003


> ----- Message from gennaro at snet.net ---------
> 
> I have narrowed my problem down to the $sql line
> I have tried the line multiple ways but still problems exsist.
> $sql = "select address from users where id = \"$imp['user']\"";
> $sql = "select address from users where id = \'$imp['user']\'";
> $sql = "select address from users where id = $imp['user']";
> $sql = "select address from users where id = "$imp['user']"";
> $sql = "select address from users where id = '$imp['user']'";
> 

I asume you're trying to put the value if $imp['user'] into the string so:
$sql = "select address from users where id = " . $imp['user'];
would do that. 

But it should be quoted so assumeing $db is your PEAR_DB opbject.
$sql = "select address from users where id = " . $db->quote($imp['user']);

- Mike :-)



More information about the imp mailing list