if ($numrows  =  0) {

should be

if ($numrows  ==  0) {

comparison, rather than assignment.

- Stephen

On 8/5/05, Galatek Webmaster <[EMAIL PROTECTED]> wrote:
> Hello all ( at least I hope it is getting somewhere, my last few emails
> disappeared)
>  Got an irritating little problem that is starting to drive me up the
> wall, I am making an online catalogue for a client
> using PHP and MySQL to populate the pages. I want the code to check to
> see if any rows were returned by the query
> and, if not, display a message saying that the category is emtp.. easy
> right? just simple case of using mysql_num_rows() on the
> query result string and whalah.. but it is being stubborn.
> mysql_num_rows is returning a blank string instead of 0 or the number
> of rows actually there. Heres a snippet of the code
> 
> <snippet begins>
> $sql = sprintf("SELECT * FROM CatalogueItems WHERE
> fldcategory=`%s`",$category);
> $result = mysql_query($sql);
> if (!$result) { die("Database Connection Error, Contact the site
> administrator"); }
> $numrows = mysql_num_rows($result);
> if ($numrows  =  0) {
>     echo '<center><font color="red" style="font-weight: bolder">No items
> exist for this category</font><br>
>              <br><a href="./index.php" class="itemlist">Back to home
> page</a></center>';
> } else {
>     .// fetch results arrays and create dynamic page
>     .
>     .
>     .
> }
> 
> </snippet>
> 
> One category is empty and another has 6 rows, but when doing this code
> on either of the categories, mysq_num_rows returns " " instead of an int
> value, so nothign whatsoever is displayed. if I use ($numrows == 0) then
> it displays the warning text saying nothing is in the category, if I use
> ($numrows < 1) it displays nothing whatsoever. I have tried debugging by
> putting dynamic comments in the code, but the value output by
> mysql_num_rows is always a blank space.
> 
> Any help on this before i go completely nuts is appreciated much in advance.
> 
> Charles R King
> Galatek Webmaster
> 
> 
> ____ • The WDVL Discussion List from WDVL.COM • ____
> To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
> use the web interface http://e-newsletters.internet.com/discussionlists.html/
>        Send Your Posts To: [email protected]
> To change subscription settings, add a password or view the web interface:
> http://intm-dl.sparklist.com/read/?forum=wdvltalk
> 
> ________________  http://www.wdvl.com  _______________________
> 
> You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to [EMAIL PROTECTED]
> To unsubscribe via postal mail, please contact us at:
> Jupitermedia Corp.
> Attn: Discussion List Management
> 475 Park Avenue South
> New York, NY 10016
> 
> Please include the email address which you have been contacted with.
>

____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
use the web interface http://e-newsletters.internet.com/discussionlists.html/
       Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk

________________  http://www.wdvl.com  _______________________

You are currently subscribed to $subst('List.Name') as: 
$subst('Recip.EmailAddr')
To unsubscribe send a blank email to $subst('Email.UnSub')
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.

Reply via email to