Jump to content

[SOLVED] mysqli_num_rows on queries which don't return a number


Recommended Posts

Hi

 

When I try to use mysqli_num_rows on a "CREATE TABLE" statement, it returns me the error "mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in ...".  This is because the CREATE statement doesn't return a number of rows like a SELECT statement would.

 

Is there a clean way to deal with this error?  Either by somehow finding out which "type" of query I'm dealing with (a substring extracting the first word of the query could do the trick, but it doesn't feel right) or by error-free testing if mysqli_num_rows is applicable (adding a @ before the function would also do the trick but is, again, not a really clean way).

 

BTW, I'm using a home-brewn general-purpose query function which launches queries for me and which automatically retrieves results.  So it's not a matter of calling mysqli_num_rows only when I launch a SELECT statement, my function doesn't know which type of query is used and I'm not too fond of having to pass the type each time as an argument.

 

Cheers

Snart

I used xampp in the past, currently I use wampserver.  But the issue is not the creation of the tables (which has to be done via script, not phpmyadmin and such) but the fact that a "CREATE TABLE" statement generates an error when I use mysqli_num_rows().  I need a way to either test if mysqli_num_rows will work properly on the query, or determine if the query that is being launched is a CREATE statement or SELECT statement or something else.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.