Current location: Hot Scripts Forums » Programming Languages » PHP » parse error... help?


parse error... help?

Reply
  #1 (permalink)  
Old 01-20-04, 01:45 PM
kappler0's Avatar
kappler0 kappler0 is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
parse error... help?

Hello:

This should be a simple form script: but getting the following error:
Parse error: parse error in /home/cabling/public_html/provider_app/mmex.php on line 426

The code is as follows for mmex.php:
Any help is appreciated!
Scott
The code on line 426 is (just above database functions area): } // end $send_type
#================================================= ==========
# Register Globals
#================================================= ==========
$settings = $_REQUEST['settings'];
$refresh = $_REQUEST['refresh'];
$phone = $_REQUEST['phone'];
$email = $_REQUEST['email'];
$state = $_REQUEST['state'];
$zip = $_REQUEST['zip'];


#================================================= ==========
# Check for Settings
#================================================= ==========
header("Cache-control: private");
if(!$settings)
{
exit ("No settings were found for this form.");
}
include($settings);


#================================================= ==========
# Set Output Style
#================================================= ==========
if (!$font_size)
$font_size = '11pt'; // Default

if (!$font_color)
$font_color = '#000000'; // Default

if (!$font_weight)
$font_weight = 'none'; // Default

if (!$font_family)
$font_weight = 'arial'; // Default

$style .= '<span style="margin-left:12px;font-family:'.$font_family.';font-size:'.$font_size.';color:'.$font_color.';font_wei ght:'.$font_weight.'">';
$divstyle .= '<div style="margin-left:12px;font-family:'.$font_family.';font-size:'.$font_size.';color:'.$font_color.';font_wei ght:'.$font_weight.'">';


#================================================= ==========
# Error Messages
#================================================= ==========
$msg['authorized'] = "This site is not authorized to use this script.";
$msg['ipblocked'] = "Your IP address has been blocked.";
$msg['recent'] = "Recent entry. New submissions are allowed every $interval minute(s).";
$msg['norecipient'] = "This email cannot be sent. No specified recipient.";
$msg['required'] = "The following field(s) are required to be filled in before submission:";
$msg['formatted'] = "The following field(s) are required to be filled in with valid format before submission:";
$msg['flooderr'] = "There is an error with your Flood Control File.\r\nEither, the file name in the settings is incorrect or permissions are not set to 666.\r\n\r\nMail Manage EX";
$msg['iperr'] = "There is an error with your IP Address File.\r\nEither, the file name in the settings is incorrect or the file does not exist.\r\n\r\nMail Manage EX";
$msg['csverr'] = "There is an error with your CSV File.\r\nEither, the file name in the settings is incorrect, the file does not exist or permissions are not set to 666.\r\nr\nMail Manage EX";
$msg['filerr'] = "There is an error with your Flat File.\r\nEither, the file name in the settings is incorrect, the file does not exist or permissions are not set to 666.\r\nr\nMail Manage EX";

#================================================= ==========
# Check User's IP Address and Last Submission
#================================================= ==========
if ($flood_control)
{
$user_ip = $_SERVER['REMOTE_ADDR'];
$stamp = mktime();
$secs = $interval * 60;

@ $get=fopen($floodfile_name,'r');
if (!$get and $senderrors == 'yes')
mail($recipient,"Form Error",$msg['flooderr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
@ flock($get, LOCK_SH);
$flooddata = @ fread($get,999999);
$flooddata = explode("#",$flooddata);

for ($x=0;$x<count($flooddata);$x++)
{
$line = explode("|",$flooddata[$x]);
if ($user_ip == $line[0])
{
if (($stamp - $line[1]) < $secs)
exit ($style . $msg['recent'] . "</span>");
}
}
@ flock($get,LOCK_UN);
@ fclose($get);
}

#================================================= ==========
# Check if User's IP Address is Allowed
#================================================= ==========
if ($ip_block)
{
@ $read = fopen($ipfile_name,'r');
if (!$read and $senderrors == 'yes')
mail($recipient,"Form Error",$msg['iperr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
@ flock($read,LOCK_SH);
@ $data = fread($read,filesize($ipfile_name));
@ flock($read,LOCK_UN);
@ fclose($read);

$user_ip = $_SERVER['REMOTE_ADDR'];
if(stristr($data,$user_ip))
exit ($style . $msg['ipblocked'] . '</span>');
}

#================================================= ==========
# Post Values Depending on Php Version
#================================================= ==========
if (isset($HTTP_POST_VARS))
$_FORM = $HTTP_POST_VARS;
if (isset($_POST))
$_FORM = $_POST;
unset ($HTTP_POST_VARS);
unset ($_POST);
if ($email)
$sendemail = $email;
if ($preview)
$keepsettings = $settings;
$_FILEFORM = $_FORM;
$_DBASE = $_FORM;
$_CSVFORM = $_FORM;

#================================================= ==========
# Display Preview
#================================================= ==========
if ($preview and !$refresh)
{
$form .="$divstyle<b>Form Results Preview</b><hr></div>
<form style=\"font-family:$font_family;font-size:$font_size;margin-left:12px\" method=\"post\" action=\"".$PHP_SELF."\">
<input type=\"hidden\" name=\"settings\" value=\"".$keepsettings."\">
<input type=\"hidden\" name=\"refresh\" value=\"yes\">";

while (list ($key, $val) = each ($_FORM))
{
if ($key != "settings" and $key != "refresh")
{
if ($val == "" and $no_answer > "")
$val = "[no answer]";
$key = stripslashes($key);
$val = stripslashes($val);
$form .= "<input type=\"hidden\" name=\"".$key."\" value=\"".$val."\"><span style=\"margin-left:-8px\"><b>$style $key</b>: $val</span><br>";
}
}
$form .= "<br>
<input type=\"button\" value=\"Back\" onclick=\"history.back()\" style=\"text-decoration:underline;font-family:$font_family;font-size:$font_size;background-color:#FFFFFF;border: solid #FFFFFF 1px; cursor:hand\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" value=\"Continue\" style=\"text-decoration:underline;font-family:$font_family;font-size:$font_size;background-color:#FFFFFF;border: solid #FFFFFF 1px; cursor:hand\"></form>";
exit($form);
}

#=======================================
# CHECK REQUIRED FIELDS
#=======================================
if ($req_fields)
{
$req_fields = explode(",",$req_fields);
for($i=0;$i<count($req_fields);$i++)
{
$Field = $req_fields[$i];
if(!$_FORM[$Field])
{
$Field = str_replace("_"," ",$Field);
$Emptyfields .= "<li>$Field</li>";
}
}
if ($Emptyfields)
$Errors = $divstyle . $msg['required'] . "<ul type=\"square\">" . $Emptyfields . "</ul></div><br><br>";
}

#=======================================
# CHECK FORMATTED FIELDS
#=======================================
if ($formatted)
{
$formatted = explode(",",$formatted);
for ($x=0;$x<count($formatted);$x++)
{
$Format = substr($formatted[$x],-1);
$Field = substr($formatted[$x],0,-1);

if ($Format == "@" and $_FORM[$Field] > "") // EMAIL FORMAT
{
if(!eregi('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$',$_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-size:8pt\">(EMAIL ADDRESS)</span>";
}
}

if ($Format == "*" and $_FORM[$Field] > "") // PHONE NUMBER FORMAT
{
if (!eregi('([0-9]{3})-([0-9]{3})-([0-9]{4})', $_FORM[$Field]) and !eregi('([0-9]{3})\.([0-9]{3})\.([0-9]{4})', $_FORM[$Field]) and !eregi('([0-9]{3}) ([0-9]{3}) ([0-9]{4})', $_FORM[$Field]) and !eregi('(\([0-9]{3}\))-([0-9]{3})-([0-9]{4})', $_FORM[$Field]) and !eregi('(\([0-9]{3}\))\.([0-9]{3})\.([0-9]{4})', $_FORM[$Field]) and !eregi('(\([0-9]{3}\)) ([0-9]{3}) ([0-9]{4})', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-size:8pt\">(PHONE NUMBER)</span>";
}
}

if ($Format == "Z" and $_FORM[$Field] > "") // ZIP CODE FORMAT
{
if (!eregi('([0-9]{5})', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-size:8pt\">(ZIP CODE)</span>";
}
}

if ($Format == "S" and $_FORM[$Field] > "") // STATE FORMAT
{
if (!eregi('([a-zA-Z]{2})', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-size:8pt\">(STATE)</span>";
}
}

if ($Format == "#" and $_FORM[$Field] > "") // NUMERIC ONLY FORMAT
{
if (eregi('([a-zA-Z_\-)', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-size:8pt\">(NUMERIC ONLY)</span>";
}
}

if ($Format == "A" and $_FORM[$Field] > "") // ALPHA ONLY FORMAT
{
if (eregi('([0-9])', $_FORM[$Field]))
{
$Field = str_replace("_"," ",$Field);
$Incorrectfields .= "<li>$Field</li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"font-size:8pt\">(ALPHA ONLY)</span>";
}
}
}
if ($Incorrectfields)
$Errors .= $divstyle . $msg['formatted'] . "<ul type=\"square\">" . $Incorrectfields . "</ul></div>";
}
if ($Errors)
exit ($Errors);


################################################## #######################
# EMAIL FUNCTIONS #
################################################## #######################
if ($send_type == 'email' or $send_type == 'emailfile' or $send_type == 'emailcsv' or $send_type == 'emaildbase')
{
#================================================= ==========
# Get All Values from the Form Fields
#================================================= ==========
while (list ($key, $val) = each ($_FORM))
{
if ($key != "settings" and $key != "refresh")
{
$key = stripslashes($key);
$val = stripslashes($val);
if ($val == "" and $no_answer > "")
$val = "[no answer]";
$html .= "<b>$key</b>: $val<br>";
$content .= "$key: $val<br>";
$form .= "<b>$style $key</b>: $val </span><br>";
}
}

#================================================= ==========
# Check for Recipient
#================================================= ==========
if (!$recipient)
exit ($style . $msg['norecipient'] . '</span>');

#================================================= ==========
# Verify Subject
#================================================= ==========
if (!$subject)
$subject = 'Form submission';

#================================================= ==========
# Get User's IP Address
#================================================= ==========
if($ip_address)
{
$user_ip = $_SERVER['REMOTE_ADDR'];
$content .= "User's IP Address: $user_ip<br>";
}

#================================================= ==========
# Get User's Browser Agent
#================================================= ==========
if($browser)
{
$browser = $_SERVER['HTTP_USER_AGENT'];
$content .= "User's Browser: $browser<br>";
}

#================================================= ==========
# Get Date and Time of Submission
#================================================= ==========
if($getdate)
{
$getdate = date('M d, Y @ g:i:s a');
$content .= "Received: $getdate\n";
}

#================================================= ==========
# Put Header Information in Email
#================================================= ==========
if ($sendemail)
{
$header = "From: $sendemail\n";
$header .= "Reply-to: $sendemail\n";
}
else
$header = "From: $recipient\n";

$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\n";
$header .= "Content-Transfer-Encoding: 8bit\n";
if ($htmlemail)
{
$handle = fopen($htmlemail_page,'r');
$data = fread($handle,99999);
fclose($handle);
$content = str_replace('[insert mmex]',$html,$data);
}
if ($cc)
$header .= "cc: $cc\n";
if ($bcc)
$header .= "bcc: $bcc\n";

#================================================= ==========
# Send It Off
#================================================= ==========
mail($recipient,$subject,$content,$header);

} // end $send_type

################################################## #######################
# CSV-FILE FUNCTIONS #
################################################## #######################
if ($send_type == 'csv' or $send_type == 'emailcsv')
{

$getdate = date('M d Y g:i:s a');
$user_ip = $_SERVER['REMOTE_ADDR'];
$content = '';
$form = '';

while (list ($key, $val) = each ($_CSVFORM))
{
if ($key != "settings" and $key != "refresh")
{
$key = stripslashes($key);
$val = stripslashes($val);
$val = str_replace(",","¸",$val);
if ($val == "" and $no_answer > "")
$val = "[no answer]";
$content .= "$val,";
$form .= "<b>$style $key</b>: $val </span><br>";
}
}
$content .= "$getdate,$user_ip\n";

@ $write = fopen($csvfile_name,'a');
if (!$write and $senderrors == 'yes')
@mail($recipient,"Form Error",$msg['csverr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
@ flock($write,LOCK_EX);
@ fwrite($write,$content);
@ flock($write,LOCK_UN);
@ fclose($write);

} // end $send_type

################################################## #######################
# FLAT-FILE FUNCTIONS #
################################################## #######################
if ($send_type == 'file' or $send_type == 'emailfile')
{

$getdate = date('M d, Y g:i:s a');
$user_ip = $_SERVER['REMOTE_ADDR'];
$content = '';
$form = '';

while (list ($key, $val) = each ($_FILEFORM))
{
if ($key != "settings" and $key != "refresh")
{
$key = stripslashes($key);
$val = stripslashes($val);
if ($val == "" and $no_answer > "")
$val = "[no answer]";
$content .= "$key: $val\n";
$form .= "<b>$style $key</b>: $val </span><br>";
}
}
}

$data .= "Received: " . $getdate . "\nIP: " . $user_ip . "\n" . $content . "\n========================================\n\ n";

$write= @ fopen($flatfile_name,'a');
if (!$write and $senderrors == 'yes')
mail($recipient,"Form Error",$msg['fileerr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
@ flock($write,LOCK_EX);
@ fwrite($write,$data);
@ flock($write,LOCK_UN);
@ fclose($write);


} // end $send_type

################################################## #######################
# DATABASE FUNCTIONS #
################################################## #######################
if ($send_type == 'dbase' or $send_type == 'emaildbase')
{

#================================================= ==========
# Connect to Database
#================================================= ==========
$db_connect = mysql_connect("localhost", "$db_user", "$db_pass");
mysql_select_db("$db_name",$db_connect);

#================================================= ==========
# Get Form Results
#================================================= ==========
while (list ($key, $val) = each ($_DBASE))
{
if ($key != "settings" and $key != "refresh")
{
$val = addslashes($val);
$key = addslashes($key);
$add .= $key . ',';
$values .= "'" . $val . "',";
$key = stripslashes($key);
$val = stripslashes($val);
$form .= "<b>$style $key</b>: $val </span><br>";
}
}
$timestamp = date('M d, Y g:i:s a');
$user_ip = $_SERVER['REMOTE_ADDR'];
if ($input_timeandIP)
{
$add .= "timestamp,user_ip";
$values .= "'" . $timestamp . "','" . $user_ip ."'";
}
else
{
$add = substr($add,0,-1);
$values = substr($values,0,-1);
}

#================================================= ==========
# Store Values into Database
#================================================= ==========

$sql = "INSERT INTO $table_name ($add) VALUES ($values)";
$result = mysql_query($sql);
mysql_close($db_connect);

} // end $send_type

################################################## #######################
# POST SUBMIT FUNCTIONS #
################################################## #######################

#================================================= ==========
# Add Plug-In Functionality (plugins may be used later)
#================================================= ==========
if ($runplugin)
{
if (file_exists($pluginfile))
include($pluginfile);
}

#================================================= ==========
# Saves IP Address and Time to Flood File
#================================================= ==========
if ($flood_control)
{
$flooddata = $user_ip . "|" . $stamp . "#";

@ $write=fopen($floodfile_name,'a');
@ flock($write,LOCK_EX);
@ fwrite($write,$flooddata);
@ flock($write,LOCK_UN);
@ fclose($write);
}

#================================================= ==========
# Auto Respond Information
#================================================= ==========
if ($auto_respond)
{
if (!$auto_subject)
$auto_subject = 'Thank you for your submission';
if (!$auto_content)
$auto_content = "Thank you for your submmission. We will contact you shortly.";
$auto_header = "From: $recipient";
if ($email)
mail($email,$auto_subject,"$auto_content",$auto_he ader);
}

#================================================= ==========
# Redirects or Outputs Thank You and Form Results
#================================================= ==========
if (!$redirect)
{
if (!$thankyou)
$thankyou = 'Thank you for your submission.';
if ($showresults == "yes")
exit ($divstyle . "$thankyou<hr></div><br>$form<br><br><img style=\"position:absolute; right:3px; bottom:3px\" src=\"http://www.arecaweb.com/php/mmex/small_mmex.jpg\" alt=\"Mail Manage EX\">");
else
exit ($divstyle . "$thankyou<img style=\"position:absolute; right:3px; bottom:3px\" src=\"http://www.arecaweb.com/php/mmex/small_mmex.jpg\" alt=\"Mail Manage EX\">");
}
else
header("Location: $redirect");
?>
__________________
http://www.cablingassist.com/images2/calogo.gif
Telecommunications Directory & Referral Service
www.CablingAssist.com

Last edited by kappler0; 01-20-04 at 02:44 PM.
Reply With Quote
  #2 (permalink)  
Old 01-21-04, 03:14 AM
Stefan's Avatar
Stefan Stefan is offline
Junior Code Guru
 
Join Date: Jun 2003
Location: Utrecht, The Netherlands
Posts: 599
Thanks: 0
Thanked 0 Times in 0 Posts
could you maybe highlight line 426 or something like that?
Reply With Quote
  #3 (permalink)  
Old 01-21-04, 03:57 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,

The first thing you can tell by getting a parse error is that you have made a syntax error.

Having said that, my googlebar's highlight tells me that you have 3 beginning curly braces ( { ) and 4 ending curly braces ( } ) in the # FLAT-FILE FUNCTIONS # of your code (i.e. just above the database one).

It is very hard to see the code because you don't indent it, but if I may try:

PHP Code:

<?php


// ......Omitted.

################################################## #######################
# FLAT-FILE FUNCTIONS #
################################################## #######################
if ($send_type == 'file' or $send_type == 'emailfile')
//Begin_IF_1

    
$getdate date('M d, Y g:i:s a');
    
$user_ip $_SERVER['REMOTE_ADDR'];
    
$content '';
    
$form '';

    while (list (
$key$val) = each ($_FILEFORM))
    { 
//Begin_WHILE
        
if ($key != "settings" and $key != "refresh")
        { 
//Begin_IF_2
            
$key stripslashes($key);
            
$val stripslashes($val);
            if (
$val == "" and $no_answer ""// No Code Block...?
            
$val "[no answer]";
            
$content .= "$key$val\n";
            
$form .= "<b>$style $key</b>: $val </span><br>";
        } 
//End_IF_2
    
//End_WHILE
//End_IF_1

$data .= "Received: " $getdate "\nIP: " $user_ip "\n" $content "\n========================================\n\n";

$write= @ fopen($flatfile_name,'a');
if (!
$write and $senderrors == 'yes'// Where is { ? (i.e. Begin_IF_3)
    
mail($recipient,"Form Error",$msg['fileerr'],"From: \"Mail Manage EX Notifier\" <MMEX_Notifier@domain.com>");
    @ 
flock($write,LOCK_EX);
    @ 
fwrite($write,$data);
    @ 
flock($write,LOCK_UN);
    @ 
fclose($write);


//End_IF_3

// ......Omitted.

?>
Now it's clearer (to me, at least) that you have forgotten to close the last IF block. Pay attention to what I wrote (orange writings) - I believe you wanted a code block in the bottom chunk because you are testing the file handler and after this IF statement, you are using file functions (e.g. fclose()).

After adding {, if you excute this, PHP will not complain, but as a whole, there may be similar mistakes around. But the best way to approach parse errors is to make your code more human-friendly.

Hope this helps.
__________________
Blavv =|
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse title redspider ASP 2 04-14-04 06:57 AM
[php error] parse error | fatal error xeoHosting PHP 1 01-03-04 08:12 PM
Syntax? Parse? eddyvlad JavaScript 0 10-15-03 02:43 PM
PHP script to parse HTML Skeleton Man Script Requests 2 10-05-03 08:41 PM
PARSE Question clintre PHP 2 09-02-03 12:30 PM


All times are GMT -5. The time now is 08:36 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.