CK9 Posted February 19, 2010 Share Posted February 19, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/192646-error-dont-know-cause/ Share on other sites More sharing options...
Alex Posted February 19, 2010 Share Posted February 19, 2010 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/192646-error-dont-know-cause/#findComment-1014882 Share on other sites More sharing options...
CK9 Posted February 19, 2010 Author Share Posted February 19, 2010 *facepalm* once again I focus too much on the problem to see the cause. Thanks for pointing that out...and I did it again a few lines down, heh The page is working as it should *hug* Quote Link to comment https://forums.phpfreaks.com/topic/192646-error-dont-know-cause/#findComment-1014893 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.