Jump to content

Warning: Mysql_Fetch_Array() Expects Parameter 1 To Be Resource, Boolean


kingmanic2

Recommended Posts

I cant seem to get this going and displaying properly. I'm getting the variable searchbar from another page which has a form on it that the user can input. When I input something that I diffidently know is in the database I get the error:

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\Site]search.php on line 42

 

Any help would be much appreciated.

Thanks

 

<?php


$dbname = "assignment2";
$dbhost = "127.0.0.1";
$dbuser = "root";
$dbpwd = "";
$search = $_GET['searchbar'];


$link = mysql_connect($dbhost, $dbuser, $dbpwd);
mysql_select_db($dbname);


$sql = "SELECT comic.image_thumbnail, comic.title, comic.description, comic.volume, artist.name AS artist_name, author.name AS author_name, genre.type, publisher.name AS publisher_name, comic.publication_date
FROM ((publisher INNER JOIN (genre INNER JOIN (comic INNER JOIN (comic_author INNER JOIN author ON comic_author.[author_id] = author.[author_id]) ON comic.[comic_id] = comic_author.[comic_id]) ON genre.[genre_id] = comic.[genre_id]) ON publisher.[publisher_id] = comic.[publisher_id]) INNER JOIN comic_artist ON comic.[comic_id] = comic_artist.[comic_id]) INNER JOIN artist ON comic_artist.[artist_id] = artist.[artist_id] WHERE comic.title like '%$search' OR artist.name like '%search' OR author.name like '%$search' OR publisher.name like '%$search'" ;


$result = mysql_query($sql);


while ($row = mysql_fetch_array($result)){               //This is line 42
echo "<img height=200 align=center src=".$row['image_thumbnail'].">". "<br>". //comic
'Title: '.$row['title']."<br>". //comic
'Description: '.$row['description']."<br>". //comic
'Volume: '.$row['volume']."<br>". //comic
//'Artist: '.$row['name']."<br>". //comic -> comic_artist -> artist
//'Author: '.$row['author']."<br>". //comic -> comic_author -> author
'Genre: '.$row['genre_id']."<br>". //comic -> genre
'Publisher: '.$row['publisher_id']."<br>". //comic -> publisher
'Publication Date: '.$row['publication_date']."<br>". //comic

"<br>";
}
?>

Edited by kingmanic2
Link to comment
Share on other sites

I now get this:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[author_id] = author.[author_id]) ON comic.[comic_id] = comic_author.[comic_id])' at line 2

 

And i dont see the problem with it?

Link to comment
Share on other sites

Updated code:

 

<?php


$dbname = "assignment2";
$dbhost = "127.0.0.1";
$dbuser = "root";
$dbpwd = "";
$search = $_GET['searchbar'];


$link = mysql_connect($dbhost, $dbuser, $dbpwd);
mysql_select_db($dbname);


$sql = "SELECT comic.image_thumbnail, comic.title, comic.description, comic.volume, artist.name AS artist_name, author.name AS author_name, genre.type, publisher.name AS publisher_name, comic.publication_date
FROM ((publisher INNER JOIN (genre INNER JOIN (comic INNER JOIN (comic_author INNER JOIN author ON comic_author.author_id = author.author_id) ON comic.comic_id = comic_author.comic_id) ON genre.genre_id = comic.genre_id) ON publisher.publisher_id = comic.publisher_id) INNER JOIN comic_artist ON comic.comic_id = comic_artist.comic_id) INNER JOIN artist ON comic_artist.artist_id = artist.artist_id WHERE comic.title like '%$search' OR artist.name like '%search' OR author.name like '%$search' OR publisher.name like '%$search'" ;


$result = mysql_query($sql);


while ($row = mysql_fetch_array($result)){
   echo "<img height=200 align=center src=".$row['image_thumbnail'].">". "<br>". //comic
 'Title: '.$row['title']."<br>". //comic
 'Description: '.$row['description']."<br>". //comic
 'Volume: '.$row['volume']."<br>". //comic
 'Artist: '.$row['name']."<br>". //comic -> comic_artist -> artist
 'Author: '.$row['author']."<br>". //comic -> comic_author -> author
 'Genre: '.$row['genre_id']."<br>". //comic -> genre
 'Publisher: '.$row['publisher_id']."<br>". //comic -> publisher
 'Publication Date: '.$row['publication_date']."<br>". //comic

 "<br>";
   }
?>

Link to comment
Share on other sites

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.