473,395 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

telling the difference between zero rows returned and failure


Suppose I make a call to MySql and zero rows come back. How do I tell
the difference between zero rows and failure?

Jul 17 '05 #1
3 2410
lk******@geocities.com wrote:
Suppose I make a call to MySql and zero rows come back. How do I tell
the difference between zero rows and failure?


By calling mysql_error() like this:

$result = mysql_query($query) or die(mysql_error());
JW

Jul 17 '05 #2
lk******@geocities.com wrote:
Suppose I make a call to MySql and zero rows come back. How do I tell
the difference between zero rows and failure?


0==false evals to true ("loose" comparison), but 0===false evals to false
(stricter comparation where types also matter), see
http://www.php.net/manual/en/types.comparisons.php for a more complete
overview and
http://www.php.net/manual/en/languag...comparison.php for the
available comparison operators.

Jul 17 '05 #3
lk******@geocities.com wrote:
Suppose I make a call to MySql and zero rows come back. How do I tell
the difference between zero rows and failure?


From the mysql_query() doc:

Only for SELECT,SHOW,EXPLAIN or DESCRIBE statements mysql_query()
returns a resource identifier or FALSE if the query was not executed
correctly. For other type of SQL statements, mysql_query() returns TRUE
on success and FALSE on error. A non-FALSE return value means that the
query was legal and could be executed by the server. It does not
indicate anything about the number of rows affected or returned.
From the mysql_num_rows() doc:

mysql_num_rows() returns the number of rows in a result set. This
command is only valid for SELECT statements.
In other words: if mysql_query() returns false, it's failure. If it's
not failure, then you can use mysql_num_rows() to see how many rows you get.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: robert | last post by:
running 8.1.7 server, 8.1.6 client. i *thought* inner join should not return nulls, but not only that, but i get way more rows than i'm expecting. assume: order table: order_number
6
by: yoohanman | last post by:
Hi, I have a select statment that correctly returns zero rows at times. I would like to be able to return the value 0 (a single row with the value 0) whenever the logic returns zero rows. ...
6
by: Frank | last post by:
I spent over an hour on the Internet & MSDN looking for an answer that worked for this problem. Lots of answers, none work. It's time to post a question. Using: VB6, ADO, MS Jet 4.0 How do...
25
by: Mantorok Redgormor | last post by:
Finally, control is returned to the host environment. If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. beyond this...
10
by: Sek | last post by:
I have a property that returns a ArrayList object. On failure condition, is it right to return null or return an ArrayList object with zero elements?
4
by: Kenneth Brody | last post by:
I looked at my copy of n1124, and I didn't see anything about this particular situation... What happens if you realloc() to a size of zero? Implementations are allowed to return NULL on...
3
by: Sandman | last post by:
Hi, So I read the manual where it says to use mysql_affected_rows() for everything except SELECT and SHOW, and use mysql_num_rows() for those two, which actually return a result. However, I...
2
by: D'Arcy J.M. Cain | last post by:
I am having a strange problem and I can't seem to zero in on it. I am also having trouble reducing it to a small enough snippet that I can post here. I think that I am doing what the more complex...
0
by: Chris Rebert | last post by:
On Tue, Nov 18, 2008 at 8:56 PM, D'Arcy J.M. Cain <darcy@druid.netwrote: What happens under Python 2.6? Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.