RE: Solved [PHP] mysql_fetch_row problem

From: Date: Thu, 23 Jan 2003 15:11:16 +0000
Subject: RE: Solved [PHP] mysql_fetch_row problem
Groups: php.general 
Request: Send a blank email to php-general+get-132839@lists.php.net to get a copy of this message
Thanks all for the responses.. the solution was to add single quotes around the $Location variable. > -----Original Message----- > From: Rick Emery [mailto:remery@emeryloftus.com] > Sent: Thursday, January 23, 2003 10:10 AM > To: Bryan Brannigan; Php List (E-mail) > Subject: Re: [PHP] mysql_fetch_row problem > > > I'm gong to bet that $Location is alpha, not numeric. Therefore: > $result = mysql_query("SELECT contactemail FROM loc WHERE > location=\"$Location\"",$db); > ----- Original Message ----- > From: "Bryan Brannigan" <bbrannigan@HancockLumber.com> > To: "Php List (E-mail)" <php-general@lists.php.net> > Sent: Thursday, January 23, 2003 8:03 AM > Subject: [PHP] mysql_fetch_row problem > > > Can someone tell me what I'm doing wrong with the following > code. What I am > trying to do with this is insert some data from a form into a > database. > Then I am querying another database to retrieve the email > addresses related > to $location. This is the error I get: > > Warning: mysql_fetch_row(): supplied argument is not a valid > MySQL result > resource in D:\inetpub\webroot\usrmgr\upd.php on line 15 > > This is the problematic code: > > > $db = mysql_connect("localhost", "webapp"); > mysql_select_db("usermgr",$db); > $sql = "INSERT INTO usernames > (name,location,position,email,home,citrix,timberline,sawmill,c > ounter,insides > upport,am,receiving,shipping,purchasing,management,approval,un > iqueid) VALUES > > ('$Name','$Location','$Position','$Emailaccess','$workathome', > '$citrix','$ti > > mberline','$sawmill','$countersales','$insidesales','$accountm > anager','$rece > > iving','$shipping','$purchasing','$management','Waiting','$uni > queid')"; > $result = mysql_query($sql); > mysql_close($db); > > > $db = mysql_connect("localhost", "webapp"); > mysql_select_db("helpdesk",$db); > $result = mysql_query("SELECT contactemail FROM loc WHERE > location=$Location",$db); > while($row = mysql_fetch_row($result)){ > $contactemail = $row[0]; > } > > > Thanks in advance, > Bryan > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > "90% of being smart is knowing what you're dumb at." > Bryan Brannigan > Hancock Lumber > System Administrator > Information Technology > (v)207.627.7694 > (f)207.627.7041 > bbrannigan@hancocklumber.com > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#132839) next »