[PHP] Re: Supplied argument is not a valid MySQL result

2001-11-15 Thread Richard Lynch

Dan McCullough wrote:

 Warning: Supplied argument is not a valid MySQL result resource in
 /home/sites/projects.heathermccullough.com/web/copeland/product.php on
 line 61
 
 Here is the code, I fixed it once, and I cant figure out why it keeps
 returning.
 
 if ($submit) {
 $sql = (SELECT * FROM store WHERE state = '$State' AND groups =
 '$group_id');

The ()s here are kinda silly...  They tell PHP to evaluate the string 
before anything else in the expression, and there ain't anything else in 
the expression...

It's like saying:

$foo = (2 + 3);

Doesn't hurt anything, but you look a bit silly...

 $result = mysql_query($sql);

Add some code to the end of this line.

At a minimum, use ... or die(mysql_error());

That's actually not so good on a production server, as it will present icky 
error messages to end users, some of whom might be hackers who then know 
more than they should about the internal working of your 
page/database/site...

So, better is:
... or error_log(__FILE__ . ' ' . __LINE__ . ': ' . mysql_error());

only now you'll have to do the following in a shell prompt:

tail /usr/local/apache/logs/error_log

to see your error message.

 if(mysql_num_rows($result)  0) {   - line 61
 while ($stores = mysql_fetch_array($result) ) {
 $store_name .= .$stores[name]. br .$stores[address]. br
 .$stores[city]., .$stores[state].
 .$stores[zip].br.$stores[phone]. brbr ; }
 } else {
 $store_name .= Copeland Furniture Company StorebrMain
 StreetbrBradford, Vermont 05033br802-222-5300bra
 href=\http://www.copelandfurniture.com/companystore\;
 target=\new\Copeland Furniture Company Store/a; 
}
 MYSQL_CLOSE();

-- 
Like music?  http://l-i-e.com/artists.htm


-- 
PHP General 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] Re: Supplied argument is not a valid MySQL result

2001-11-15 Thread Dan McCullough

Got it to work.  I had made a change that deleted something, not sure what, but when I 
went back a
revision it worked, and I just added back in the html that I needed to use, but I was 
more
careful.
--- Richard Lynch [EMAIL PROTECTED] wrote:
 Dan McCullough wrote:
 
  Warning: Supplied argument is not a valid MySQL result resource in
  /home/sites/projects.heathermccullough.com/web/copeland/product.php on
  line 61
  
  Here is the code, I fixed it once, and I cant figure out why it keeps
  returning.
  
  if ($submit) {
  $sql = (SELECT * FROM store WHERE state = '$State' AND groups =
  '$group_id');
 
 The ()s here are kinda silly...  They tell PHP to evaluate the string 
 before anything else in the expression, and there ain't anything else in 
 the expression...
 
 It's like saying:
 
 $foo = (2 + 3);
 
 Doesn't hurt anything, but you look a bit silly...
 
  $result = mysql_query($sql);
 
 Add some code to the end of this line.
 
 At a minimum, use ... or die(mysql_error());
 
 That's actually not so good on a production server, as it will present icky 
 error messages to end users, some of whom might be hackers who then know 
 more than they should about the internal working of your 
 page/database/site...
 
 So, better is:
 ... or error_log(__FILE__ . ' ' . __LINE__ . ': ' . mysql_error());
 
 only now you'll have to do the following in a shell prompt:
 
 tail /usr/local/apache/logs/error_log
 
 to see your error message.
 
  if(mysql_num_rows($result)  0) {   - line 61
  while ($stores = mysql_fetch_array($result) ) {
  $store_name .= .$stores[name]. br .$stores[address]. br
  .$stores[city]., .$stores[state].
  .$stores[zip].br.$stores[phone]. brbr ; }
  } else {
  $store_name .= Copeland Furniture Company StorebrMain
  StreetbrBradford, Vermont 05033br802-222-5300bra
  href=\http://www.copelandfurniture.com/companystore\;
  target=\new\Copeland Furniture Company Store/a; 
 }
  MYSQL_CLOSE();
 
 -- 
 Like music?  http://l-i-e.com/artists.htm
 
 
 -- 
 PHP General 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]
 


=
Dan McCullough
---
Theres no such thing as a problem unless the servers are on fire!
h: 603.444.9808
w: McCullough Family
w: At Work

__
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com

-- 
PHP General 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]