$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.
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.
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)
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.