QUOTE
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp\www\web design\cms\viewtutorial.php on line 18
It works for all my other scripts except for this one. Here's my PHP;
PHP
<?php
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: '.$domain.'index.php?error=1');
exit();
}
include 'config.php';
$ID = $_GET['view'];
$db = mysql_connect("$dbHost","$dbUser","$dbPass");
mysql_select_db($dbname,$db);
$requete = "SELECT T.ID, metakeywords, metadescription, tutorialtitle, subjectID, subject, postedby, datetime, tutcontent FROM tutorial T INNER JOIN
subject S ON S.ID = T.subjectID WHERE ID=$ID";
$result = mysql_query ($requete,$db);
while($row = mysql_fetch_assoc($result)) {
$ID = $row['ID'];
$metakeywords = $row['metakeywords'];
$metadescription = $row['metadescription'];
$tutorialtitle = $row['tutorialtitle'];
$subjectID = $row['subjectID'];
$subject = $row['subject'];
$postedby = $row['postedby'];
$datetime = date("n.j.y / g:ia", $row['datetime']);
$tutcontent = $row['tutcontent'];
$metakeywords = stripslashes($row['metakeywords']);
$metadescription = stripslashes($row['metadescription']);
$tutorialtitle = stripslashes($row['tutorialtitle']);
$subject = stripslashes($row['subject']);
$postedby = stripslashes($row['postedby']);
$tutcontent = str_replace("\n", '', $tutcontent);
$tutcontent = stripslashes($tutcontent);
$tutcontent = str_replace("'", "\'", $tutcontent);
$tutcontent = preg_replace("/\[php\](.+?)\[\/php\]/", "'); highlight_php('$1'); echo('", $tutcontent);
$tutcontent = preg_replace("/\[html\](.+?)\[\/html\]/", "'); htmlchar('$1'); echo('", $tutcontent);
$tutcontent = 'echo(\'' . $tutcontent . '\');';
echo '<div class="indexpagecomment">';
echo '<div class="indexpagecommentheader"><a href="viewtutorial.php?view='.$ID.'">'.$tutorialtitle.'</a><p>Category: <a
href="subjectlist.php?='.$subjectID.'">'.$subject.'</a></p><p>Created by '.$postedby.' on '.$datetime.' <acronym title="Greenwich Mean
Time">GMT</acronyn></p></div>';
echo '<div style="padding: 5px;">';
eval($tutcontent);
echo '</div></div>';
}
?>
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: '.$domain.'index.php?error=1');
exit();
}
include 'config.php';
$ID = $_GET['view'];
$db = mysql_connect("$dbHost","$dbUser","$dbPass");
mysql_select_db($dbname,$db);
$requete = "SELECT T.ID, metakeywords, metadescription, tutorialtitle, subjectID, subject, postedby, datetime, tutcontent FROM tutorial T INNER JOIN
subject S ON S.ID = T.subjectID WHERE ID=$ID";
$result = mysql_query ($requete,$db);
while($row = mysql_fetch_assoc($result)) {
$ID = $row['ID'];
$metakeywords = $row['metakeywords'];
$metadescription = $row['metadescription'];
$tutorialtitle = $row['tutorialtitle'];
$subjectID = $row['subjectID'];
$subject = $row['subject'];
$postedby = $row['postedby'];
$datetime = date("n.j.y / g:ia", $row['datetime']);
$tutcontent = $row['tutcontent'];
$metakeywords = stripslashes($row['metakeywords']);
$metadescription = stripslashes($row['metadescription']);
$tutorialtitle = stripslashes($row['tutorialtitle']);
$subject = stripslashes($row['subject']);
$postedby = stripslashes($row['postedby']);
$tutcontent = str_replace("\n", '', $tutcontent);
$tutcontent = stripslashes($tutcontent);
$tutcontent = str_replace("'", "\'", $tutcontent);
$tutcontent = preg_replace("/\[php\](.+?)\[\/php\]/", "'); highlight_php('$1'); echo('", $tutcontent);
$tutcontent = preg_replace("/\[html\](.+?)\[\/html\]/", "'); htmlchar('$1'); echo('", $tutcontent);
$tutcontent = 'echo(\'' . $tutcontent . '\');';
echo '<div class="indexpagecomment">';
echo '<div class="indexpagecommentheader"><a href="viewtutorial.php?view='.$ID.'">'.$tutorialtitle.'</a><p>Category: <a
href="subjectlist.php?='.$subjectID.'">'.$subject.'</a></p><p>Created by '.$postedby.' on '.$datetime.' <acronym title="Greenwich Mean
Time">GMT</acronyn></p></div>';
echo '<div style="padding: 5px;">';
eval($tutcontent);
echo '</div></div>';
}
?>
And as Willy mentioned before it is quite difficult to solve server side problems without seeing the tables here they are also;
SQL
CREATE TABLE `subject` (
`ID` int(11) NOT NULL auto_increment,
`subject` varchar(255) default NULL,
KEY `ID` (`ID`)
);
`ID` int(11) NOT NULL auto_increment,
`subject` varchar(255) default NULL,
KEY `ID` (`ID`)
);
SQL
CREATE TABLE `tutorial` (
`ID` int(11) NOT NULL auto_increment,
`metakeywords` text,
`metadescription` text,
`tutorialtitle` varchar(255) default NULL,
`subjectID` int(5) default NULL,
`tutcontent` text,
`postedby` varchar(60) default NULL,
`datetime` int(10) unsigned default NULL,
KEY `ID` (`ID`)
);
`ID` int(11) NOT NULL auto_increment,
`metakeywords` text,
`metadescription` text,
`tutorialtitle` varchar(255) default NULL,
`subjectID` int(5) default NULL,
`tutcontent` text,
`postedby` varchar(60) default NULL,
`datetime` int(10) unsigned default NULL,
KEY `ID` (`ID`)
);
Can anyone see where I'm going wrong with this code?
TIA