Jump to content

Perhaps a Simple Synatax Error


Sware

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]
Link to comment
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
Link to comment
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.
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.