Jump to content

Archived

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

Sware

Perhaps a Simple Synatax Error

Recommended Posts

[code]<?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>";
  }
?>[/code]


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

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

Share this post


Link to post
Share on other sites
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 \"

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

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


Bear

Share this post


Link to post
Share on other sites
Or use singles for the outside and doubles on the inside.

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

But agreed, this isn't a MySQL-related issue.

Share this post


Link to post
Share on other sites

×

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.