Accolade Posted October 31, 2012 Share Posted October 31, 2012 I have done the joins for 7 tables. Unable to change the database to make this easier. Very simple search.php at this stage. I am getting the following error.... I have tried this with a more simple JOIN also, no deal. Unsure what is wrong. Line 17 is the following line: while ($row = mysql_fetch_array($sql)){ Which indicates to me that there is something wrong with the query. But I don't see why there would be. I will attach search.php for formatting. SCREAM: Error suppression ignored for ( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\search.php on line 17 Call Stack # Time Memory Function Location 1 0.0004 254408 {main}( ) ..\search.php:0 2 0.0119 263288 mysql_fetch_array ( ) ..\search.php:17 <?php $page = 'search'; require('header.php'); require('sidebar.php'); mysql_connect ("127.0.0.1", "root","") or die (mysql_error()); mysql_select_db ("crystal_fusion"); $term = $_POST['term']; $sql = mysql_query("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.description like '%$term%'"); while ($row = mysql_fetch_array($sql)){ echo "<img height=200 align=center src=".$row['comic.image_thumbnail'].">". "<br>". 'Title: '.$row['comic.title']."<br>". 'Description: '.$row['comic.description']."<br>". 'Volume: '.$row['comic.volume']."<br>". 'Artist: '.$row['artist_name']."<br>". 'Author: '.$row['author_name']."<br>". 'Genre: '.$row['genre.type']."<br>". 'Publisher: '.$row['publisher_name']."<br>". 'Publication Date: '.$row['comic.publication_date']."<br>". "<br>"; } ?> search.php Quote Link to comment Share on other sites More sharing options...
Barand Posted October 31, 2012 Share Posted October 31, 2012 After the mysql_query() call, add if (!$sql) die(mysql_error()); That should tell you why it failed Quote Link to comment Share on other sites More sharing options...
Accolade Posted October 31, 2012 Author Share Posted October 31, 2012 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 Quote Link to comment Share on other sites More sharing options...
Accolade Posted October 31, 2012 Author Share Posted October 31, 2012 I cannot see any problem with that syntax? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 31, 2012 Share Posted October 31, 2012 PS. I also had a go at unraveling your joins 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 comic INNER JOIN genre USING (genre_id) INNER JOIN publisher USING (publisher_id) INNER JOIN comic_author ON comic.comic_id = comic_author.comic_id INNER JOIN author USING (author_id) INNER JOIN comic_artist ON comic.comic_id = comic_artist.comic_id INNER JOIN artist USING (artist_id) WHERE comic.description like '%$term%' Quote Link to comment Share on other sites More sharing options...
Barand Posted October 31, 2012 Share Posted October 31, 2012 (edited) I cannot see any problem with that syntax? You are using MySQL with MS-SQL syntax MS-SQL uses [..], MySQL uses backticks `..`, however neither necessary here Edited October 31, 2012 by Barand Quote Link to comment Share on other sites More sharing options...
Accolade Posted October 31, 2012 Author Share Posted October 31, 2012 Thank you soooo much mate! Lifesaver! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.