Re: [PHP] mysql_num_rows()
At 12:40 AM -0500 2/22/11, Gary wrote: Can someone tell me why this is not working? I do not get an error message, the results are called and echo'd to screen, the count does not work, I get a 0 for a result... $result = mysql_query("SELECT * FROM `counties` WHERE name = 'checked'") or die(mysql_error()); if ( isset($_POST['submit']) ) { for($i=1; $i<=$_POST['counties']; $i++) { if ( isset($_POST["county$i"] ) ) { echo "You have chosen ". $_POST["county$i"]." "; } } } $county_total=mysql_num_rows($result); while($row = mysql_fetch_array($result)) {$i++; echo $row['name']; } $county_total=mysql_num_rows($result); echo "$county_total"; echo 'You Have ' . "$county_total" . ' Counties '; ?> Gary: With regard of the count thing, why not let MySQL do the work? $query = "SELECT COUNT(*) AS total FROM 'counties' WHERE name = 'checked' "; $result = mysql_query($query) or die(mysql_error()); $total = $rowcount['total']; Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows()
"Daniel Molina Wegener" wrote in message news:201102220747.11...@coder.cl... > On Tuesday 22 February 2011, > "Gary" wrote: > >> Can someone tell me why this is not working? I do not get an error >> message, the results are called and echo'd to screen, the count does not >> work, I get a 0 for a result... > > Are you sure that the table is called `counties` and not `countries`? > > :) > >> >> >> >> $result = mysql_query("SELECT * FROM `counties` WHERE name = 'checked'") >> or die(mysql_error()); >> >> if ( isset($_POST['submit']) ) { >> for($i=1; $i<=$_POST['counties']; $i++) { >> if ( isset($_POST["county$i"] ) ) { >> echo "You have chosen ". $_POST["county$i"]." "; >> } >> } >> } >> >> $county_total=mysql_num_rows($result); >> >> while($row = mysql_fetch_array($result)) >> {$i++; >> echo $row['name']; >> } >> $county_total=mysql_num_rows($result); >> echo "$county_total"; >> >> echo 'You Have ' . "$county_total" . ' Counties '; >> >> ?> > > Best regards, > -- > Daniel Molina Wegener > System Programmer & Web Developer > Phone: +56 (2) 979-0277 | Blog: http://coder.cl/ Daniel Thank you for your reply, yes the database is named counties, working and returning results. Gary __ Information from ESET Smart Security, version of virus signature database 5895 (20110222) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows()
Thanks for your reply "Deva" wrote in message news:aanlktimvycqsi5nejd1lxxaqbqsb+q_onhoc7omgj...@mail.gmail.com... >I tried your script locally. Its working for me. > > On Tue, Feb 22, 2011 at 11:10 AM, Gary wrote: > >> Can someone tell me why this is not working? I do not get an error >> message, >> the results are called and echo'd to screen, the count does not work, I >> get >> a 0 for a result... >> >> >> >> $result = mysql_query("SELECT * FROM `counties` WHERE name = 'checked'") >> or >> die(mysql_error()); >> >> if ( isset($_POST['submit']) ) { >> for($i=1; $i<=$_POST['counties']; $i++) { >> if ( isset($_POST["county$i"] ) ) { >> echo "You have chosen ". $_POST["county$i"]." "; >>} >>} >> } >> >> $county_total=mysql_num_rows($result); >> >> while($row = mysql_fetch_array($result)) >> {$i++; >>echo $row['name']; >> } >> $county_total=mysql_num_rows($result); >> echo "$county_total"; >> >> echo 'You Have ' . "$county_total" . ' Counties '; >> >> ?> >> -- >> Gary Thanks for your reply. I'm curious, how did you try it locally without a database? I am still getting either a 0 or a 1 for a result. Gary __ Information from ESET Smart Security, version of virus signature database 5895 (20110222) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows()
Hello Gary, Please wrap $i in braces in your variable variable: if ( isset($_POST["county{$i}"] ) ) { echo "You have chosen ". $_POST["county{$i}"]." "; -- With best regards from Ukraine, Andre Skype: Francophile My blog: http://oire.org/menelion (mostly in Russian) Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion Original message From: Gary To: php-general@lists.php.net Date created: , 7:40:48 AM Subject: [PHP] mysql_num_rows() Can someone tell me why this is not working? I do not get an error message, the results are called and echo'd to screen, the count does not work, I get a 0 for a result... $result = mysql_query("SELECT * FROM `counties` WHERE name = 'checked'") or die(mysql_error()); if ( isset($_POST['submit']) ) { for($i=1; $i<=$_POST['counties']; $i++) { if ( isset($_POST["county$i"] ) ) { echo "You have chosen ". $_POST["county$i"]." "; } } } $county_total=mysql_num_rows($result); while($row = mysql_fetch_array($result)) {$i++; echo $row['name']; } $county_total=mysql_num_rows($result); echo "$county_total"; echo 'You Have ' . "$county_total" . ' Counties '; ?> -- Gary __ Information from ESET Smart Security, version of virus signature database 5894 (20110221) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows()
On Tuesday 22 February 2011, "Gary" wrote: > Can someone tell me why this is not working? I do not get an error > message, the results are called and echo'd to screen, the count does not > work, I get a 0 for a result... Are you sure that the table is called `counties` and not `countries`? :) > > > > $result = mysql_query("SELECT * FROM `counties` WHERE name = 'checked'") > or die(mysql_error()); > > if ( isset($_POST['submit']) ) { > for($i=1; $i<=$_POST['counties']; $i++) { > if ( isset($_POST["county$i"] ) ) { > echo "You have chosen ". $_POST["county$i"]." "; > } > } > } > > $county_total=mysql_num_rows($result); > > while($row = mysql_fetch_array($result)) > {$i++; > echo $row['name']; > } > $county_total=mysql_num_rows($result); > echo "$county_total"; > > echo 'You Have ' . "$county_total" . ' Counties '; > > ?> Best regards, -- Daniel Molina Wegener System Programmer & Web Developer Phone: +56 (2) 979-0277 | Blog: http://coder.cl/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows()
I tried your script locally. Its working for me. On Tue, Feb 22, 2011 at 11:10 AM, Gary wrote: > Can someone tell me why this is not working? I do not get an error > message, > the results are called and echo'd to screen, the count does not work, I get > a 0 for a result... > > > > $result = mysql_query("SELECT * FROM `counties` WHERE name = 'checked'") or > die(mysql_error()); > > if ( isset($_POST['submit']) ) { > for($i=1; $i<=$_POST['counties']; $i++) { > if ( isset($_POST["county$i"] ) ) { > echo "You have chosen ". $_POST["county$i"]." "; >} >} > } > > $county_total=mysql_num_rows($result); > > while($row = mysql_fetch_array($result)) > {$i++; >echo $row['name']; > } > $county_total=mysql_num_rows($result); > echo "$county_total"; > > echo 'You Have ' . "$county_total" . ' Counties '; > > ?> > -- > Gary > > > > __ Information from ESET Smart Security, version of virus signature > database 5894 (20110221) __ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- :DJ
Re: [PHP] mysql_num_rows
INSERT queries and num_rows just don't go together. And whatever you've done with mysql_affected_rows() is just some kind of silly mistake on your part, almost for sure... On Tue, May 30, 2006 11:28 pm, John Taylor-Johnston wrote: > How can I get an integer value for mysql_affected_rows()? I get text: > > " n Database Transfer(s)". > > I would like to create my own error flag and exit; if the number of > affected rows is <= 0. > > The example for mysql-num-rows in the manual does not work. I have > MySQL > - 4.1.12. > > $num_rows = mysql_num_rows($result); > echo "$num_rows Rows\n"; > > http://ca3.php.net/manual/en/function.mysql-num-rows.php > > I get: > Warning: mysql_num_rows(): supplied argument is not a valid MySQL > result > resource in /var/www/html2/db/tools/test.php on line 29 > Rows Database Transfer > > Here is my code. > > > > $sql ="insert into `jtjohnston`.`ccl` > (RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,TUS,GEO,AN,RB,SA,CO,RR) > > select > RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,TUS,GEO,AN,RB,SA, > CONCAT(`CO`,' ;'),RR > FROM ".$_POST["dbtable"]." > WHERE id=".$_POST["transferthis"].";"; > > echo "".htmlspecialchars($sql)."\n"; > > $myconnection = mysql_connect($server,$user,$pass); > mysql_select_db($db,$myconnection); > > $result = mysql_query($sql) or die(print mysql_error()); > > echo mysql_affected_rows(); > #$num_rows = mysql_num_rows($result); > #echo "$num_rows Rows\n"; > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows()
On Tuesday 28 September 2004 03:15, PHP Junkie wrote: > In one of my scripts, I'm getting the error: Use mysql_error() after every call to the mysql_*() functions. -- 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 -- /* The last person that quit or was fired will be held responsible for everything that goes wrong -- until the next person quits or is fired. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows()
[snip] In one of my scripts, I'm getting the error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /Library/WebServer/Documents/limiteduse.net/dumptoday.php on line 56 I¹m not clearly sure why. I¹m running PHP5 with mySQL 4 ... Is there a compatibility issues somewhere? [/snip] If we could see the code we probably could tell you a little more. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows()
Generally you've got an error in your SQL at such points. If you do, mysql_query return false, and false is nor a valid MySQL result, so mysql_num_rows errors out. Check using mysql_error() to see what you're doing wrong Php Junkie wrote: Ave, In one of my scripts, I'm getting the error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /Library/WebServer/Documents/limiteduse.net/dumptoday.php on line 56 I¹m not clearly sure why. I¹m running PHP5 with mySQL 4 ... Is there a compatibility issues somewhere? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
John Taylor-Johnston wrote: My question got buried on the bottom of the thread. Sorry for the repeat. I'm getting this message: Warning: Supplied argument is not a valid MySQL result resource in /.../testals.php on line 189 Read with me. Supplied argument ($news) is not a valid MySQL result resource. 189> if (mysql_num_rows($news) == 1) Ideas? $server = "localhost"; $user = ""; $pass = ""; $db = "redwards"; $table = "testals"; $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $news = mysql_query("select StudentId from $table where StudentID = $StudentID"); $news is not valid, therefore your query failed. Use mysql_error() to find out why. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
Uh. no that can't be right becuase mysql_query() returns a pointer not an array. The variable does contain a string refering to the pointer ID but that's about all the information you're going to disseminate from print_r(); -- Kevin - Original Message - From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> To: "Mike Tuller" <[EMAIL PROTECTED]>; "J J" <[EMAIL PROTECTED]> Cc: "php mailing list list" <[EMAIL PROTECTED]> Sent: Friday, April 04, 2003 4:18 PM Subject: Re: [PHP] mysql_num_rows > Someone helped me out with this to see exactly what the query is > returning... > > echo " the Query: "; print_r ($select_result); echo ""; > > This should show you exactly what the result is getting... > > /T > > on 4/4/03 4:49 PM, Mike Tuller at [EMAIL PROTECTED] wrote: > > > I can't believe I forgot that. time to go home for the week. > > > > thanks. > > > > On Friday, April 4, 2003, at 04:28 PM, J J wrote: > > > >> oh and your SQL statement is wrong: > >> > >> SELECT * FROM table WHERE you are missing the > >> FROM... > >> > >> > >> > >> --- Mike Tuller <[EMAIL PROTECTED]> wrote: > >>> I can't get mysql_num_rows to work for some reason. > >>> Here is a snippet > >>> of what I have > >>> > >>> > >>> $department_name = $_POST['department_name']; > >>> > >>> $select_query = "SELECT * WHERE department_name = > >>> '$department_name'"; > >>> $select_result = mysql_query($select_query, > >>> $db_connect); > >>> $select_total_rows = mysql_num_rows($select_result); > >>> > >>> if ($select_total_rows<1) > >>> { > >>> $insert_query = " insert into departments > >>> (department_name) > >>> values > >>> ('$department_name')"; > >>> > >>> mysql_query($insert_query, $db_connect) or die > >>> (mysql_error()); > >>> > >>> > >>> I am getting back an error mysql_num_rows(): > >>> supplied argument is not a > >>> valid MySQL result resource. I have looked over it > >>> again and again, and > >>> can't see what is wrong. Can anyone else see where > >>> the problem might be? > >>> > >>> Mike > >>> > >>> > >>> -- > >>> PHP General Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >> > >> > >> __ > >> Do you Yahoo!? > >> Yahoo! Tax Center - File online, calculators, forms, and more > >> http://tax.yahoo.com > >> > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
Someone helped me out with this to see exactly what the query is returning... echo " the Query: "; print_r ($select_result); echo ""; This should show you exactly what the result is getting... /T on 4/4/03 4:49 PM, Mike Tuller at [EMAIL PROTECTED] wrote: > I can't believe I forgot that. time to go home for the week. > > thanks. > > On Friday, April 4, 2003, at 04:28 PM, J J wrote: > >> oh and your SQL statement is wrong: >> >> SELECT * FROM table WHERE you are missing the >> FROM... >> >> >> >> --- Mike Tuller <[EMAIL PROTECTED]> wrote: >>> I can't get mysql_num_rows to work for some reason. >>> Here is a snippet >>> of what I have >>> >>> >>> $department_name = $_POST['department_name']; >>> >>> $select_query = "SELECT * WHERE department_name = >>> '$department_name'"; >>> $select_result = mysql_query($select_query, >>> $db_connect); >>> $select_total_rows = mysql_num_rows($select_result); >>> >>> if ($select_total_rows<1) >>> { >>> $insert_query = " insert into departments >>> (department_name) >>> values >>> ('$department_name')"; >>> >>> mysql_query($insert_query, $db_connect) or die >>> (mysql_error()); >>> >>> >>> I am getting back an error mysql_num_rows(): >>> supplied argument is not a >>> valid MySQL result resource. I have looked over it >>> again and again, and >>> can't see what is wrong. Can anyone else see where >>> the problem might be? >>> >>> Mike >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> >> __ >> Do you Yahoo!? >> Yahoo! Tax Center - File online, calculators, forms, and more >> http://tax.yahoo.com >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
I can't believe I forgot that. time to go home for the week. thanks. On Friday, April 4, 2003, at 04:28 PM, J J wrote: oh and your SQL statement is wrong: SELECT * FROM table WHERE you are missing the FROM... --- Mike Tuller <[EMAIL PROTECTED]> wrote: I can't get mysql_num_rows to work for some reason. Here is a snippet of what I have $department_name = $_POST['department_name']; $select_query = "SELECT * WHERE department_name = '$department_name'"; $select_result = mysql_query($select_query, $db_connect); $select_total_rows = mysql_num_rows($select_result); if ($select_total_rows<1) { $insert_query = " insert into departments (department_name) values ('$department_name')"; mysql_query($insert_query, $db_connect) or die (mysql_error()); I am getting back an error mysql_num_rows(): supplied argument is not a valid MySQL result resource. I have looked over it again and again, and can't see what is wrong. Can anyone else see where the problem might be? Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows
> $department_name = $_POST['department_name']; > > $select_query = "SELECT * WHERE department_name = '$department_name'"; > $select_result = mysql_query($select_query, $db_connect); > $select_total_rows = mysql_num_rows($select_result); > > if ($select_total_rows<1) > { > $insert_query = " insert into departments (department_name) > values > > ('$department_name')"; > > mysql_query($insert_query, $db_connect) or die (mysql_error()); > > > I am getting back an error mysql_num_rows(): supplied argument is not a > valid MySQL result resource. I have looked over it again and again, and > can't see what is wrong. Can anyone else see where the problem might be? That means your query failed, generally. Check for mysql_error() after you run your query to see what went wrong. For example in your SQL, you're missing the "FROM table" portion of your query... oops! ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
oh and your SQL statement is wrong: SELECT * FROM table WHERE you are missing the FROM... --- Mike Tuller <[EMAIL PROTECTED]> wrote: > I can't get mysql_num_rows to work for some reason. > Here is a snippet > of what I have > > > $department_name = $_POST['department_name']; > > $select_query = "SELECT * WHERE department_name = > '$department_name'"; > $select_result = mysql_query($select_query, > $db_connect); > $select_total_rows = mysql_num_rows($select_result); > > if ($select_total_rows<1) > { > $insert_query = " insert into departments > (department_name) > > values > > ('$department_name')"; > > > mysql_query($insert_query, $db_connect) or die > (mysql_error()); > > > I am getting back an error mysql_num_rows(): > supplied argument is not a > valid MySQL result resource. I have looked over it > again and again, and > can't see what is wrong. Can anyone else see where > the problem might be? > > Mike > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
Try: ($select_total_rows == 0) instead. That and maybe echo $select_total_rows; to see what it's returning. --- Mike Tuller <[EMAIL PROTECTED]> wrote: > I can't get mysql_num_rows to work for some reason. > Here is a snippet > of what I have > > > $department_name = $_POST['department_name']; > > $select_query = "SELECT * WHERE department_name = > '$department_name'"; > $select_result = mysql_query($select_query, > $db_connect); > $select_total_rows = mysql_num_rows($select_result); > > if ($select_total_rows<1) > { > $insert_query = " insert into departments > (department_name) > > values > > ('$department_name')"; > > > mysql_query($insert_query, $db_connect) or die > (mysql_error()); > __ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows() error
And which database are you using?? (hint - mysql_select_db() might be a good idea ...) > -Original Message- > From: Phil Powell [mailto:[EMAIL PROTECTED]] > > Anyone know why this is happening? I have mySQL on Win2000 > Server with IIS > > and PHP: >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows() error
Are you actually checking that the query result is valid? $conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not connect to db'); $result = mysql_query('select * from blah', $conn); if ($result) { echo "Number of rows: " . mysql_num_rows($result); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_row($result)) { for ($i = 0; $i < sizeOf($row); $i++) { echo "$i: " . $row[$i] . ""; } } } } else { echo mysql_error($conn); } -Original Message- From: Phil Powell [mailto:[EMAIL PROTECTED]] Sent: Friday, 10 January 2003 1:46 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: [PHP] mysql_num_rows() error > Anyone know why this is happening? I have mySQL on Win2000 Server with IIS > and PHP: > > mysql_num_rows(): supplied argument is not a valid MySQL result resource > > Here is my code: > >$conn = mysql_connect('localhost', "xxx", "yyy") or die('Could not connect > to db'); > $result = mysql_query('select * from blah'); > echo "Number of rows: " . mysql_num_rows($result); > if (mysql_num_rows($result) > 0) { >while ($row = mysql_fetch_row($result)) { > for ($i = 0; $i < sizeOf($row); $i++) { > echo "$i: " . $row[$i] . ""; > } >} > } > ?> > > It couldn't get any simpler. I just installed mySQL on my machine and am > trying to see what I can do with it giving Win2K and IIS. > > AUGH! Thanx > Phil > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows() error
You query is incorrect. Try doing the same query from the MySQL clent. |-> -Original Message- |-> From: Phil Powell [mailto:[EMAIL PROTECTED]] |-> Sent: Thursday, January 09, 2003 7:46 PM |-> To: [EMAIL PROTECTED]; [EMAIL PROTECTED] |-> Subject: [PHP] mysql_num_rows() error |-> |-> |-> > Anyone know why this is happening? I have mySQL on |-> Win2000 Server with |-> > IIS and PHP: |-> > |-> > mysql_num_rows(): supplied argument is not a valid MySQL result |-> > resource |-> > |-> > Here is my code: |-> > |-> > > $conn = mysql_connect('localhost', "xxx", "yyy") or |-> die('Could not |-> connect |-> > to db'); |-> > $result = mysql_query('select * from blah'); |-> > echo "Number of rows: " . mysql_num_rows($result); |-> > if (mysql_num_rows($result) > 0) { |-> >while ($row = mysql_fetch_row($result)) { |-> > for ($i = 0; $i < sizeOf($row); $i++) { |-> > echo "$i: " . $row[$i] . ""; |-> > } |-> >} |-> > } |-> > ?> |-> > |-> > It couldn't get any simpler. I just installed mySQL on |-> my machine and |-> > am trying to see what I can do with it giving Win2K and IIS. |-> > |-> > AUGH! Thanx |-> > Phil |-> > |-> |-> |-> -- |-> PHP General Mailing List (http://www.php.net/) |-> To unsubscribe, visit: http://www.php.net/unsub.php |-> |-> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
> Would someone be kind enough to explain why I'm not getting the correct > result from the following query. If I select a valid member no. and name, > the following query should return 1 row. This is not the case, however. It > returns zero rows. > > $sql = "SELECT * FROM users WHERE member_no = '$member_no' and > name = ' $name' "; Because ' $name' != '$name' so zero rows are returned. So remove the leading space from your query and you'll get one row.. > $result = mysql_query($sql) or die ("Cannot verify the member"); > $rows = mysql_num_rows($result); > echo "rows = $rows"; > > Furthermore when trying the following query where the table "users" contains > 13 rows, the query returns only 12 rows. > > $sql = "SELECT * FROM users"; > $result = mysql_query($sql) or die ("Cannot verify the member"); > $rows = mysql_num_rows($result); > echo "rows = $rows"; Because there are 12 rows, not 13 ;) Check again or simply test it: $sql = "SELECT * FROM users"; if (!$result = mysql_query($sql)) { echo "Could not run query ($sql) " . mysql_error(); exit; } $count = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)) { $rows[] = $row; } print ""; print "Returned: " . count($rows) . " and num_rows: $count\n"; print_r($rows); > Conclusion: mysql_num_rows seems to be returning one less row > than exists. Is this correct? Nope. Regards, Philip Olson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
add echo mysql_error(); after line 39, it should tell you why the query failed in the future. Now I can tell you you have a typo: "slecet" => "select" empty wrote: Hi guys; I have a problem (or mistake(s)); for this code 39| $result=mysql_query("slecet * from site_members where User_Name='$username'"); 40| $num_row=mysql_num_rows($result); 41| if($num_row>0) echo("error 46"); as a reult I have unsolved error in my hands :( Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\sites\inc\register.inc on line 40 NOTE: all the fields on the db are empty anybody knows why? (PHP 4.2.3 SAPI - MySql 3.23.53 - IIS 5.0 running on WinXP) thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
Hi, > 39| $result=mysql_query("slecet * from site_members where > User_Name='$username'"); 40| $num_row=mysql_num_rows($result); > 41| if($num_row>0) echo("error 46"); There is an typo-error in the word "slecet" which shoud look like "select" :-) -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows
I suppose it's nothing to do with the spelling mistake in the sql statement (slecet should be select) Mark -Original Message- From: empty [mailto:[EMAIL PROTECTED]] Sent: 21 November 2002 15:57 To: [EMAIL PROTECTED] Subject: [PHP] mysql_num_rows Hi guys; I have a problem (or mistake(s)); for this code 39| $result=mysql_query("slecet * from site_members where User_Name='$username'"); 40| $num_row=mysql_num_rows($result); 41| if($num_row>0) echo("error 46"); as a reult I have unsolved error in my hands :( Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\sites\inc\register.inc on line 40 NOTE: all the fields on the db are empty anybody knows why? (PHP 4.2.3 SAPI - MySql 3.23.53 - IIS 5.0 running on WinXP) thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows
Your query on the previous line is failing for one reason or another. You can use mysql_error() to get the error message from MySQL, or you can place an echo statement in your code to make sure the SQL statement is what you think it is. You can also try the SQL statement yourself interactively at a MySQL prompt. Chris --- empty <[EMAIL PROTECTED]> wrote: > I have a problem (or mistake(s)); > > for this code > > 39| $result=mysql_query("slecet * from site_members where >User_Name='$username'"); > 40| $num_row=mysql_num_rows($result); > 41| if($num_row>0) echo("error 46"); > > as a reult I have unsolved error in my hands :( > > Warning: mysql_num_rows(): supplied argument is not a valid MySQL > result resource in D:\sites\inc\register.inc on line 40 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows error
Well, those error normaly appear when you've got something wrong in your sql statement. Make sure there is some information stored in your database, empty tables are sometimes troublesome. What do you use $link for? $sql = "select USUARIO from docente where USUARIO = '$usuario'"; $result = mysql_query($sql, $link); if (mysql_num_rows($result) == 1) Bye *** Wilmar Pérez Network Administrator Library System Tel: ++57(4)2105145 University of Antioquia Medellín - Colombia 2002 *** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows error
Omar Campos wrote: > I get the next warning: > Warning: mysql_num_rows(): supplied argument is not a valid MySQL result > resource in /home/olimpiad/public_html/base/alta1.php on line 34 This usually means that the SQL query failed. You can check the value returned by mysql_query to see if this is the case - it will be FALSE if it failed. In this case my guess would be that the backticks are not valid string delimeters. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows error
Hi Nick, > I am new to php and that the folowing error: > Warning: mysql_num_rows(): supplied argument > is not a valid MySQL result resource in > /home/tbonestu/public_html/smallimages.php > > i dont know what i am doing wrong here is the code: > > @ $db = mysql_pconnect(connect info); Along with the other suggestions to check your $query variable, you should change this line to : $db = @mysql_pconnect($whatever); The @ goes in front of the function call, not the variable, if you want to suppress any potential error messages generated by the function. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows error
>> I am new to php and that the folowing error: Warning: mysql_num_rows(): >> supplied argument is not a valid MySQL result resource in >> /home/tbonestu/public_html/smallimages.php >> >> i dont know what i am doing wrong here is the code: >> >> @ $db = mysql_pconnect(connect info); >> >> mysql_select_db("images"); >> $query = "select * from images where type =".$type.""; $result = >> mysql_query($query); $num_results = mysql_num_rows($result); >That generally means your query failed. Try to echo mysql_error() after your query to see what the problem is. You probably need quotes around $type or $type has no value. You also have too many quotes on the $query line, try echoing your $query variable to see if it reads properly. Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows error
> I am new to php and that the folowing error: Warning: mysql_num_rows(): > supplied argument is not a valid MySQL result resource in > /home/tbonestu/public_html/smallimages.php > > i dont know what i am doing wrong here is the code: > > @ $db = mysql_pconnect(connect info); > > mysql_select_db("images"); > $query = "select * from images where type =".$type.""; > $result = mysql_query($query); > $num_results = mysql_num_rows($result); That generally means your query failed. Try to echo mysql_error() after your query to see what the problem is. You probably need quotes around $type or $type has no value. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows error
Hi, Sunday, September 23, 2001, 3:25:02 PM, you wrote: NV> I am new to php and that the folowing error: Warning: mysql_num_rows(): NV> supplied argument is not a valid MySQL result resource in NV> /home/tbonestu/public_html/smallimages.php NV> i dont know what i am doing wrong here is the code: NV> @ $db = mysql_pconnect(connect info); NV> mysql_select_db("images"); NV> $query = "select * from images where type =".$type.""; NV> $result = mysql_query($query); NV> $num_results = mysql_num_rows($result); Do it this way $query = "select * from images where type = '$type'"; or if you prefer $query = "select * from images where type = '".$type."'"; PS check your comps date its a year out -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows();
On Thursday 15 August 2002 07:35, Sascha Braun wrote: > This is my query with some dummy loginformations: > > SELECT * FROM benutzer_db where Benutzername = 'Herbert' AND Passwort = > 'hals' > > and this is the code i use for the database transaction: > > $Query = "SELECT * FROM benutzer_db where Benutzername = > '".$SESSION['nickname']."' "; $Query .= "AND Passwort = > '".$SESSION['password']."'"; > $Result = mysql_query($Query, $connect); > if(mysql_num_rows($Result)>'0') { Try: if (mysql_num_rows($Result) > 0) { -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* I tell them to turn to the study of mathematics, for it is only there that they might escape the lusts of the flesh. -- Thomas Mann, "The Magic Mountain" */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows($Result)
In your database design you need the following every username/pass comb is unique. so a query like ... WHERE username='$testvalue' AND password='$testvalue2' Have to give you one row for a good user/passcombination ALWAYS. And 0 rows for a wrong combination. If NOT your design doesn;t fit your needs!! Op donderdag 15 augustus 2002 01:18, schreef Sascha Braun: > Mh, > > right yet I have another problem. I want to select a username an a = > password from a database. The Values for tghe select are stored in a = > session variable. > > And my problem is, that when I run the Query there is no difference in = > the mysql_num_rows($Result) > > it both time (When the User is in the Database, or the Username is = > emtpy) 0. > > How am i able to ckeck the value to do some branching? > > Schura -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows always returns 1?
> $query = "select count(*) from users where " You are asking for a count() in your query. This will always give you one row returned with a count. If you really want to do this you should probably have: $query = "select count(*) as usercount from users where" Then you can do your tests based on the value of usercount. Alternately, you could do something like this: $query = "select * from user where" And then use mysql_num_rows() to see how many users you got. In this case, no matches will result in no rows returned. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows always returns 1?
At 13:00 18-06-02 +0100, Mark Colvin wrote: >The function below works when I pass in a valid username and password and >returns '1'. When I pass a username and password that is not in the database >it still returns '1'. I have put some echo statements in for debugging and >the value of $numresult is always '1'. Does mysql_num_rows retain results in >memory or something like that or am I completely going down the wrong road? that's because when 'select count(*)' = 0 when it finds no results. So you get a record returned to $result with a single line that tells you count(*) was 0. what you should probably do is instead of counting, check for a valid username/password returned by your query. if they're blank, then $user/$pass are either incorrect or not in your users table. or, as someone else suggested, check the value of count(*) rather than the number of lines returned by the query. Eugene -- - Eugene Mah, M.Sc., DABR [EMAIL PROTECTED] Medical Physicist/Misplaced Canuck[EMAIL PROTECTED] Department of Radiology "For I am a Bear of Very Little Medical University of South Carolina Brain, and long words Bother Charleston, South Carolina me." Winnie the Pooh http://home.netcom.com/~eugenem/ PGP KeyID = 0x1F9779FD, 0x319393F4 PGP keys available on request ICQ 3113529 O- - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows always returns 1?
Try $query = "select count(*) as Lines from users where " and then check the value of Lines. Or then do something like $query = "select ID from users where " and now your mysql_num_rows($result) should return right kinda value. Niklas -Original Message- From: Mark Colvin [mailto:[EMAIL PROTECTED]] Sent: 18. kesäkuuta 2002 15:00 To: [EMAIL PROTECTED] Subject: [PHP] mysql_num_rows always returns 1? The function below works when I pass in a valid username and password and returns '1'. When I pass a username and password that is not in the database it still returns '1'. I have put some echo statements in for debugging and the value of $numresult is always '1'. Does mysql_num_rows retain results in memory or something like that or am I completely going down the wrong road? function VerifyLogin($user, $pass) { $conn = $this->DB_Connect(); $query = "select count(*) from users where " ."username = '$user' and " ."password = '$pass'"; $result = mysql_query($query); if(!$result) { echo 'Cannot run query.'; echo 'user = ' .$user; echo 'pass = ' .$pass; echo 'query = ' .$query; echo 'result = ' .$result; $numresult = mysql_num_rows($result); echo 'numresult = ' .$numresult; exit; } else { $numresult = mysql_num_rows($result); echo 'numresult = ' .$numresult; } //if a row exists we have a correct username/password if (mysql_num_rows($result) == 1) { return 1; } // else username and/or password is wrong { return 0; } } Thanks in advance Mark This e-mail is intended for the recipient only and may contain confidential information. If you are not the intended recipient then you should reply to the sender and take no further ation based upon the content of the message. Internet e-mails are not necessarily secure and CCM Limited does not accept any responsibility for changes made to this message. Although checks have been made to ensure this message and any attchments are free from viruses the recipient should ensure that this is the case. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ### This message has been scanned by F-Secure Anti-Virus for Internet Mail. For more information, connect to http://www.F-Secure.com/ ### This message has been scanned by F-Secure Anti-Virus for Internet Mail. For more information, connect to http://www.F-Secure.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_num_rows()
It's 1 based. It returns the number of rows. Not the index of the last row. (Which would be 0 based.) On Fri, 2002-06-07 at 19:23, William_dw -- Sqlcoders wrote: > Hiya!, > Does anyone know whether mysql_num_rows is zero or one based? > > that is, if I have 5 records will mysql_num_rows() return 4 or 5? > > Thanks in advance!, > Dw. > > (I did check the php.net and MySQL manual for mysql_num_rows, > php.net dosent say and MySQL only gives a one line description, which is how > to call mysql_num_rows). > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql_num_rows()
[snip] Does anyone know whether mysql_num_rows is zero or one based? [/snip] It's one based. Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mysql_num_rows
At 06:05 AM 2/18/2002 Monday, Frank Miller wrote: >Next I say if ($num == 0) >{ > echo " There are no events scheduled today!"; >} >else > { > echo "blah, blah, blah"; >} Try this if (empty($num)) echo "Nothing today!"; else echo "blah, blah, blah"; I believe in PHP if a variable is set to 0 it is as good as not set at all. So the empty($num) looks for a variable that has a value of 0. I think I ran into this problem myself and I was able to solve it in the above way. Phillip +++ IMPORTANT: This email message (including attachments, if any) is intended for the use of the individual addressee(s) named above and may contain information that is confidential, privileged or unsuitable for overly sensitive persons with low self-esteem, no sense of humor or irrational religious beliefs. If you are not the intended recipient, any dissemination, distribution or copying of this email is not authorized (either explicitly or implicitly) and constitutes an irritating social faux pas. Unless the word absquatulation has been used in its correct context somewhere other than in this warning, it does not have any legal or no grammatical use and may be ignored. No animals were harmed in the transmission of this email, although the barking dachshund next door is living on borrowed time, let me tell you. Those of you with an overwhelming fear of the unknown will be gratified to learn that there is no hidden message revealed by reading this warning backwards, so just ignore that Alert Notice from Microsoft. However, by pouring a complete circle of salt around yourself and your computer you can ensure that no harm befalls you, your family or your pets. If you have received this email in error, please add some nutmeg and egg whites, whisk and place in a warm oven for 40 minutes. +++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Mysql_num_rows
Do everything as you did, except for that if-statement. $Query = "SELECT * FROM table"; $Results = mysql_query($Query); $num = mysql_num_rows($Results); if ($num < 1 || !isset($num)) echo "Nothing here!"; else echo "Do something today!"; Niklas -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: 18. helmikuuta 2002 16:27 To: Php-General; ':[EMAIL PROTECTED]' Subject: RE: [PHP] Mysql_num_rows Please show your exact code, because your code snippet looks right. Then, again, maybe it's because it's an Aggie machine... -Original Message- From: Niklas Lampén [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:11 AM To: Php-General Subject: RE: [PHP] Mysql_num_rows Maybe you can round the problem with if ($num < 1) echo "Nothing today!"; else echo "Something to do today!"; if (!isset($num) || $num == 0)... Niklas -Original Message- From: Frank Miller [mailto:[EMAIL PROTECTED]] Sent: 18. helmikuuta 2002 16:05 To: [EMAIL PROTECTED] Subject: [PHP] Mysql_num_rows Thanks to everyone that helped me with my last problem I've run into another problem and was wondering if someone here could offer any help or suggestions. The project I'm working on is an event calender. It does several things but the problem I've run into is when I click a date on the calendar if there are no events for that day I want to print a message on the web page saying as much. I've read the documentaion that said if I'm using a select statement to use mysql_num_rows and that it returns an integer. Here is a snippet of my code $query = "SELECT *,TIME_FORMAT(eventtime, '%l:%i %p')AS eventtime, DATE_FORMAT(dateofevent,'%M %e, %Y') AS fdateofevent FROM tamutevents where refid=$refid"; $result = mysql_query($query,$connection) or die("Error in Query"); $num = mysql_num_rows($result); Next I say if ($num == 0) { echo " There are no events scheduled today!"; } else { echo "blah, blah, blah"; } The problem is if there are no records that match the select then it always goes to the else part. I've tried printing the value of $num and it works if there is something scheduled but when there is nothing scheduled $num shows nothing on the screen. I'm using Mysql 3.23.38 and php 4.06 on a windows test machine but it works the same on php 4.06 and Mysql 3.23.46 on my Linux server. Has anyone else run into this and if so can you tell me what to do about it. Thanks in advance - Frank Frank Miller Computer Specialist and Webmaster Technology and Distance Education Texas A&M University-Texarkana 2600 North Robison Rd Texarkana, Texas 75501 Phone: 903-223-3156 Fax: 903-223-3139 Office: 165 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Mysql_num_rows
Please show your exact code, because your code snippet looks right. Then, again, maybe it's because it's an Aggie machine... -Original Message- From: Niklas Lampén [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 8:11 AM To: Php-General Subject: RE: [PHP] Mysql_num_rows Maybe you can round the problem with if ($num < 1) echo "Nothing today!"; else echo "Something to do today!"; if (!isset($num) || $num == 0)... Niklas -Original Message- From: Frank Miller [mailto:[EMAIL PROTECTED]] Sent: 18. helmikuuta 2002 16:05 To: [EMAIL PROTECTED] Subject: [PHP] Mysql_num_rows Thanks to everyone that helped me with my last problem I've run into another problem and was wondering if someone here could offer any help or suggestions. The project I'm working on is an event calender. It does several things but the problem I've run into is when I click a date on the calendar if there are no events for that day I want to print a message on the web page saying as much. I've read the documentaion that said if I'm using a select statement to use mysql_num_rows and that it returns an integer. Here is a snippet of my code $query = "SELECT *,TIME_FORMAT(eventtime, '%l:%i %p')AS eventtime, DATE_FORMAT(dateofevent,'%M %e, %Y') AS fdateofevent FROM tamutevents where refid=$refid"; $result = mysql_query($query,$connection) or die("Error in Query"); $num = mysql_num_rows($result); Next I say if ($num == 0) { echo " There are no events scheduled today!"; } else { echo "blah, blah, blah"; } The problem is if there are no records that match the select then it always goes to the else part. I've tried printing the value of $num and it works if there is something scheduled but when there is nothing scheduled $num shows nothing on the screen. I'm using Mysql 3.23.38 and php 4.06 on a windows test machine but it works the same on php 4.06 and Mysql 3.23.46 on my Linux server. Has anyone else run into this and if so can you tell me what to do about it. Thanks in advance - Frank Frank Miller Computer Specialist and Webmaster Technology and Distance Education Texas A&M University-Texarkana 2600 North Robison Rd Texarkana, Texas 75501 Phone: 903-223-3156 Fax: 903-223-3139 Office: 165 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Mysql_num_rows
Maybe you can round the problem with if ($num < 1) echo "Nothing today!"; else echo "Something to do today!"; if (!isset($num) || $num == 0)... Niklas -Original Message- From: Frank Miller [mailto:[EMAIL PROTECTED]] Sent: 18. helmikuuta 2002 16:05 To: [EMAIL PROTECTED] Subject: [PHP] Mysql_num_rows Thanks to everyone that helped me with my last problem I've run into another problem and was wondering if someone here could offer any help or suggestions. The project I'm working on is an event calender. It does several things but the problem I've run into is when I click a date on the calendar if there are no events for that day I want to print a message on the web page saying as much. I've read the documentaion that said if I'm using a select statement to use mysql_num_rows and that it returns an integer. Here is a snippet of my code $query = "SELECT *,TIME_FORMAT(eventtime, '%l:%i %p')AS eventtime, DATE_FORMAT(dateofevent,'%M %e, %Y') AS fdateofevent FROM tamutevents where refid=$refid"; $result = mysql_query($query,$connection) or die("Error in Query"); $num = mysql_num_rows($result); Next I say if ($num == 0) { echo " There are no events scheduled today!"; } else { echo "blah, blah, blah"; } The problem is if there are no records that match the select then it always goes to the else part. I've tried printing the value of $num and it works if there is something scheduled but when there is nothing scheduled $num shows nothing on the screen. I'm using Mysql 3.23.38 and php 4.06 on a windows test machine but it works the same on php 4.06 and Mysql 3.23.46 on my Linux server. Has anyone else run into this and if so can you tell me what to do about it. Thanks in advance - Frank Frank Miller Computer Specialist and Webmaster Technology and Distance Education Texas A&M University-Texarkana 2600 North Robison Rd Texarkana, Texas 75501 Phone: 903-223-3156 Fax: 903-223-3139 Office: 165 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php