Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

problem of scripts on this page

Links for php scripts

Moderators: macek, egami, gesf

problem of scripts on this page

Postby begeiste » Fri Apr 15, 2005 4:05 pm

Parse error: parse error in c:\program files\easyphp1-8\www\charlton\connect_2.php on line 88

Don't know why this happened, even I tried to fix what was implying of the error message, it is still wrong. Here is the codes:
<?php
session_start();
//if the index entered is set (not null)
if (isset($_SESSION['entered'])){
//print it
echo $_SESSION['entered'];
}
//if index'submit' is set and true and if index 'enter' is not set then
if( (isset($_POST['submit']) &&($_POST['submit'])) && !isset($_SESSION['entered']) ){
echo 'Form submitted';
$_SESSION['entered']=true;
}
//else if index ''submit is set and true and index 'entered' is set and is true, then
elseif(( (isset($_POST['submit'])) && ($_POST['submit']))&&( (isset($_SESSION['entered'])) && ($_SESSION['entered']=="true"))){
echo 'You already submitted the form.';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<style type="text/css">
<!--
.result {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
padding-top: 5px;
border: 1px solid #660000;
padding-bottom: 5px;
padding-left: 10px;
width:50%;
}
.record {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #333333;
padding-left: 0px;
width:48%;
border-bottom: 1px solid #ccc;
}
.formtab {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
width:20%;
color: #FF9900;
background-color: #660000;
padding-left:5px;
}
.dele {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
color: #660000;
padding-left: 10px;
border-bottom: 1px solid #ccc;
text-decoration: underline;
}
-->
</style>
</head>

<body>

<?php if (isset($_GET['addlove']))://user wants to add a loving text?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<label class="formtab">Type your loving words here:<br>
<textarea name="lovetext" rows="10" cols="40"></textarea><br>
</label>
Name:<input type="text" name="authorname"><br>
Email:<input type="text" name="authoremail"><br>
<input type="submit" value="SUBMIT">
</form>
<?php else:// Default page display
//Connect to the database server
$db =@mysql_connect('localhost','root','');
if(!$db){
exit('<p>Unable to connect to the'.'database server at this time.</p>');
}
//Select the godblessing database
if(!@mysql_select_db('godblessing')){
exit('<p>Unable to locate the love'.'database at this time.</p>');
}
//if a loving text has been submitted,
//add it to the database.
if(isset($_POST['lovetext']) && isset($_POST['authorname']) && isset($_POST['authoremail'])) {
$lovetext=$_POST['lovetext'],
$authorname=$_POST['authorname'],
$authoremail=$_POST['authoremail'];
$sql="INSERT INTO love SET
lovetext='$lovetext',
authorname='$authorname',
authoremail='$authoremail',
lovedate=CURDATE()";
if (@mysql_query($sql)){
echo'<p class="record"> Your loving text has been added.</p>';
}
else{
echo '<p class="record">Error adding submitted love:'.mysql_error().'</p>';
}
}
//if a love has been deleted
//remove it from the database
if(isset( $_GET[ 'deletelovetext'])){
$id=$_GET['deletelovetext'];
$sql="DELETE FROM love WHERE id=$id";
if(@mysql_query($sql)){
echo'<p class="record">The loving word has been deleted.</p>';
}
else{
echo'<p class="record">Error deleting lovetext:'.'mysql_error()'.'</p>';
}
}
?>

<p class="result">Here are all the love in our database:</p>
<blockquote>
<?php
//request the text of all the loves
$result=@mysql_query('SELECT id, lovetext,authorname,authoremail FROM love');
if(!$result){
exit('<p>Error performing query:'.mysql_error().'</p>');
}
//Display the text of each love in a paragraph
while($row=mysql_fetch_array($result)){
$id=$row['id'];
$authorname=$row['authorname'];
$authoremail=$row['authoremail'];
$lovetext=$row['lovetext'];
echo '<p class="record">'.$lovetext.'<a href="'.$_SERVER['PHP_SELF'].'?deletelovetext='.$id.'"><span class="dele">delete</span></a></p>';
echo '<p class="record">'.$authorname.'<a href="'.$_SERVER['PHP_SELF'].'?deletelovetext='.$id.'"><span class="dele">delete</span></a></p>';
echo '<p class="record">'.$authoremail.'<a href="'.$_SERVER['PHP_SELF'].'?deletelovetext='.$id.'"><span class="dele">delete</span></a></p>';

}
//when clicked, this link will load this page
//with the love submission form displayed
echo'<p class="record"><a href="'.$_SERVER['PHP_SELF'].'?addlove=1">Add your loving text!</a></p>';
endif;
?>
</blockquote>
</body>
</html>
begeiste
New php-forum User
New php-forum User
 
Posts: 83
Joined: Thu Jun 03, 2004 11:27 am

Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.