Re: variable interpolation in mysql queries

From: Date: Wed, 27 Feb 2002 00:15:39 +0000
Subject: Re: variable interpolation in mysql queries
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-17320@lists.php.net to get a copy of this message
Cool, I didn't know you could embed mysql_query(...) inside mysql_fetch_row(...). That's kinda nice--I hate having a line each for 1-connecting, 2-selecting, 3-querying, and 4-resulting. I'll hafta try that. Thanks. Ryan On Tue, 26 Feb 2002, Stewart Gateley wrote: > First of all that should throw an error, correct syntax is mysql_result > ($query, 0) meaning to grab the 0 index returned. > > I am not sure about performance wise, however I dislike mysql_result > since if nothing is returned then you get a runtime error. Instead I > like to use > > list($pd) = mysql_fetch_row ( > mysql_query ( > "select password > from users > where login = '$login'" > ) > ); > > Then you can test $pd without getting sql errors. > > -- Stewart > > --- Ryan Snow <snow@cosmic.utah.edu> wrote: > > Hi, Im kinda new to this list. Can anyone tell me what is the proper > > way > > to interpolate my php variables into my mysql queries? > > > > I've been trying $query = "SELECT password FROM users WHERE > > login='$login'"; > > > > > > then: > > mysql_query($result); > > $pd = mysql_result($result); > > > > but I get a message that says: "Supplied Argument is not a valid > > MySQL-Link resource" > > > > any ideas, anyone? > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Greetings - Send FREE e-cards for every occasion! > http://greetings.yahoo.com >

« previous php.db (#17320) next »