gaugeboson Posted April 29, 2008 Share Posted April 29, 2008 <?php else { $latqsql = "SELECT questions.id, question, subject FROM subjects, questions, topics WHERE questions.topic_id = topics.id AND topics.subject_id = subjects.id AND active = 1 ORDER BY questions.dateadded DESC;"; $latqresult = mysql_query($latqsql); $latqnumrows = mysql_num_rows($latqresult); echo "<h1>Latest Questions</h1>"; if($latqnumrows == 0) { echo "No questions!"; } else { echo "<ul>"; while($latqrow = mysql_fetch_assoc($latqresult)) { echo "<li><a href='answer.php?id=" . $latqrow['id'] . //error here "'>" . $latqrow['question'] . "</a> (<i>" . $latqrow['subject'] . "</i>)</li>"; } echo "</ul>"; } } ?> (edited by kenrbnsn to add tags) Quote Link to comment Share on other sites More sharing options...
gaugeboson Posted April 29, 2008 Author Share Posted April 29, 2008 Oh, and the complete error message is this: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in /var/www/faq/index.php on line 81 Thanks Quote Link to comment Share on other sites More sharing options...
blackcell Posted April 29, 2008 Share Posted April 29, 2008 Try something like this for sake of being able to read the code: <php? while($latqrow = mysql_fetch_assoc($latqresult)) { $ID = $latqrow['id']; $question = $latqrow['question']; $subject = $latqrow['subject']; echo "<li><a href='answer.php?id='$ID'>$question</a> (<i>$subject</i>)</li>"; } Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 29, 2008 Share Posted April 29, 2008 It looks ok. I tested it (by removing the query thing normally) and it isnt giving any errors. U sure u posted the right portion of code? Quote Link to comment Share on other sites More sharing options...
gaugeboson Posted April 29, 2008 Author Share Posted April 29, 2008 Well here is the code for the page: <?php session_start(); require("config.php"); require("functions.php"); if($_GET['subject']) { if(pf_check_number($_GET['subject']) == TRUE) { $validsub = $_GET['subject']; } else { header("Location: " . $config_basedir); } } require("header.php"); if($_GET['subject']) { $subsql = "SELECT users.username, subjects.* FROM subjects LEFT JOIN users ON subjects.owner_id = users.id WHERE subjects.id = " . $validsub . ";"; $subresult = mysql_query($subsql); $subrow = mysql_fetch_assoc($subresult); echo "<h1>" . $subrow['subject'] . " Summary</h1>"; if($subrow['owner_id'] == 0) { echo "This subject has no owner."; if($_SESSION['SESS_USERNAME']) { echo " If you would like to apply to own this subject, click <a href='applysubowner.php?subject=" . $subject . "'>here</a>."; } } else { echo "This subject is owned by <strong>". $subrow['username'] . "</strong>."; } echo "<p><i>" . $subrow['blurb'] . "</i></p>"; $topicsql = "SELECT count(distinct(topics.id)) AS numtopics, count(questions.id) AS numquestions FROM subjects LEFT JOIN topics ON subjects.id = topics.subject_id LEFT JOIN questions ON topics.id = questions.topic_id WHERE subjects.id = " . $validsub . " AND active = 1;"; $topresult = mysql_query($topsql); $toprow = mysql_fetch_assoc($topresult); echo "<table class='visible' cellspacing=0 cellpadding=5>"; echo "<tr><th class='visible' colspan=2>Statistics</th></tr>"; echo "<tr>"; echo "<td>Total Topics</td><td>" . $toprow['numtopics'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Total Questions</td><td>" . $toprow[numquestions'] . "</td>"; echo "</tr>"; echo "</table>"; } else { $latqsql = "SELECT questions.id, question, subject FROM subjects, questions, topics WHERE questions.topic_id = topics.id AND topics.subject_id = subjects.id AND active = 1 ORDER BY questions.dateadded DESC;"; $latqresult = mysql_query($latqsql); $latqnumrows = mysql_num_rows($latqresult); echo "<h1>Latest Questions</h1>"; if($latqnumrows == 0) { echo "No questions!"; } else { echo "<ul>"; while($latqrow = mysql_fetch_assoc($latqresult)) { echo "<li><a href='answer.php?id=" . $latqrow['id'] . ## error here "'>" . $latqrow['question'] . "</a> (<i>" . $latqrow['subject'] . "</i>)</li>"; } echo "</ul>"; } } require("footer.php"); ?> Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in /var/www/faq/index.php on line 81 Quote Link to comment Share on other sites More sharing options...
peranha Posted April 29, 2008 Share Posted April 29, 2008 This line echo "<td>Total Questions</td><td>" . $toprow[numquestions'] 58 you have only 1 ' should be echo "<td>Total Questions</td><td>" . $toprow['numquestions'] Quote Link to comment Share on other sites More sharing options...
gaugeboson Posted April 29, 2008 Author Share Posted April 29, 2008 Great. Thanks. 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.