Jump to content

error, don't know cause


CK9

Recommended Posts

Hello again!  Seems I only ever come here when something goes wrong with my coding, heh

 

Well, I've been experimenting with some code again, this time for a site to go along with my senior design project (hooray!  BS degree almost complete!)

 

error message:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ck9/public_html/CHE175project/news.php on line 26

 

page code (with security information censored of course).  Line 26 is the if statement checking for row['id'] matching

<?php
if (empty($_REQUEST['np']))
  {
   $page = "home";
  }
else
  {
   $page = $_REQUEST['np'];
  }
mysql_connect("localhost","user","pass") or die('could not connect: ' . mysql_error());
mysql_select_db("ck9_CHE175") or die('could not find database: ' . mysql_error());
$result = mysql_query("SELECT * FROM news") or die('could not find table: ' . mysql_error());
if ($page == "home")
  {
   echo "<font size='5'>Labor Improbus strives to keep information up to date.  Select a news topic below to see what we have accomplished<br>";
   echo "<table cols='1' align='center'>";
   while ($row = mysql_fetch_array($result))
    {
     echo "<tr><td><center><a href='index.php?pg=news&np=" . $row['id'] . "'>" . $row['title'] . "</a></center></td></tr>
    }
  }
else
  {
   while ($row = mysql_fetch_array($result))
    {
     if ($page == $row['id'])
      {
       echo "<center><font size='5'><b>" . $row['title'] . "</b></font></center><br><br>";
       echo "<center><a href='index.php?pg=news&np=home'>[return to articles]</a></center><br><br>";
       echo "<p>" . $row['body'] . "<br><br>";
       echo "<center><a href='index.php?pg=news&np=home'>[return to articles]</a></center>
      }
    }
  }
?>

 

When I used a similar if statement to check login information for an editing tool I made (thankfully that is funtioning as intended) it didn't have any problems.

 

As always, I appreciate the help :)

Link to comment
https://forums.phpfreaks.com/topic/192646-error-dont-know-cause/
Share on other sites

You're forgetting "; on this line:

 

echo "<tr><td><center><a href='index.php?pg=news&np=" . $row['id'] . "'>" . $row['title'] . "</a></center></td></tr>

 

Should be:

 

echo "<tr><td><center><a href='index.php?pg=news&np=" . $row['id'] . "'>" . $row['title'] . "</a></center></td></tr>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.