Hi PJ,

Having been a C programmer for a while this makes perfect sense to me. You call mysql_(real)_query to execute the query and get the results from the server. Because the MySQL library doesn't know when you've finished with the result-set, you have to tell it to write the results to memory (mysql_store_result.) This can then be read using mysql_num_rows and other data retrieval functions.

This sentence in the manual makes this clear:

"After you have called mysql_store_result() and gotten back a result that isn't a null pointer, you can call mysql_num_rows() to find out how many rows are in the result set."

When you're finished with the result-set you can then use mysql_free_result to release the memory allocated by the library.

What difficulties are you having with error checking? Most MySQL functions return NULL if the operation fails - mysql_real_connect, mysql_store_result etc. Others return non-zero, like mysql_real_query. All the function documentation in the manual gives the return codes and how to tell if a call failed.

Personally I've found the MySQL manual the best of any documentation for systems we use, although I agree an example of a simple client/query would have been useful.

Regards,
Andy

PJ wrote:
What is this supposed to mean from the manual:
The use of |mysql_num_rows()|
<http://dev.mysql.com/doc/refman/5.0/en/mysql-num-rows.html> depends on
whether you use |mysql_store_result()|
<http://dev.mysql.com/doc/refman/5.0/en/mysql-store-result.html> or
|mysql_use_result()|
<http://dev.mysql.com/doc/refman/5.0/en/mysql-use-result.html> to return
the result set....
|mysql_num_rows()|
<http://dev.mysql.com/doc/refman/5.0/en/mysql-num-rows.html> is intended
for use with statements that return a result set, such as |SELECT|
<http://dev.mysql.com/doc/refman/5.0/en/select.html>.
Does this mean you have to use
mysql_store_result() before using mysql_num_rows() ?.... kind of doesn't
make sense to have to do that. And there are no clear cut examples or
explanations...
I do not wish to piss-and-moan but I do find that there is a lot to be
desired in the manual; things that are very ;contradictory and/ or
unclear and certainly lacking in examples.

And please, somebody guide me to some tutorial or something where I can
learn to set up proper error checking so you guys don't have to listen
to my problems. :'(

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to