Jump to content

[SOLVED] Syntax / Parse Error Help


The14thGOD

Recommended Posts

Hey, I'm working on my site and I cant seem to find the problem of:
Parse error: parse error, unexpected $ in testpage.php on line 187

here is the code that I added when i started seeing the problem:
[code] <?php
//Select comments table and see if there are any related to this art piece
//Put table/id in form MYSQL can read
$select_table = "art_$art_type";
$select_table .= "_comments";
$select_id = "$id";
$select_id .= "_id";
$com_query = "SELECT * FROM $select_table WHERE id='$select_id' AND status='enabled' ";
$com_result = mysql_query($com_query);
while($com_row = mysql_fetch_array($com_result)) {
echo("<div id=\"comment\"> \n");
//obtain username/avatar
$select_user = "SELECT username,avatar,signature FROM user WHERE id='$com_row[user_id]' ";
$select_result = mysql_query($select_user);
$select_row = mysql_fetch_array($select_result);
echo("<h2>$select_row[username]</h2> \n");
echo("<div id=\"section_a\"> \n");
echo("<img src=\"$select_row[avatar]\" alt=\"$select_row[username] avatar\" width=\"82\" height=\"82\" /></div> \n");
echo("<div id=\"section_b\" > \n");
echo("<p class=\"small_text_10\">Posted: $com_row[date]<span class=\"align_right\"><a href=\"edit_com.php\">Edit</a> | <a href=\"delete_com.php\">Delete</a></span></p> \n");
echo("<p class=\"borders\">$com_row[body]</p> \n");
echo("<p class=\"small_text_10\">$select_row[signature]</p></div> \n");
echo("</div> \n");
?>[/code]

I've looked for a while now and I've found some minor syntax errors but fixed those and it still seems to be giving me the problem. I've narrowed it down to this code also, I took out the code and it worked fine.

Thanks in advance for any help.
Link to comment
Share on other sites

Nope. Still nothing obvious. You realise that echo does not need its arguments wrapped in ( ) ? And also that complex variables should be wrapped within { } when within a double quotes string. eg;

[code=php:0]
echo("<h2>$select_row[username]</h2> \n");
[/code]

Should be....

[code=php:0]
echo "<h2>{$select_row['username']}</h2>\n";
[/code]
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.