Jump to content


Photo

Perhaps a Simple Synatax Error


  • Please log in to reply
2 replies to this topic

#1 Sware

Sware
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 03 July 2006 - 08:16 PM

<?PHP                //MYSQL CONNECTION
$dbh=mysql_connect ("localhost", "XXXX", "XXXXXX") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("sware_phpb2");

$query = "SELECT phpbb_users.username, phpbb_posts_text.post_subject, phpbb_posts_text.post_text, phpbb_posts.post_id, phpbb_posts.topic_id, phpbb_posts.forum_id FROM phpbb_users JOIN phpbb_posts ON phpbb_posts.poster_id = phpbb_users.user_id JOIN phpbb_posts_text ON phpbb_posts.post_id = phpbb_posts_text.post_id ORDER BY post_id DESC";
	 
$result = mysql_query($query) or die(mysql_error());


// Contents 
while($row = mysql_fetch_array($result)){
	echo "<br>";
    echo "<table border="0" cellpadding="0" cellspacing="2" width="510" class="pageoutline">";
          echo "<tr>";
            echo "<td width="504" height="19" valign="top" bgcolor="#A3C159"><div align="center" class="navtitle">";
              echo "<div align="center">". $row['post_subject'] ."</div>";
            echo "</div></td>";
            echo  "</tr>";
          echo "<tr>";
            echo "<td height="45" valign="top">"";
			echo "Posted By:". $row['username'] .".";
              echo "<p align="center">". $row['post_text'] .";
                echo "<br>";
             echo  "</tr>";
          echo "</table>";
		  }
?>


It says
Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/sware/public_html/test.php on line 13

Line 13 is
    echo "<table border="0" cellpadding="0" cellspacing="2" width="510" class="pageoutline">";


#2 bearruler

bearruler
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 03 July 2006 - 08:31 PM

When you echo a line, you cant have quotes in that line. php will see those quotes as ending the text its echoing, and going back into php syntax
To echo a quote character, use \"

echo "<table border="0" cellpadding="0" cellspacing="2" width="510" class="pageoutline">";
Should be
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"510\" class=\"pageoutline\">";
or
echo "<table border=0 cellpadding=0 cellspacing=2 width=510 class=pageoutline>";
or
?><table border="0" cellpadding="0" cellspacing="2" width="510" class="pageoutline"><?

And this is the mysql (database) forum. Syntax errors should go in the basic php help forum


Bear

www.KingdomsDivided.com

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 July 2006 - 09:44 PM

Or use singles for the outside and doubles on the inside.

echo '<table border="0" cellpadding="0" cellspacing="2" width="510" class="pageoutline">';

But agreed, this isn't a MySQL-related issue.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users