mysql_num_rows() problem


$result = mysqli_query($link, 
		'SELECT * FROM allbooks
	   	WHERE  booknumber = "' . $booknumber . '"');
		if (!$result)
			{
			echo 'Error fetching selected title!' . mysqli_error($link);
			exit();
			}

$numrows = mysql_num_rows($result);

The above code gives me this warning:
Warning: mysql_query() [function.mysql-query]: Access denied for user ‘ODBC’@‘localhost’ (using password: NO) in…

The database connection info for the SELECT is ok.

Advice please.

Thanks

Mike

Yes to the first, or to the second question? :lol:

Right. Local it works, remote it doesn’t.
I’ve asked my provider but they don’t supply any technical support so I’m stymied unless someone out there ever had the same situation and knows the answer.

Yeah, sorry I’ll be clearer, as I said earlier there are 4 sources, SELECTS, that use the print program. So I’ve put an echo after all 4 just to check that there are no differences. Anyway, all echos are giving the correct info.

Yes.

Oh and on what I would use Mysql, or Mysqli, i would use MYsqli… but a third option is PDO which is much better for me, and that is what I use. PDO creates a familiar API to access many popular databases. So with PDO you don’t use database specific functions like the mysql or mysqli style fuctions.

Correct me if I’m wrong:
The difference between the MYSQL functions and the MYSQLI functions are that the MYSQLI functions support more of the new features in mysql such as prepared statements. Mysqli was written to be an improved version of the mysql functions.
Another difference is that in the mysqli functions, you specify the database you want in the connection, whereas in mysql you choose the database with mysql_select_db().
That little feature makes mysqli a bit safer.

If MYSQLI wasnt installed, you wouldnt have been able to query the database at all, so lets throw that away for the moment.

We cant see your output statements so we cant offer suggestion as to why this problem occurs.

I notice in your first post you called your num_rows storage $numrows, and in the second post you called it $number. Are you sure you’ve got your variables straight? Show us the code for the output.

Are you sure that the query IS returning results on your remote server? I see an if, else based on $number (For that matter, why not just put the num_rows call in the searchresult.html.php file? $result will extend across the include)

Sorry, I don’t understand. Why after 4 selects? In the code you posted there’s only 1 select. Did you do the echo after that one?

Could you do an echo of mysqli_num_rows($result) right after you execute the query?

Only gives zero, thus incorrect.

After 4 selects I echo the select key and mysqli_num_rows($result) and all are correct.

Yeah, lol. Yes to one script, redirect, no.

If mysqli_num_rows returns 0, it means no rows have been selected.
Do an echo of the query in your code, and check if it is exactly as you expect it to be. Copy and paste it in PHPMyAdmin, and see if it gives any results there.

If the function isn’t supported, it would give an error, not 0.

Check your configuration file…

The user_password is not provided in the config or connection file.

And make sure to user either mysqli_ or mysql_

My provider apparently has php 5.2.14. Or could they be telling a fib?

mysqli_num_rows just in PHP5,php4 doesn’t support it.
http://php.net/manual/en/mysqli-result.num-rows.php
I think maybe your server use low PHP version

Your query is of type MYSQLI.
Your Num Rows function is of type MYSQL.

You missed the i on the num_rows.

Is all the code you’re talking about one script (includes included :wink: ) ?
Or do you do a redirect to another page somewhere?