php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger > PHP Tipps 2004

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 18.09.2004, 12:42  
Gast
 
Beiträge: n/a
Standard Parse error: unexpected $end ... on line xy

Hallo zusammen

Ich habe in eurem Forum viel gestöbert, konnte aber mein Problem dennoch nicht lösen.

Ich hab ein kleines Gästebuch geschrieben und bekomme stets folgende Fehlermeldung wenn ich die Datei view.php aufrufe:
Zitat:
Parse error: parse error, unexpected $end in C:\Program Files\Apache Group\Apache2\htdocs\guestbook2k\header.php on line 221
Die view.php Datei soll es mir ermöglichen Gästebucheinträge anzusehen.
Code von view.php:
Zitat:
<?php

include "header.php"; // includes main functions for the guestbook2k

?>

<table border=0>

<?php

if (empty($offset)) { $offset = 0; }
$preserve ="";
while ($row = mysql_fetch_array($result))
{
print_entry($row,$preserve,"name","location","emai l","URL","entry date","comments");
print "<tr><td colspan=2></td></tr>\n";
}
mysql_free_result($result);
?>
</table>
<?php
nav($offset);
?>
Und die header.php verwaltet mein Gästebuch
Code von header.php:
Zitat:
<?php

include("$DOCUMENT_ROOT/functions/charset.php");
include("$DOCUMENT_ROOT/functions/basic.php");
?>
<?php
$conn = mysql_connect("localhost", "root", "Chie5pha") or
die("Could not connect to database! Please try again later");
mysql_select_db("guestbook2k", $conn) or
die("Could not select guestbook2k");

define("PAGE_LIMIT", 2); /*defines a constant named PAGE_LIMIT
with value 2, the constant is everywhere
available, without declaring it as global */

##################################################
# Function: print_entry() #
# Creator: Antoine Hauck #
# Create date: 15.09.2004 #
# Origin use: guestbook2k #
##################################################
# This prints the results of a query within #
# a table #
##################################################

function print_entry($row,$preserve="")
{
$numargs = func_num_args(); /* retrieves the number of arguments of the function
the first argument will be indicated as 0 */
for ($i = 2; $i < $numargs; $i++)
{
$field = func_get_arg($i); /* the value of each function argument can be
accessed with fung_get_arg() */
$dbfield = str_replace(" ", "_", strtolower($field)); /* makes $field lowercase and replaces spaces
with underlines */
$dbvalue = cleanup_text($row[$dbfield],$preserve); //clean up the text with the cleanup_text() from $dbfield
$name = ucwords($field); //makes the first letter of each word uppercase
print " <tr>\n";
print " <td valign=top align=right>$name:</td>\n"; //prints a table with the column names of the table
print " <td valign=top align=left>$dbvalue</td>\n"; //and the according values
print " </tr>\n\n";
}
}

##################################################
# Function: print_input_fields() #
# Creator: Antoine Hauck #
# Create date: 15.09.2004 #
# Origin use: guestbook2k #
##################################################
# This function prints input fields (e.g. name, #
# location, url etc.) from the specified table #
# columns #
##################################################

function print_input_fields()
{
$fields = func_get_args(); /* makes $field an array, each element of which
is an argument sent to the function */
while (list($index,$field) = each($fields)) /* the list structure moves through all elements
in the array and prints a text field for each */
{
print " <tr>\n";
print " <td valign=top align=right>" //The name of the field will be in one table cell,
.ucfirst($field).":
</td>\n";
print "<td valign=top align=left><input type=text " //and the input box will be in an adjoining cell
."name=$field size=40 value=\""
.$GLOBALS["last_$field"]."\"></td>\n";
print " </tr>\n\n";
}
}

##################################################
# Function: create_entry() #
# Creator: Antoine Hauck #
# Create date: 15.09.2004 #
# Origin use: guestbook2k #
##################################################
# Verifies the entered information and puts it #
# into the database after succeeded verification #
##################################################

function create_entry($name,$location,$email,$url,$comments )
{
$name = cleanup_text($name);
$location = cleanup_text($location);
$email = cleanup_text($email); //cleanup_text() removes HTML tags and
$url = cleanup_text($url); //escape special characters (e.g. & and ")
$comments = cleanup_text($comments);

$errmsg = ""; /* starts with an empty error message, if a
validation test fails, an error message will be
added to $errmsg */

if (empty($name)) //Checks if a name was entered
{
$errmsg .= "[*]You didn't enter a name!\n";
}

//verifies the format of $email, it must be xyz@zyx.xy
if (empty($email) || !eregi("^[A-Za-z0-9\_.-]+@[A-Za-z0-9\_-]+.[A-Za-z0-9\_-]+.*", $email))
{
$errmsg .="[*]$email doesn't look like a valid email address\n";
}
else
{
/* If the format is OK, check to see if a user (with the same $email) has already signed the guestbook
Multiple entries are not allowed! */
$query = "select * from guestbook where email ='$email'"; /* looks after entries in the database where
email = $email */
$result = safe_query($query);
if (mysql_num_rows($result) > 0) //if a result is found with $email, you got
{ //an error
$errmsg .="$email has already signed this guestbook!\n";
}
}

//perform a very simple check on the format of the url supplied by the user (if any)
if (!empty($url) && !eregi("^http://[A-Za-z0-9\%\?\_\:\~\/\.-]+$",$url))
{
$errmsg .="[*]$url doesn't look like a valid URL. Don't forget the \"http://\"\n";
}

if (empty($errmsg)) //If no error found insert data to database
{
$query = "insert into guestbook " //mySQL query: inserts the data into the database
." (name,location,email,url,comments,remote_addr) values "
."('$name', '$location', '$email', '$url', '$comments', '$REMOTE_ADDR')"
;
safe_query($query);

print "<h2>Thanks, $name!</h2>\n";
}
else
{
print <<<EOQ



<font color=red>
[b]
<ul>
$errmsg
[/list] //if an error occurs: prints the error message
Please try again
</p>
EOQ;
}
return $errmsg;
}

##################################################
# Function: select_entries() #
# Creator: Antoine Hauck #
# Create date: 16.09.2004 #
# Origin use: guestbook2k #
##################################################
# This function calls the database entries #
##################################################

function select_entries ($offset=0)
{
if (empty($offset)) { $offset = 0; } //defines an offset of 0, if no one was given

$query = "select *, date_format(created,'%e %M, %Y %h:%i %p') " //date_format retrieves "created" in a readable way
."as entry_date from guestbook order by created " //Selects the DB entries sorted by creation date
."desc limit $offset, " . PAGE_LIMIT //PAGE_LIMIT limits the number of fields to be shown
;
$result = safe_query($query);

return $result;
}

##################################################
# Function: nav() #
# Creator: Antoine Hauck #
# Create date: 18.09.2004 #
# Origin use: guestbook2k #
##################################################
# This function creates navigational elements. #
# When appropriate, this function will insert #
# links that will enable the user to view the #
# the next set of entries, the previous entries, #
# or both. It's all determined by the £offset #
# variable and the PAGE_LIMIT constant #
##################################################

function nav ($offset=0, $this_script="")
{
global $PHP_SELF;

if (empty($this_script)) { $this_script = $PHP_SELF; }
if (empty($offset)) { $offset = 0; }

// Get the total number of entries in the guestbook,
// to know if there are more entries which must be shown
$result = safe_query("select count(*) from guestbook");
list($total_rows) = mysql_fetch_array($result);

print "

\n";
if ($offset > 0)
{
// If we're not on the first row, it will insert a link,
// that will enable the user to view the previous set of entries
print "<a href=\"$this_script?offset=".($offset-PAGE_LIMIT)
."\">&lt;&lt;Previous Entries</a> ";
}
if ($offset+PAGE_LIMIT < $total_rows)
{
// offset + PAGE_LIMIT gives us the maximum record number
// that we could have displayed on this page. If it's less
// than the total number of rows of entries, that means
// there are more entries to see, and we can go forward
//
// It will insert a link, that will enable the user
// to view the next set of entries
print "<a href=\"$this_script?offset=".($offset+PAGE_LIMIT)
."\">Next Entries&gt;&gt;</a> ";
}
print "</p>\n";
}

?> DAS IST DIE VERFLIXTE LINIE 221
In der header.php verweise ich auf die basic.php (hier sind meine Basisfunktionen fürs Gästebuch.
Code von basic.php:
Zitat:
<?php

##################################################
# Function: authenticate() #
# Creator: Antoine Hauck #
# Create date: 15.09.2004 #
# Origin use: guestbook2k #
##################################################
# The authenticate function sends only a header #
# to the browser. It doesn't check the values #
# entered in the textboxes. They' re checked in #
# the guestbook2k/authenticate.php file #
##################################################

function authenticate ($realm="Secure Area"
,$errmsg="Please enter a username and password"
)
{
Header("WWW-Authenticate: Basic realm=\"$realm\"");
Header("HTTP/1.0 401 Unauthorized");
die($errmsg);
}

##################################################
# Function: cleanup_text() #
# Creator: Antoine Hauck #
# Create date: 15.09.2004 #
# Origin use: guestbook2k #
##################################################
# This function makes sure we don't insert #
# malicious text into the database #
##################################################

function cleanup_text ($value = "", $preserve="", $allowed_tags="")
{
if (empty($preserve))
{
$value = strip_tags($value, $allowed_tags); //all HTML tags will be removed, except
} //$allowed_tags
$value = htmlspecialchars($value); //changes & and " to proper HTML entities
//(e.g. &amp; and &quot
return $value;
}

##################################################
# Function: safe_query() #
# Creator: Antoine Hauck #
# Create date: 15.09.2004 #
# Origin use: guestbook2k #
##################################################
# This function checks a mySQL query and gives #
# and gives you detailed information, when a #
# query fails #
##################################################

function safe_query ($query = "")
{
if (empty($query)) {return FALSE; }
$result = mysql_query($query)
or die("ack! query failed: "
."[*]errorno=".mysql_errno() //gives detailed
."[*]error=".mysql_error() //information about the error
."[*]query=".$query
);
return $result;
}
?>
Ich weiss nicht mehr weiter, die geschweiften Klammern scheinen richtig gesetzt zu sein.

Ich wäre für jeden nützlichen Tipp sehr dankbar.

Gruss
xenos1983
 
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 18.09.2004, 12:46  
Gast
 
Beiträge: n/a
Standard

ich mag mir das jetzt nicht alles durchlesen, aber ohne nachzugucken probiere ich es meist erstmal mit einem zusätzlichen } ganz ans ende der datei.
 
Alt 18.09.2004, 13:18  
Gast
 
Beiträge: n/a
Standard

Ne, eine Klammer fehlt nicht. Das hab ich gecheckt.
Ich kann da aber auch nicht helfen. Der Code beinhaltet Anweisungen, die ich nicht kenne und ich habe jetzt auch keine Lust mich da einzulesen.

Dieser Block gibt mir aber etwas zu denken.
Zitat:
print <<<EOQ



<font color=red>
[b]
<ul>
$errmsg[/list]//if an error occurs: prints the error message
Please try again
</p>
EOQ;
 
 


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
[Erledigt] PHP -&gt; Ordner anlegen der sich auch beschreiben lässt?! Nightuser PHP Tipps 2008 13 30.06.2008 23:51
Parse error: syntax error, unexpected $end in D:\xampp\htdoc PHP Tipps 2005-2 11 11.10.2005 17:05
Suche Tipps für Persormance-Steigerung (Geld für Nützliches) Beitragsarchiv 18 16.08.2005 10:57
Suche Programmierer, Designer, Schreiber... blinkster.de Beitragsarchiv 76 14.08.2005 18:31
parse error, unexpected T_IF in..... on line 51 matthros PHP Tipps 2005-2 28 28.07.2005 12:52
parse error on line 4 PHP Tipps 2005-2 5 16.07.2005 11:22
parse error on line 11 Komm nicht weiter Datenbanken 4 06.06.2005 13:20
update auf php 5.0.4 robo47 Server, Hosting und Workstations 6 10.04.2005 19:00
ShowIt_V1.8.14 PHP Tipps 2005 1 23.03.2005 19:13
parse error, unexpected $end in.. ==> Editor gesucht PHP Tipps 2005 3 03.03.2005 16:01
Counter zeigt nach ca. 2-3 Stunden fehler an PHP Tipps 2004 2 26.08.2004 20:08
Parse error: parse error, unexpected $end PHP Tipps 2004 2 24.08.2004 16:28
Script Problem: parse error unexpected $end PHP Tipps 2004 5 02.08.2004 13:25
Parse error: parse error, unexpected $end PHP Tipps 2004 5 13.07.2004 14:34
Parse Error, unexpected '{' in line 34 PHP Tipps 2004 2 15.06.2004 07:04

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
<<<eoq <script> unexpected t_sl php, unexcepted $end in line, \if (empty($preserve))\, unexpected $end in php in header, parse error syntax error unexpected $end in on line, php x y line, antoine hauck, parse error: parse error, unexpected \'>\' line 11, include \../functions/charset.php\;, parse first 3 lines, email_url & &amp;#, parse error: syntax error, unexpected \',\' in c:\\xampp\\htdocs\\includes\\functions\\database.php on line 13, php function unexpected $end

Alle Zeitangaben in WEZ +2. Es ist jetzt 03:58 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum

Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.