I have two tables on my database, one called comics, and one called subjects.
I’m trying to get data from both tables, but I’m running into an error.
Here’s my code:
[code=php]<?php
include (‘../inserts/comic_db.php’);
# Set up variables
$subject= @mysql_real_escape_string(htmlspecialchars($_GET[‘subject’]));
if(!$comics = mysql_query(“SELECT * FROM comics WHERE Keywords LIKE (‘%$subject%’)”)){
echo “<br>Error with MySQL:<br>”.mysql_error();
}
if(!$description = mysql_query(“SELECT * FROM subjects WHERE `Keyword` LIKE (‘$subject’)”)){
echo “<br>Error with MySQL:<br>”.mysql_error();
}
$nl = “n”;
$comic_list = ”;
if (empty($_GET[‘page’]))
{
$page=1;
}
else
{
$page=$_GET[‘page’];
}
$next=$page+1;
$previous=$page-1;
// debug
$num = @mysql_num_rows($comics);
$comic_array=array();
$counter=1;
while($row=mysql_fetch_array($comics))
{
$comic_array[$counter] = ‘<li><a href=”./chronological.php?comic=’.$row[‘Number’].'”><img src=”../comics/sem_’.$row[‘Semester’].’/’.$row[‘Comic’].'”></a></li>’.$nl.”;
$counter+=1;
}
$row2=msql_fetch_array($description);
$describe=$row2[‘Description’];
//Create the page here.
include(“../inserts/head.htm”);
echo (‘
<link type=”text/css” rel=”stylesheet” href=”../CSS/setup.css”>
<link type=”text/css” rel=”stylesheet” href=”../CSS/comic.css”>
<title>’.$subject.'</title>
</head>
<body>
<h1>’.$subject.'</h1>
<h2>’.$describe.'</h2>
<ul class=”comic”>
‘);
$comic_end=$page*5;
$comic_start=$comic_end-4;
for ($comic_count=$comic_start; $comic_count<=$comic_end;$comic_count++)
{
echo $comic_array[$comic_count];
}
echo (‘</ul>
‘);
# previous/next stuff
echo (‘<ul id=”nav”>
‘);
if ($page>1)
{
echo(‘<li><a href=”./subjects-exp.php?subject=’.$subject.’&page=’.$previous.'”>Previous</a></li>’);
}
echo (‘<li><a href=”../subjects.php”>Subjects</a></li>
<li><a href=”../index.php”>Back To Main</a></li>
‘);
if (!empty($comic_array[$comic_count]))
{
echo(‘<li><a href=”./subjects-exp.php?subject=’.$subject.’&page=’.$next.'”>Next</a></li>’);
}
?>
</ul>
</body>
</html>
The result is a blank page. I’m sure the error is in
[code]$row2=msql_fetch_array($description);
$describe=$row2[‘Description’];
since when I comment those out, a working page does show up, albeit without some of the data I want in there (namely that from the table ‘subjects’).