logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Parse error...Error on line <LINE#>???
Author
kr33



Joined: 19 Sep 2006
Posts: 64
Location: South Africa

PostPosted: Tue 26 Sep '06 10:24    Post subject: Parse error...Error on line <LINE#>??? Reply with quote

Hi, I'm back

I've solved most of my problems, now theres another problem.

I wrote a script to query the database and display it using tables,

I am using the heredoc method for creating the rows dynamically.

My code seems fine, logically and my syntax seems fine. But it tells me that there is a parse error on line 98, but my last line of code, where i close the php section with ?> is on line 97. I don't know what could be the problem.

Any advice?

Thanks

Quote:
Everyman has to go through hell...to reach his paradise
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7360
Location: Germany, Next to Hamburg

PostPosted: Tue 26 Sep '06 10:38    Post subject: Reply with quote

Heredoc style is fine to use. It allows nice coding without lookibf for the quotes. To the Problem

Code:

echo <<<END
new bla;
bla->bla();
<a href="$blub">blub</a>
END;


The last statement END; in this example must be in very beginning of a line
no space and no tab. It is very worse that PHP do not find the end if there is a space... Confused I hate that! On a large code with tabs for codecleanes that gettin' on my nervs!
Back to top
kr33



Joined: 19 Sep 2006
Posts: 64
Location: South Africa

PostPosted: Tue 26 Sep '06 12:17    Post subject: Reply with quote

I will try that, thanks.

But come to think of it my code is as follows :
Code:

while ($row = mysql_fetch_array($query_d)) {
       $movie_n = $row['movie_name'];
       $movie_d = $row['movie_director'];
       $movie_a = $row['movie_leadactor'];

       $movie .=<<<EOD
          <tr>
              <td>$movie_n</td>
              <td>$movie_d</td>
              <td>$movie_a</td>
          </tr>
       EOD;
}


My code is indented like how i've type it above, I did not code like the following:
Code:

while ($row = mysql_fetch_array($query_d)) {
$movie_n = $row['movie_name'];
$movie_d = $row['movie_director'];
$movie_a = $row['movie_leadactor'];

$movie .=<<<EOD
  <tr>
  <td>$movie_n</td>
  <td>$movie_d</td>
  <td>$movie_a</td>
  </tr>
EOD;
}


Which way does it or should it be? The first code snippet or the second code snippet?

Thanks
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7360
Location: Germany, Next to Hamburg

PostPosted: Tue 26 Sep '06 12:30    Post subject: Reply with quote

it can be like

Code:

while ($row = mysql_fetch_array($query_d)) {
       $movie_n = $row['movie_name'];
       $movie_d = $row['movie_director'];
       $movie_a = $row['movie_leadactor'];

       $movie .=<<<EOD
          <tr>
              <td>$movie_n</td>
              <td>$movie_d</td>
              <td>$movie_a</td>
          </tr>
EOD;
//only this EOD; need to be with no space
}


Find your own way Wink only make sure that you can read the code fast, even when haven't read it more than one year.



Don't copy the code from the forum. Don't kow why, but it don't work when paste post in forum & copy and paste and rty. Shocked

Also be fast would be in-line coding


I am a bit confused! Why do you use here doc for a string? Here doc is for echo'ing. The example below would also work. Formating will be saved!

Code:

while ($row = mysql_fetch_array($query_d)) {
       $movie_n = $row['movie_name'];
       $movie_d = $row['movie_director'];
       $movie_a = $row['movie_leadactor'];

       $movie .="
          <tr>
              <td>$movie_n</td>
              <td>$movie_d</td>
              <td>$movie_a</td>
          </tr>
";
}


Much easier is a direct output

Code:

while ($row = mysql_fetch_array($query_d)) {
       $movie_n = $row['movie_name'];
       $movie_d = $row['movie_director'];
       $movie_a = $row['movie_leadactor'];
?>

          <tr>
              <td><?php echo $movie_n; ?></td>
              <td><?php echo $movie_d; ?></td>
              <td><?php echo $movie_a; ?></td>
          </tr>
<?php
}
Back to top
kr33



Joined: 19 Sep 2006
Posts: 64
Location: South Africa

PostPosted: Tue 26 Sep '06 12:38    Post subject: Reply with quote

Thanks a million....I just hope to get php wrapped around my finger Wink
Back to top


Reply to topic   Topic: Parse error...Error on line <LINE#>??? View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner