Re: a little logic...

From: Date: Sun, 18 May 2003 18:03:44 +0000
Subject: Re: a little logic...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148104@lists.php.net to get a copy of this message
On Monday 19 May 2003 01:43, Ryan A wrote: > Hi, > Having a little logic problem here...This is my (original)code: > --------------------------------------------------------------------------- >- --- > $q = "SELECT cno FROM main_co where user='".$user."' and > pass='".$pass."'"; > $r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error()); > > $_SESSION['cno'] = $r; > --------------------------------------------------------------------------- >- --- > > what logic should I use to get/add $company and $site? > (This is what i want to make of it) > eg: > --------------------------------------------------------------------------- >- --- > $q = "SELECT cno,company,site FROM main_co where user='".$user."' and > pass='".$pass."'"; > $r = mysql_result(mysql_query($q),0) or die("Error: " . mysql_error()); > > $_SESSION['cno'] =$r //??? > $_SESSION['company'] = $r // ??? > $_SESSION['site'] = $r; // ??? > --------------------------------------------------------------------------- >- --- > > After reading up in the manual I think $r becomes an array/ or I should > make it an array or somehow use an array...right? I HATE arrays so dont > really know how to use them or even if I need one here...the only arrays I > use are the ones that return a resultset after querying the database. You're using the wrong function. You should be using one of these: mysql_fetch_array(), mysql_fetch_assoc(), mysql_fetch_object(), mysql_fetch_row(). In this particular you probably want to use mysql_fetch_assoc(), look it up in the manual and follow the example. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Can you MAIL a BEAN CAKE? */

« previous php.general (#148104) next »