Re: syntax of sprintf
| From: | Chris | Date: | Wed, 21 May 2008 00:08:47 +0000 |
| Subject: | Re: syntax of sprintf | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-274585@lists.php.net to get a copy of this message | ||
> the select query is
>
> $selectqueryusername = sprintf("Select username from individuals where
> username='%s'", mysql_real_escape_string($username));
The syntax is fine.
$result = mysql_query($selectqueryusername);
if (!$result) {
echo "Error! *** " . mysql_error();
}
> also for insert query if i have a numeric value i should be writting %d
> correct, i have a numeric value however before inserting that
> numeric value i am appending a character "-" to combine area code and phone
> number example 09-123 4567 so i am considering this as %s as there is a
> character. is this correct.
Yes.
The placeholders are all documented pretty well:
http://www.php.net/sprintf
--
Postgresql & php tutorials
http://www.designmagick.com/