php help

  • deathblade
  • Proficient
  • Proficient
  • User avatar
  • Joined: Mar 08, 2007
  • Posts: 417
  • 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 :)

Code: [ Download ] [ Select ]
$result = mysql_query("SELECT * FROM news ORDER BY ID desc");
echo "<div  style='background-image:url(images/news_bar.gif); width:auto; height:auto'>&nbsp;</div>";
 
while($row = mysql_fetch_array($result))
  {
  echo "<div style='width:auto; height:auto'>" . $row['Title'] . "~~~" . $row['Date'] . "</div>";
  echo "<br />"
  echo "<div>" . $row['Comment'] . "</div>";
  }
mysql_close($con);
?>
  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
Code: [ Download ] [ Select ]
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: Jul 14, 2005
  • Posts: 7128
  • Loc: Ozzuland
  • Status: Offline

Post July 8th, 2008, 2:59 pm

Code: [ Download ] [ Select ]
$result = mysql_query("SELECT * FROM news ORDER BY ID desc");
echo "<div style='background-image:url(images/news_bar.gif); width:auto; height:auto'>&nbsp;</div>";

while($row = mysql_fetch_array($result))
{
echo "<div style='width:auto; height:auto'>" . $row['Title'] . "~~~" . $row['Date'] . "</div>";
echo "<br />";
echo "<div>" . $row['Comment'] . "</div>";
}
mysql_close($con);
?>
  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. while($row = mysql_fetch_array($result))
  4. {
  5. echo "<div style='width:auto; height:auto'>" . $row['Title'] . "~~~" . $row['Date'] . "</div>";
  6. echo "<br />";
  7. echo "<div>" . $row['Comment'] . "</div>";
  8. }
  9. mysql_close($con);
  10. ?>

You forgot that red ; in there (I put that thing in)
Learn PHP | I got 10 PHP tutorials! Check them out!
Dreamtale - Farewell
Just a note... I've giving up on web development and that stuff... Just lost all interest in it.
  • deathblade
  • Proficient
  • Proficient
  • User avatar
  • Joined: Mar 08, 2007
  • Posts: 417
  • 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: Jul 14, 2005
  • Posts: 7128
  • 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...
Learn PHP | I got 10 PHP tutorials! Check them out!
Dreamtale - Farewell
Just a note... I've giving up on web development and that stuff... Just lost all interest in it.
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 29, 2007
  • Posts: 456
  • 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: Jul 14, 2005
  • Posts: 7128
  • 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...).
Learn PHP | I got 10 PHP tutorials! Check them out!
Dreamtale - Farewell
Just a note... I've giving up on web development and that stuff... Just lost all interest in it.
  • spork
  • HB
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 5485
  • 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.
How to Maintain Simple, Static Pages in a CakePHP Application
EEEEEEEEE! It's here!!
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 29, 2007
  • Posts: 456
  • 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: Jul 14, 2005
  • Posts: 7128
  • 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++
Learn PHP | I got 10 PHP tutorials! Check them out!
Dreamtale - Farewell
Just a note... I've giving up on web development and that stuff... Just lost all interest in it.
  • deathblade
  • Proficient
  • Proficient
  • User avatar
  • Joined: Mar 08, 2007
  • Posts: 417
  • 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: Jul 14, 2005
  • Posts: 7128
  • Loc: Ozzuland
  • Status: Offline

Post July 11th, 2008, 8:53 pm

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

What are you complaining about? :)
Learn PHP | I got 10 PHP tutorials! Check them out!
Dreamtale - Farewell
Just a note... I've giving up on web development and that stuff... Just lost all interest in it.

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 162 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.