jamesxg1 Posted April 8, 2009 Share Posted April 8, 2009 i have a problem guys. this is the code <?php session_start(); include 'Database/Connection.php'; include 'Database/Utility.php'; isloggedin(); accessneeded("C"); if (isset($_POST['Add'])) { $holder = mysql_real_escape_string($_POST['holder']); $firstname = mysql_real_escape_string($_POST['firstname']); $firstname = ereg_replace(" ", "", $firstname); $lastname = mysql_real_escape_string($_POST['lastname']); $lastname = ereg_replace(" ", "", $lastname); $address = mysql_real_escape_string($_POST['address']); $postcode = mysql_real_escape_string($_POST['postcode']); $email = mysql_real_escape_string($_POST['email']); $email = ereg_replace(" ", "", $email); $pnumber = mysql_real_escape_string(intval($_POST['pnumber'])); $pnumber = ereg_replace(" ", "", $pnumber); $number = mysql_real_escape_string($_POST['txtNumber']); if($holder && $firstname && $lastname && $address && $postcode && $email && $pnumber){ $_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^`{|}~]+"; $_host = "([-0-9A-Z]+\.)+"; $_tlds = "([0-9A-Z]){2,4}$/i"; if( !preg_match($_name."@".$_host.$_tlds,$email) ){ echo "<div align=\"center\">The email you entered is of invalid format.</div>"; include("ContactControl.php?contact=Add"); die(); } if (md5($number) == $_SESSION['image_random_value']) { $sql = sprintf("INSERT INTO `contacts` (`holder`, `firstname`, `lastname`, `address`, `postcode`, `email`, `pnumber`) VALUES('$holder', '$firstname', '$lastname', '$address', '$postcode', '$email', '$pnumber')"); mysql_query($sql) or die(mysql_error()); header('Location: ContactControl.php?contact=Overview'); } if ($_GET['contact'] == "Add") { ?> <form method="POST" action="ContactControl.php?contact=Add"> <p> <b>First Name:</b><br><input type="text" name="firstname" size="20" maxlength="255" /> </p> <p> <b>Last Name:</b><br><input type="text" name="lastname" size="20" maxlength="255" /> </p> <p> <b>Address:</b><br><textarea rows="5" cols="40" name="address" id="$address"></textarea> </p> <p> <b>Postcode:</b><br><input type="text" name="postcode" size="20" maxlength="255" /> </p> <p> <b>Email:</b><br><input type="text" name="email" size="20" maxlength="255" /> </p> <p> <b>Phone Number:</b><br><input type="text" name="pnumber" size="20" maxlength="255" /> </p> <p><img src="Security/SecureSubmit.php"></p> <p><b>Security Code:</b><br><input name="txtNumber" type="text" id="txtNumber" value="" /></p> <p> <br><input type="hidden" name="holder" size="20" maxlength="255" value="<?php print $_SESSION['userid'] ?>"/> </p> <p align="center"> <input type="submit" name="Add" value="Submit" /> <input type="reset" name="reset" value="Reset Form"> </p> </form> <?php } } } if ($_GET['contact'] == "Overview") { $count = 0; $query = mysql_query(sprintf("SELECT * FROM contacts WHERE holder = '$_SESSION['userid']'")) or die(mysql_error()); while ($row = mysql_fetch_object($query)) { if ($count!=0){echo "<br>";} print "First Name: <font color=red>$row->firstname<br>"; print "Last Name: <font color=red>$row->lastname<br>"; print "Address: <font color=red>$row->address<br>"; print "Postcode: <font color=red>$row->postcode<br>"; print "Email: <font color=red>$row->email<br>"; print "Phone Number: <font color=red>$row->pnumber<br>"; $count++; } } ?> i get this Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\family\ContactControl.php on line 80 but i delete the whole bottom of the code and it is still there. :S Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 One thing to remember with PHP is the error can actualy be on the previous line or a line much earlier. Which is line 80? Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 8, 2009 Author Share Posted April 8, 2009 One thing to remember with PHP is the error can actualy be on the previous line or a line much earlier. Which is line 80? <?php session_start(); include 'Database/Connection.php'; include 'Database/Utility.php'; isloggedin(); accessneeded("C"); if (isset($_POST['Add'])) { $holder = mysql_real_escape_string($_POST['holder']); $firstname = mysql_real_escape_string($_POST['firstname']); $firstname = ereg_replace(" ", "", $firstname); $lastname = mysql_real_escape_string($_POST['lastname']); $lastname = ereg_replace(" ", "", $lastname); $address = mysql_real_escape_string($_POST['address']); $postcode = mysql_real_escape_string($_POST['postcode']); $email = mysql_real_escape_string($_POST['email']); $email = ereg_replace(" ", "", $email); $pnumber = mysql_real_escape_string(intval($_POST['pnumber'])); $pnumber = ereg_replace(" ", "", $pnumber); $number = mysql_real_escape_string($_POST['txtNumber']); if($holder && $firstname && $lastname && $address && $postcode && $email && $pnumber){ $_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^`{|}~]+"; $_host = "([-0-9A-Z]+\.)+"; $_tlds = "([0-9A-Z]){2,4}$/i"; if( !preg_match($_name."@".$_host.$_tlds,$email) ){ echo "<div align=\"center\">The email you entered is of invalid format.</div>"; include("ContactControl.php?contact=Add"); die(); } if (md5($number) == $_SESSION['image_random_value']) { $sql = sprintf("INSERT INTO `contacts` (`holder`, `firstname`, `lastname`, `address`, `postcode`, `email`, `pnumber`) VALUES('$holder', '$firstname', '$lastname', '$address', '$postcode', '$email', '$pnumber')"); mysql_query($sql) or die(mysql_error()); header('Location: ContactControl.php?contact=Overview'); } if ($_GET['contact'] == "Add") { ?> <form method="POST" action="ContactControl.php?contact=Add"> <p> <b>First Name:</b><br><input type="text" name="firstname" size="20" maxlength="255" /> </p> <p> <b>Last Name:</b><br><input type="text" name="lastname" size="20" maxlength="255" /> </p> <p> <b>Address:</b><br><textarea rows="5" cols="40" name="address" id="$address"></textarea> </p> <p> <b>Postcode:</b><br><input type="text" name="postcode" size="20" maxlength="255" /> </p> <p> <b>Email:</b><br><input type="text" name="email" size="20" maxlength="255" /> </p> <p> <b>Phone Number:</b><br><input type="text" name="pnumber" size="20" maxlength="255" /> </p> <p><img src="Security/SecureSubmit.php"></p> <p><b>Security Code:</b><br><input name="txtNumber" type="text" id="txtNumber" value="" /></p> <p> <br><input type="hidden" name="holder" size="20" maxlength="255" value="<?php print $_SESSION['userid'] ?>"/> </p> <p align="center"> <input type="submit" name="Add" value="Submit" /> <input type="reset" name="reset" value="Reset Form"> </p> </form> <?php } } } ?> ithe the second * } * out of the bottom three Quote Link to comment Share on other sites More sharing options...
thebadbad Posted April 8, 2009 Share Posted April 8, 2009 If you indented your code properly, it would be easy to ensure that every opening bracket was being closed. In your posted code however, there's 10 pairs of brackets that seem fine. I think the error could be in one of the included files. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 8, 2009 Author Share Posted April 8, 2009 nope isnt any of the include files because i havent any the only included files is the one in question. . the script file name is ContactControl.php. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 I've reformatted it and make a couple minor changes... <?php session_start(); include 'Database/Connection.php'; include 'Database/Utility.php'; isloggedin(); accessneeded("C"); if (isset($_POST['Add'])) { $holder = mysql_real_escape_string($_POST['holder']); $firstname = mysql_real_escape_string($_POST['firstname']); $firstname = ereg_replace(" ", "", $firstname); $lastname = mysql_real_escape_string($_POST['lastname']); $lastname = ereg_replace(" ", "", $lastname); $address = mysql_real_escape_string($_POST['address']); $postcode = mysql_real_escape_string($_POST['postcode']); $email = mysql_real_escape_string($_POST['email']); $email = ereg_replace(" ", "", $email); $pnumber = mysql_real_escape_string(intval($_POST['pnumber'])); $pnumber = ereg_replace(" ", "", $pnumber); $number = mysql_real_escape_string($_POST['txtNumber']); if($holder && $firstname && $lastname && $address && $postcode && $email && $pnumber) { $_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^`{|}~]+"; $_host = "([-0-9A-Z]+\.)+"; $_tlds = "([0-9A-Z]){2,4}$/i"; if( !preg_match($_name."@".$_host.$_tlds,$email) ){ echo "<div align=\"center\">The email you entered is of invalid format.</div>"; include("ContactControl.php?contact=Add"); die(); } if (md5($number) == $_SESSION['image_random_value']) { $sql = "INSERT INTO `contacts` (`holder`, `firstname`, `lastname`, `address`, `postcode`, `email`, `pnumber`) VALUES('$holder', '$firstname', '$lastname', '$address', '$postcode', '$email', '$pnumber')"; mysql_query($sql) or die(mysql_error()); header('Location: ContactControl.php?contact=Overview'); } if ($_GET['contact'] == "Add") { ?> <form method="POST" action="ContactControl.php?contact=Add"> <p><b>First Name:</b><br><input type="text" name="firstname" size="20" maxlength="255" /></p> <p><b>Last Name:</b><br><input type="text" name="lastname" size="20" maxlength="255" /></p> <p><b>Address:</b><br><textarea rows="5" cols="40" name="address" id="$address"></textarea></p> <p><b>Postcode:</b><br><input type="text" name="postcode" size="20" maxlength="255" /></p> <p><b>Email:</b><br><input type="text" name="email" size="20" maxlength="255" /></p> <p><b>Phone Number:</b><br><input type="text" name="pnumber" size="20" maxlength="255" /></p> <p><img src="Security/SecureSubmit.php" /></p> <p><b>Security Code:</b><br><input name="txtNumber" type="text" id="txtNumber" value="" /></p> <p><br><input type="hidden" name="holder" size="20" maxlength="255" value="<?php print $_SESSION['userid']; ?>"/></p> <p align="center"> <input type="submit" name="Add" value="Submit" /> <input type="reset" name="reset" value="Reset Form" /> </p> </form> <?php } } } ?> Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 I've just checked all the quotes etc. and I'm also thinking the problem is in one of the includes. Try removing everything inside that file so it's just like this and try it again: <?php session_start(); include 'Database/Connection.php'; include 'Database/Utility.php'; isloggedin(); accessneeded("C")?> If you get the error still it's the includes. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 8, 2009 Author Share Posted April 8, 2009 I've just checked all the quotes etc. and I'm also thinking the problem is in one of the includes. Try removing everything inside that file so it's just like this and try it again: <?php session_start(); include 'Database/Connection.php'; include 'Database/Utility.php'; isloggedin(); accessneeded("C")?> If you get the error still it's the includes. the includes are all ok as i use them on every page in my server and i have the script working (kinda) you see i have no errors but it also isnt displaying anything any ideas or reason for this :S ? <?php session_start(); include 'Database/Connection.php'; include 'Database/Utility.php'; isloggedin(); accessneeded("C"); if (isset($_POST['Add'])) { $holder = mysql_real_escape_string($_POST['holder']); $firstname = mysql_real_escape_string($_POST['firstname']); $firstname = ereg_replace(" ", "", $firstname); $lastname = mysql_real_escape_string($_POST['lastname']); $lastname = ereg_replace(" ", "", $lastname); $address = mysql_real_escape_string($_POST['address']); $postcode = mysql_real_escape_string($_POST['postcode']); $email = mysql_real_escape_string($_POST['email']); $email = ereg_replace(" ", "", $email); $pnumber = mysql_real_escape_string(intval($_POST['pnumber'])); $pnumber = ereg_replace(" ", "", $pnumber); $number = mysql_real_escape_string($_POST['txtNumber']); if($holder && $firstname && $lastname && $address && $postcode && $email && $pnumber) { $_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^`{|}~]+"; $_host = "([-0-9A-Z]+\.)+"; $_tlds = "([0-9A-Z]){2,4}$/i"; if( !preg_match($_name."@".$_host.$_tlds,$email) ){ echo "<div align=\"center\">The email you entered is of invalid format.</div>"; include("ContactsControl.php?contact=Add"); die(); } if (md5($number) == $_SESSION['image_random_value']) { $sql = "INSERT INTO `contacts` (`holder`, `firstname`, `lastname`, `address`, `postcode`, `email`, `pnumber`) VALUES('$holder', '$firstname', '$lastname', '$address', '$postcode', '$email', '$pnumber')"; mysql_query($sql) or die(mysql_error()); header('Location: ContactsControl.php?contact=Overview'); } if ($_GET['contact'] == "Add") { ?> <form method="POST" action="ContactControl.php?contact=Add"> <p><b>First Name:</b><br><input type="text" name="firstname" size="20" maxlength="255" /></p> <p><b>Last Name:</b><br><input type="text" name="lastname" size="20" maxlength="255" /></p> <p><b>Address:</b><br><textarea rows="5" cols="40" name="address" id="$address"></textarea></p> <p><b>Postcode:</b><br><input type="text" name="postcode" size="20" maxlength="255" /></p> <p><b>Email:</b><br><input type="text" name="email" size="20" maxlength="255" /></p> <p><b>Phone Number:</b><br><input type="text" name="pnumber" size="20" maxlength="255" /></p> <p><img src="Security/SecureSubmit.php" /></p> <p><b>Security Code:</b><br><input name="txtNumber" type="text" id="txtNumber" value="" /></p> <p><br><input type="hidden" name="holder" size="20" maxlength="255" value="<?php print $_SESSION['userid']; ?>"/></p> <p align="center"> <input type="submit" name="Add" value="Submit" /> <input type="reset" name="reset" value="Reset Form" /> </p> </form> <?php } } } if ($_GET['contact'] == "Overview") { $userid = $_SESSION['userid']; $count = 0; $query = mysql_query(sprintf("SELECT * FROM contacts WHERE holder = '$userid'")) or die(mysql_error()); while ($row = mysql_fetch_object($query)) { if ($count!=0){echo "<br>";} print "First Name: <font color=red>$row->firstname<br>"; print "Last Name: <font color=red>$row->lastname<br>"; print "Address: <font color=red>$row->address<br>"; print "Postcode: <font color=red>$row->postcode<br>"; print "Email: <font color=red>$row->email<br>"; print "Phone Number: <font color=red>$row->pnumber<br>"; $count++; } } ?> Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 8, 2009 Author Share Posted April 8, 2009 anyone have any ideas ? Quote Link to comment Share on other sites More sharing options...
thebadbad Posted April 8, 2009 Share Posted April 8, 2009 Yes, turn on error reporting. Put this at the top of your script: <?php ini_set('display_errors', 1); error_reporting(E_ALL); ?> Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 8, 2009 Author Share Posted April 8, 2009 Notice: Undefined index: contact in C:\xampp\htdocs\family\ContactsControl.php on line 71 thats all i got. . . dont understand why thoe :S Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 8, 2009 Author Share Posted April 8, 2009 if ($_GET['contact'] == "Overview") { thats not working is it correctly typed ? Quote Link to comment Share on other sites More sharing options...
thebadbad Posted April 8, 2009 Share Posted April 8, 2009 It just means that 'contact' isn't a key in the $_GET array. I.e. contact is not set in the URL. Shouldn't cause any trouble though. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 8, 2009 Author Share Posted April 8, 2009 It just means that 'contact' isn't a key in the $_GET array. I.e. contact is not set in the URL. Shouldn't cause any trouble though. hiya, well for some reason no matter what url i use be it contact=Overview OR contact=Add none of them work :S any ideas why ? Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted April 8, 2009 Author Share Posted April 8, 2009 someone please help, this has totally baffled me Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.