Stop a User warning message

2003-09-15 Thread Tom Sparks
I am doing a mysql_num_rows after a SELECT statement and am getting
the following warning message:
Warning: Supplied argument is not a valid MySQL result resource in {pathname to 
program} on line 40

Line 40 -  $result = mysql_num_rows($res); 
The SELECT statement:
$res = mysql_query(SELECT * FROM company WHERE $category='yes',$db);
($category is passed to this program from an input form.)

Is there a way to stop this warning to the user when $category = 'no' for all records?

-tom

Re: Stop a User warning message

2003-09-15 Thread Paul DuBois
At 11:06 AM -0700 9/15/03, Tom Sparks wrote:
I am doing a mysql_num_rows after a SELECT statement and am getting
the following warning message:
Warning: Supplied argument is not a valid MySQL result resource in 
{pathname to program} on line 40

Line 40 -  $result = mysql_num_rows($res);
The SELECT statement:
$res = mysql_query(SELECT * FROM company WHERE $category='yes',$db);
($category is passed to this program from an input form.)
Is there a way to stop this warning to the user when $category = 
'no' for all records?
It indicates an error in your program.  You have no error checking
on the result of the mysql_query() call, I take it?

-tom


--
Paul DuBois, Senior Technical Writer
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Are you MySQL certified?  http://www.mysql.com/certification/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: Stop a User warning message

2003-09-15 Thread Tom Sparks
Paul,

It is not an error for $category to be 'no' in all records.  The warning
is just telling me that it didn't find any 'yes' records. 

I need to read up and find out how to error check the SELECT statement,
I guess...


-tom

Re: Stop a User warning message

2003-09-15 Thread Paul DuBois
Paul,

It is not an error for $category to be 'no' in all records.  The warning
is just telling me that it didn't find any 'yes' records.
Well, no, it is not.  The error you showed was:

Warning: Supplied argument is not a valid MySQL result resource in 
{pathname to program} on line 40

PHP is telling you that $res does not refer to a valid result set.
That means your query *failed with an error*, not that
it executed properly and returned no records.
I need to read up and find out how to error check the SELECT statement,
I guess...
Yes.  Try this, for example:

if (!$res)
die (query failed, error message is:  . mysql_error ());


-tom


--
Paul DuBois, Senior Technical Writer
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Are you MySQL certified?  http://www.mysql.com/certification/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: Stop a User warning message

2003-09-15 Thread Kelley Lingerfelt
Yep, you're right Paul, it is a bad query, one thing I've been burnt on a lot

in the past, is using the variables inside those double quoted lines. I've
started expanding everything, mostly objects and arrays won't get interpreted

correctly,  try building the query in a string, and then printing out the
string to the screen and see if it looks right, and then execute that mysql
command from the mysql command line, and see if it flies, bet it won't.

KL

PS: Sorry about sending you that last message Paul, I'm still not used to the
reply all, and I just use that all too easy reply button :(



Paul DuBois wrote:

 Paul,
 
 It is not an error for $category to be 'no' in all records.  The warning
 is just telling me that it didn't find any 'yes' records.

 Well, no, it is not.  The error you showed was:

 Warning: Supplied argument is not a valid MySQL result resource in
 {pathname to program} on line 40

 PHP is telling you that $res does not refer to a valid result set.
 That means your query *failed with an error*, not that
 it executed properly and returned no records.

 
 I need to read up and find out how to error check the SELECT statement,
 I guess...

 Yes.  Try this, for example:

 if (!$res)
  die (query failed, error message is:  . mysql_error ());

 
 
 -tom

 --
 Paul DuBois, Senior Technical Writer
 Madison, Wisconsin, USA
 MySQL AB, www.mysql.com

 Are you MySQL certified?  http://www.mysql.com/certification/

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]