php help

  • deathblade
  • Proficient
  • Proficient
  • User avatar
  • Joined: 08 Mar 2007
  • Posts: 414
  • Loc: u.k
  • Status: Offline

Post July 8th, 2008, 2:36 pm

hey back again this time it;s with calling data from a data base to display in divs :)

  1. $result = mysql_query("SELECT * FROM news ORDER BY ID desc");
  2. echo "<div  style='background-image:url(images/news_bar.gif); width:auto; height:auto'>&nbsp;</div>";
  3.  
  4. while($row = mysql_fetch_array($result))
  5.   {
  6.   echo "<div style='width:auto; height:auto'>" . $row['Title'] . "~~~" . $row['Date'] . "</div>";
  7.   echo "<br />"
  8.   echo "<div>" . $row['Comment'] . "</div>";
  9.   }
  10. mysql_close($con);
  11. ?>


give me

Parse error: parse error, unexpected T_ECHO, expecting ',' or ';' in /home/www/arc22.freehostia.com/news.php on line 26

line 26 is
  1. echo "<div>" . $row['Comment'] . "</div>";


:S.com
This is a block of text that can be added to posts you make. There is a 500 character limit.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 8th, 2008, 2:36 pm

  • Bogey
  • Disturbed
  • Genius
  • User avatar
  • Joined: 14 Jul 2005
  • Posts: 6646
  • Loc: Ozzuland
  • Status: Offline

Post July 8th, 2008, 2:59 pm

  1. $result = mysql_query("SELECT * FROM news ORDER BY ID desc");
  2. echo "<div  style='background-image:url(images/news_bar.gif); width:auto; height:auto'>&nbsp;</div>";
  3.  
  4. while($row = mysql_fetch_array($result))
  5.   {
  6.   echo "<div style='width:auto; height:auto'>" . $row['Title'] . "~~~" . $row['Date'] . "</div>";
  7.   echo "<br />";
  8.   echo "<div>" . $row['Comment'] . "</div>";
  9.   }
  10. mysql_close($con);
  11. ?>

You forgot that red ; in there (I put that thing in)
Matthew 7:12 - "Therefore all things whatsoever ye would that men should do to you, do ye even so to them: for this is the law and the prophets."
  • deathblade
  • Proficient
  • Proficient
  • User avatar
  • Joined: 08 Mar 2007
  • Posts: 414
  • Loc: u.k
  • Status: Offline

Post July 8th, 2008, 3:14 pm

oppy :/ haha thanks :oops:
This is a block of text that can be added to posts you make. There is a 500 character limit.
  • Bogey
  • Disturbed
  • Genius
  • User avatar
  • Joined: 14 Jul 2005
  • Posts: 6646
  • Loc: Ozzuland
  • Status: Offline

Post July 8th, 2008, 3:38 pm

deathblade wrote:
oppy :/ haha thanks :oops:

Yeah, just keep in mind that the parser when gives a Parse Error, the line the error is actually on is 1 before than provided...

So in this case, the parser said the error occurred on line 26 when it actually happened on line 25... it's because of how the parser parses the code...
Matthew 7:12 - "Therefore all things whatsoever ye would that men should do to you, do ye even so to them: for this is the law and the prophets."
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: 29 May 2007
  • Posts: 458
  • Loc: India
  • Status: Offline

Post July 10th, 2008, 10:09 pm

Bogey wrote:
Yeah, just keep in mind that the parser when gives a Parse Error, the line the error is actually on is 1 before than provided...

Just to clarify things: it's not always one before. Sometimes the reported line numbers can be far away from the actual error, sometimes it can be exactly where the error occurred.

When you miss a ; the parser thinks the statement is not yet complete, and only when it parses the next line, it finds an error.

In other cases, like when you misspell a function name or constant, the parser immediately knows something is wrong.

C and C++ can be much worse: I once got around 100 compilation errors because I missed a ; at the end of a class declaration.
Fotografix: A portable image editor
  • Bogey
  • Disturbed
  • Genius
  • User avatar
  • Joined: 14 Jul 2005
  • Posts: 6646
  • Loc: Ozzuland
  • Status: Offline

Post July 10th, 2008, 10:12 pm

casablanca wrote:
Bogey wrote:
Yeah, just keep in mind that the parser when gives a Parse Error, the line the error is actually on is 1 before than provided...

Just to clarify things: it's not always one before. Sometimes the reported line numbers can be far away from the actual error, sometimes it can be exactly where the error occurred.

When you miss a ; the parser thinks the statement is not yet complete, and only when it parses the next line, it finds an error.

In other cases, like when you misspell a function name or constant, the parser immediately knows something is wrong.

C and C++ can be much worse: I once got around 100 compilation errors because I missed a ; at the end of a class declaration.

lol about the C/++ error you got...

I know that about the parser error "generator"... I was just too lazy to write all of that up than... usually for me it is as I tend to make small stupid mistakes and post them here (lol), but I got a few difficult ones when the problem was way out on line 25 and it said it was on 55 (When I had sql queries in an array and it said there was a problem on the loop...).
Matthew 7:12 - "Therefore all things whatsoever ye would that men should do to you, do ye even so to them: for this is the law and the prophets."
  • spork
  • Rotaredom
  • Silver Member
  • User avatar
  • Joined: 22 Sep 2003
  • Posts: 5292
  • Loc: Rochester, NY
  • Status: Offline

Post July 10th, 2008, 11:06 pm

casablanca wrote:
C and C++ can be much worse: I once got around 100 compilation errors because I missed a ; at the end of a class declaration.

Heh... ever try debugging an STL error? Those things literally generate pages of error output.
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: 29 May 2007
  • Posts: 458
  • Loc: India
  • Status: Offline

Post July 11th, 2008, 3:59 am

spork wrote:
Heh... ever try debugging an STL error? Those things literally generate pages of error output.

:) Yes, but most of the stuff past the first line or two is usually junk.
Fotografix: A portable image editor
  • Bogey
  • Disturbed
  • Genius
  • User avatar
  • Joined: 14 Jul 2005
  • Posts: 6646
  • Loc: Ozzuland
  • Status: Offline

Post July 11th, 2008, 11:27 am

spork wrote:
casablanca wrote:
C and C++ can be much worse: I once got around 100 compilation errors because I missed a ; at the end of a class declaration.

Heh... ever try debugging an STL error? Those things literally generate pages of error output.

lol maybe I won't learn C/C++
Matthew 7:12 - "Therefore all things whatsoever ye would that men should do to you, do ye even so to them: for this is the law and the prophets."
  • deathblade
  • Proficient
  • Proficient
  • User avatar
  • Joined: 08 Mar 2007
  • Posts: 414
  • Loc: u.k
  • Status: Offline

Post July 11th, 2008, 4:02 pm

all that from a missing ";" :P
This is a block of text that can be added to posts you make. There is a 500 character limit.
  • Bogey
  • Disturbed
  • Genius
  • User avatar
  • Joined: 14 Jul 2005
  • Posts: 6646
  • Loc: Ozzuland
  • Status: Offline

Post July 11th, 2008, 8:53 pm

deathblade wrote:
all that from a missing ";" :P

What are you complaining about? :)
Matthew 7:12 - "Therefore all things whatsoever ye would that men should do to you, do ye even so to them: for this is the law and the prophets."

Post Information

  • Total Posts in this topic: 11 posts
  • Moderator: Moderator Team
  • Users browsing this forum: No registered users and 95 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.