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

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.