FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


FriHost PHP Parser doesn´t work?





x-stream
At the moment, I am coding my website (Frihost, of course) in PHP.
Usually, the works very fine. But yesterday I coded a page, and i forgot to type an ";" after my last command ("echo"). The parser did nothing!
It didn´t say s.th. like "unexpected T_END"! Why?

And now, I´ve got another Problem, I´ll post the code...
x-stream
So, here it is:

Code:
<?php
include "header.php";
include "functions.php";
dbconnect('login');
  $sql = "SELECT * FROM `users` WHERE `name`='".$_GET['user']."';";
  $result = mysql_query($sql) or die("Benutzer falsch!");
  $db = mysql_fetch_assoc($result) or die("Fehler aufgetreten!");

echo ("<table border=\"3\" cellspacing=\"5\">
      <tr>
       <td>Vorname: </td>
       <td align=\"\">".$db['vorname']." </td>
      </tr>
      <tr>
       <td>Nachname: </td>
       <td align=\"\">".$db['nachname']." </td>
      </tr>
      <tr>
       <td>Spitzname: </td>
       <td align=\"\">".$db['spitzname']." </td>
      </tr>
      <tr>
       <td>Geburtsdatum: </td>
       <td align=\"\">".$db['geburtstag']." </td>
      </tr>
      <tr>
       <td>Wohnort: </td>
       <td align=\"\">".$db['wohnort']." </td>
      </tr>
      <tr>
       <td>PLZ: </td>
       <td align=\"\">".$db['postleitzahl']." </td>
      </tr>
      <tr>
       <td>Straße: </td>
       <td align=\"\">".$db['strasse']." </td>
      </tr>
      <tr>
       <td>Telefonnummer: </td>
       <td align=\"\">".$db['telefonnummer']." </td>
      </tr>
      <tr>
       <td>Handynummer: </td>
       <td align=\"\">".$db['handynummer']." </td>
      </tr>
      <tr>
       <td>eMail: </td>
       <td align=\"\">".$db['email']." </td>
      </tr>
      <tr>
       <td>ICQ: </td>
       <td align=\"\">".$db['icq']." </td>
      </tr>
      <tr>
       <td>Homepage: </td>
       <td align=\"\"> ".$db['homepage']." </td>
      </tr>
      <tr>
       <td>Persönlicher Text:</td>
       <td>".$db['text']."</td>
      </tr>
");


echo ("End");



include "footer.php";


Do you recognize any mistake?
So, what the parser does, is to echo
"end"
before echoing the table!!
but the echo("end"); command comes after the table! I can´t find the problem!!!
n0obie4life
You put the
Code:
echo "End";
after it parases the table. Put that code above
Code:
$sql = "SELECT * FROM `users` WHERE `name`='".$_GET['user']."';";
instead.
x-stream
You mean I should test something like this:
[quote=Code]
<?php
include "header.php";
include "functions.php";
dbconnect('login');
echo ("End");
$sql = "SELECT * FROM `users` WHERE `name`='".$_GET['user']."';";
$result = mysql_query($sql) or die("Benutzer falsch!");
$db = mysql_fetch_assoc($result) or die("Fehler aufgetreten!");

echo ("<table border=\"3\" cellspacing=\"5\">
<tr>
<td>Vorname: </td>
<td align=\"\">".$db['vorname']." </td>
</tr>
<tr>
<td>Nachname: </td>
<td align=\"\">".$db['nachname']." </td>
</tr>
<tr>
<td>Spitzname: </td>
<td align=\"\">".$db['spitzname']." </td>
</tr>
<tr>
<td>Geburtsdatum: </td>
<td align=\"\">".$db['geburtstag']." </td>
</tr>
<tr>
<td>Wohnort: </td>
<td align=\"\">".$db['wohnort']." </td>
</tr>
<tr>
<td>PLZ: </td>
<td align=\"\">".$db['postleitzahl']." </td>
</tr>
<tr>
<td>Straße: </td>
<td align=\"\">".$db['strasse']." </td>
</tr>
<tr>
<td>Telefonnummer: </td>
<td align=\"\">".$db['telefonnummer']." </td>
</tr>
<tr>
<td>Handynummer: </td>
<td align=\"\">".$db['handynummer']." </td>
</tr>
<tr>
<td>eMail: </td>
<td align=\"\">".$db['email']." </td>
</tr>
<tr>
<td>ICQ: </td>
<td align=\"\">".$db['icq']." </td>
</tr>
<tr>
<td>Homepage: </td>
<td align=\"\"> ".$db['homepage']." </td>
</tr>
<tr>
<td>Persönlicher Text:</td>
<td>".$db['text']."</td>
</tr>
");






include "footer.php";
?>
[/quote]
Daniel15
Try putting
Code:
error_reporting(E_ALL);
at the top of the page. This will report all errors (the default is report all errors except notices). See if you get any errors then.
n0obie4life
@x-stream

Yes, from your description of your problem, I think you want that.

And please use the
Code:
[code][/code]
tags instead of quote tags Wink
Stubru Freak
Code:
</table>
Kaneda
Stubru freak said it... It's not the PHP parser doing something wrong, it's your HTML that's wrong. If you look at the HTML source, you'll see it's output exactly as you told PHP to output it - with "end" coming after the table HTML.

The problem is that if you don't close a <table> element, any HTML after it will be rendered before the table. You'll get the same result in pure HTML:

Code:
<html>
<head>
  <title>Test</title>
</head>
<body>
  <table>
    <tr>
      <td>Cell 1</td>
      <td>Cell 2</td>
    </tr>
    <tr>
      <td>Cell 3</td>
      <td>Cell 4</td>
    </tr>
  <!-- missing table end tag -->
  <p>After table, but rendered before it.</p>
</body>
</html>


It's a sideeffect of how browsers render tables (and one of the reasons why tables are mostly inefficient for layouts). A table can't be rendered until the end tag </table> is reached (because the browser can't know the width of each column until it knows the content of each cell). So most browsers will render anything that isn't a table cell - but still occurs before the table is ended - before the table cells themselves.

Oh, and about the semicolon...

Quote:
But yesterday I coded a page, and i forgot to type an ";" after my last command ("echo"). The parser did nothing!
It didn´t say s.th. like "unexpected T_END"! Why?


Nothing wrong with the PHP parser. The semicolon in PHP isn't a statement terminator (i.e., it doesn't have to occur after every statement in your script, as it does in, say, C/C++). It's a statement separator. So, in some cases, it's not an error to leave it out, such as after the last line in a script.

Doesn't mean it's not a good idea to still have a semicolon in your last statement (just to avoid confusion when you later add a new statement after it).
x-stream
Thanks a lot, I´ll try it out...
x-stream
Yes, it worked! Thanks again!
You can now -close- the thread!
Related topics
Does anyone know if PHP-Nuke works for freehosting?
PHP Editor in Frihost Direct Admin Server?
Using databases
FriHost - Google Rankings
Try method in php does not work
PHP-Server at localhost
DBI.pm & DBD::mysql
FriHost php Configuration
PHP with Frihost [need help]
Getting PHP variable to work in FCKeditor
Textbox Submit to email
What PHP software works well on FriHost especially forum PHP
How to write PHP
Frihost PHP Account
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.