Re: [PHP-DB] Help With Getting Values Please!
mysql_result() is used when you know the row number of the item you want to retrive from your table. mysql_query() is used to get all results from a query, so you can loop thru an array of them or something. Russ On Wed, 23 May 2001 18:47:22 +0200 Johannes Janson <[EMAIL PROTECTED]> wrote: > Hi, > > >$sql2 = "SELECT ServiceDes FROM ServiceTypes WHERE ServiceID = > $serviceid"; > > put single quotes around $serviceid. > > >$service_type = mysql_result($sql2, 1); > > I might be perpetuating the spreading of rumors but I've heard and read > somewhere > that mysql_query() is supposed to be better in the performance. Perhaps > someone > else could clear this point for me thus stopping the rumors. > > Cheers > Johannes > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > #---# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam e: [EMAIL PROTECTED] w: www.apu.ac.uk/webteam t: +44 (0)1223 363271 x 2331 www.theruss.com #---# -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Help With Getting Values Please!
Hi, >$sql2 = "SELECT ServiceDes FROM ServiceTypes WHERE ServiceID = $serviceid"; put single quotes around $serviceid. >$service_type = mysql_result($sql2, 1); I might be perpetuating the spreading of rumors but I've heard and read somewhere that mysql_query() is supposed to be better in the performance. Perhaps someone else could clear this point for me thus stopping the rumors. Cheers Johannes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Help With Getting Values Please!
Greetings. I'm trying to get a value for a single cell out of a table and into a variable. I receive the following error message: Warning: Supplied argument is not a valid MySQL result resource in /home/etc My code (abbreviated) is as follows: $sql2 = "SELECT ServiceDes FROM ServiceTypes WHERE ServiceID = $serviceid"; $service_type = mysql_result($sql2, 1); The value in $serviceid is valid and displays fine. I'm simply trying to retrieve the value of ServiceDes from a different table which also has a column named serviceid, which is unique to the table. I'm very new to PHP, but I do have lots of SQL experience. I'm used to defining variables using indicators (ie. SELECT column INTO varname FROM tablename WHERE), but this didn't seem to work using PHP/MYSQL. Thanks, Dan