Hello,
I have a guestbook created in PHP and was having a problem with blank entries. I was on here a few weeks ago getting help and then the board went down. Anyway, I learned about javascript field verification and was told to look into PHP verification as well, just in case.
Can someone please help me figure out my the following code is generating this parse error?
Parse error: parse error, unexpected T_STRING in /hsphere/local/home/agfagf/agruesomefind.com/php/submit.php on line 10
Even though I get the error, it seems to be sending a blank email with no information at all....
Any help would be greatly appreciated, thanks!
<?php
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$location = $_POST['location'] ;
$site_url = $_POST['site_url'] ;
$comments = $_POST['comments'] ;_
// verify if any stated fields has empty values
if_(empty($comments))_{_
____header("Location: error.php");_
}_else_{_
____// check if magic_quotes_gpc is On or Off
____if_(!get_magic_quotes_gpc())_{___
________$comments_=_addslashes($comments);___
____}_else_{___
________$comments_=_$comments;___
____}_
____// process the submission here
____$sql_=_mysql_connect ("xxxx", "xxxx", "xxxx");
mysql_select_db (agfagf_vileart_distro);
$sql = mysql_query ("INSERT INTO agf_guestbook (name, email, location, site_url, comments)
VALUES ('$name', '$email', '$location', '$site_url', '$comments')
");
print ("Guestbook entry successful");
____
____// Grab last record input
____$sql_=_mysql_query("SELECT * FROM agf_guestbook ORDER BY entry_id DESC LIMIT 1")_or_die_(mysql_error());
____$row_=_mysql_fetch_array($sql);
____
____## FORMAT EMAIL ##############################
____
____// set email header
____$header_=_"From:[email protected]\n";
____$header_.=_"MIME-Version: 1.0\n";
____$header_.=_"Mailer: FCG Browser-Based Applications\n";
____$header_.=_"Content-Type: text/plain; charset=\"iso-8859-1\"\n";
____
____// set destination
____$sendto_=_"[email protected]\n";
____
____// set subject
____$subject_=_"Enter and subject you want to display in subject area\n";
____
____// build message
____$message_=_"New guestbook posted on ".date("F j, Y")."\n";
____$message_.=_"\n";
____$message_.=_"http://www.agruesomefind.com/php/guestbook.php?id=".$row["entry_id"]."\n";
____
____// send email
____mail($sendto,$subject,$message,$header);
_____
____## END EMAIL ##################################
____header("Location: guestbook.php");_
}
?>First of all, are you sure you've got the right forum? This one is for help with migrating from PHP4 to PHP5. I think you wanted the coding forum...?
Second, parse errors are usually the easiest to fix, because there is something blatantly wrong with the syntax of the file (PHP doesn't even need to run the script to find it). Which one is line 10? I tried counting but just got a blank. After copying and pasting your code (and stripping out those spurious underscores - and then putting back the ones that are supposed to be there), I syntax-checked the code and didn't get any parse errors.
Of course, because the code never ran, it would never have sent out an email. Are you sure you're looking at the right file?hi
to test the blank field you better user javascript on the page from which you are posting the values.
in the Form tag call this function valid()
<script language="javascrip">
function valid()
{
if(document.formname.obectname.value=="")
{
alert("Please enter the value")
document.formname.obectname.focus();
return false
}
}
</script>
this javascrip function will solve ur problem of testing Balnk field and it will work more faster since it work on ur client.
let me know if it works for u
I have a guestbook created in PHP and was having a problem with blank entries. I was on here a few weeks ago getting help and then the board went down. Anyway, I learned about javascript field verification and was told to look into PHP verification as well, just in case.
Can someone please help me figure out my the following code is generating this parse error?
Parse error: parse error, unexpected T_STRING in /hsphere/local/home/agfagf/agruesomefind.com/php/submit.php on line 10
Even though I get the error, it seems to be sending a blank email with no information at all....
Any help would be greatly appreciated, thanks!
<?php
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$location = $_POST['location'] ;
$site_url = $_POST['site_url'] ;
$comments = $_POST['comments'] ;_
// verify if any stated fields has empty values
if_(empty($comments))_{_
____header("Location: error.php");_
}_else_{_
____// check if magic_quotes_gpc is On or Off
____if_(!get_magic_quotes_gpc())_{___
________$comments_=_addslashes($comments);___
____}_else_{___
________$comments_=_$comments;___
____}_
____// process the submission here
____$sql_=_mysql_connect ("xxxx", "xxxx", "xxxx");
mysql_select_db (agfagf_vileart_distro);
$sql = mysql_query ("INSERT INTO agf_guestbook (name, email, location, site_url, comments)
VALUES ('$name', '$email', '$location', '$site_url', '$comments')
");
print ("Guestbook entry successful");
____
____// Grab last record input
____$sql_=_mysql_query("SELECT * FROM agf_guestbook ORDER BY entry_id DESC LIMIT 1")_or_die_(mysql_error());
____$row_=_mysql_fetch_array($sql);
____
____## FORMAT EMAIL ##############################
____
____// set email header
____$header_=_"From:[email protected]\n";
____$header_.=_"MIME-Version: 1.0\n";
____$header_.=_"Mailer: FCG Browser-Based Applications\n";
____$header_.=_"Content-Type: text/plain; charset=\"iso-8859-1\"\n";
____
____// set destination
____$sendto_=_"[email protected]\n";
____
____// set subject
____$subject_=_"Enter and subject you want to display in subject area\n";
____
____// build message
____$message_=_"New guestbook posted on ".date("F j, Y")."\n";
____$message_.=_"\n";
____$message_.=_"http://www.agruesomefind.com/php/guestbook.php?id=".$row["entry_id"]."\n";
____
____// send email
____mail($sendto,$subject,$message,$header);
_____
____## END EMAIL ##################################
____header("Location: guestbook.php");_
}
?>First of all, are you sure you've got the right forum? This one is for help with migrating from PHP4 to PHP5. I think you wanted the coding forum...?
Second, parse errors are usually the easiest to fix, because there is something blatantly wrong with the syntax of the file (PHP doesn't even need to run the script to find it). Which one is line 10? I tried counting but just got a blank. After copying and pasting your code (and stripping out those spurious underscores - and then putting back the ones that are supposed to be there), I syntax-checked the code and didn't get any parse errors.
Of course, because the code never ran, it would never have sent out an email. Are you sure you're looking at the right file?hi
to test the blank field you better user javascript on the page from which you are posting the values.
in the Form tag call this function valid()
<script language="javascrip">
function valid()
{
if(document.formname.obectname.value=="")
{
alert("Please enter the value")
document.formname.obectname.focus();
return false
}
}
</script>
this javascrip function will solve ur problem of testing Balnk field and it will work more faster since it work on ur client.
let me know if it works for u