Jump to content

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING


gaugeboson

Recommended Posts

<?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)

Link to comment
Share on other sites

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>";
}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.