hahah thank-you, love the responses here. you guys are awesome..
ps, where does the %s come from?
--------------------------------------------------
From: <majk.sko...@eventim.de>
Sent: Friday, September 04, 2009 9:11 PM
To: <p...@computer.org>; <mysql@lists.mysql.com>
Subject: AW: Re: a better way, code technique?
-----Ursprüngliche Nachricht-----
Von: Per Jessen [mailto:p...@computer.org]
Gesendet: Freitag, 4. September 2009 13:05
An: mysql@lists.mysql.com
Betreff: Re: a better way, code technique?
AndrewJames wrote:
is there a better way (hopefully simpler) to code this?
i want to get the user id of the logged in user to use in my next
statement.
$q1 = sprintf("SELECT uid FROM users WHERE
users.username='$username'");
The only "improvement" I can see is:
$q1 = sprintf("SELECT uid FROM users WHERE users.username='%s'",
$username);
sprintf only adds overhead to this. There is no need to use it here.
You can just use $q = "SELECT ...";
Or if you wanna have it more readable use heredoc style
$q = <<<EOSQL
SELECT
uid
FROM
users
WHERE
username = '{$username}'
EOSQL;
But thats a bit off topic ;)
Majk
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org