Mysql result is a resource but doesn't display

Okay so i have this code:

if (isset($_GET['book'])) {

$query= "SELECT  book_id, title, authors.`author` , publishers.`publisher` , formats.`format` , genres.`genre` , usersdb.users.username, pages, isbn, description, DATE_FORMAT( books.`release_date` ,  '%M, %d, %Y' ) AS  `release_date` 
    FROM books
    INNER JOIN  `authors` ON (  `authors`.`author_id` =  `books`.`author_id` ) 
    INNER JOIN  `publishers` ON (  `publishers`.`publisher_id` =  `books`.`publisher_id` ) 
    INNER JOIN  `formats` ON (  `formats`.`format_id` =  `books`.`format_id` ) 
    INNER JOIN  `genres` ON (  `genres`.`genre_id` =  `books`.`genre_id` ) 
    INNER JOIN usersdb.users ON ( usersdb.users.user_id = bookdb.books.user_id ) 
    WHERE books.book_id= ".$_GET['book']."";
    $query=@mysql_query ($query, $dbc1);

if ($query) {
var_dump ($query);
while($row=mysql_fetch_assoc($query)){

echo '<h1>'.$row['title'].'</h1>
  <p>'.$row['author'].'</p>
  <p>'.$row['publisher'].'</p>
  <p>'.$row['format'].'</p>
  <p>'.$row['genre'].'</p>
  <p>'.$row['pages'].'</p>
  <p>'.$row['isbn'].'</p>
  <p>'.$row['release_date'].'</p>
  <p>'.$row['description'].'</p>
  <p>'.$row['username'].'</p>';
}
}
}

It works absolutely fine for some of the entries and all the information is displayed correctly and is fine, but for new entries the information doesn't display at all for some reason.

The mysql query runs correctly and as you can see the I have done a var_dump() and that returns resource(11, mysql result) so the resource is definitely there it just doesn't seem to get run through the while statement.

If you can see why this is occurring that would be much appreciated.

Answers


If you just remove the "@", you will see that there's maybe an error. Globally in PHP, the use of "@" is a mistake. You may never use it.


Try echo mysql_num_rows($query) if any records are being fetched.

If it returns some value, try removing @,it might be the cause of error


Need Your Help

Metro XAML - Color Bindings Not Working

c# silverlight xaml windows-runtime winrt-xaml

Ive been writing a complex custom control in Metro/XAML using C#.

Why does "foo".class === String return false?

ruby string boolean equality

I became curious when this didn't work as I expected: