Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/270110-having-some-problems-with-my-searchphp/
Share on other sites

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%'

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 by Barand
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.