11 Replies - 582 Views - Last Post: 17 February 2013 - 01:28 PM Rate Topic: -----

#1 jackieandrosie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-February 13

PHP error: form handle

Posted 12 February 2013 - 08:44 PM

$error_messages = array();
if(!empty($_POST['credit_no']) && is_numeric($_POST['credit_no'])){
	$credit_no = $_POST['credit_no'];
}else{
	$error_messages[] = "You did not enter your credit number or the number you entered is not numeric <br />";
}



Error Message:
Parse error: syntax error, unexpected '{' in /home/public_html/Test/order_handle.php on line 5

I am new to php, forgive me! My error message says that I don't need the open curly brace but I know I do! Is there another error and I just don't see it?

This post has been edited by Dormilich: 13 February 2013 - 02:01 AM
Reason for edit:: fixed code tags


Is This A Good Question/Topic? 0
  • +

Replies To: PHP error: form handle

#2 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 442
  • View blog
  • Posts: 1,890
  • Joined: 30-April 10

Re: PHP error: form handle

Posted 12 February 2013 - 09:00 PM

Is the code you supplied the entire code for Test/order_handle.php? What line does this code begin on?
Was This Post Helpful? 0
  • +
  • -

#3 jackieandrosie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-February 13

Re: PHP error: form handle

Posted 12 February 2013 - 09:23 PM

No, I will post the entire code for you:

<?php
// phpinfo();

$error_messages = array();
if(!empty($_POST['credit_no']) && is_numeric($_POST['credit_no'])){
	$credit_no = $_POST['credit_no'];
}else{
	$error_messages[] = "You did not enter your credit number or the number you entered is not numeric <br />";
}

if(!empty($_POST['security'])&& is_numeric(($_POST['security'])){
	$security = $_POST['security'];
}else{
	$error_messages[] = "You did not enter your security code or it is not numberic <br />";
}

if(!empty($_POST['instructions'])){
	$instructions = $_POST['instructions'];
}else{
	$error_messages[] = "You did not enter your instructions <br />";
}

if(isset($_POST['hat_type'])){
	$hat_type = $_POST['hat_type'];
}else{
	$error_messages[] = "You did not enter your hat type <br />";
}

if(isset($_POST['credit_type'])){
	$confirm = $_POST['credit_type'];
}else{
	$error_messages[] = "You did not select a credit type <br />";
}

if(!empty($_POST['shipping'])){
	$shipping = $_POST['shipping'];
}else{
	$error_messages[] = "You did not select a shipping method <br />";
}

if(isset($_POST['shipping_method'])){
	$shipping_method = $_POST['shipping_method'];
}else{
	$error_messages[] = "You did not enter a shipping method <br />";
}

	if(!ini_get('magic_quotes_gpc')){
		$instructions = addslashes($instructions);
		
	}
	
	echo "Your hat type is: $hat_type <br />";
	echo "Your credit type is: $credit_type <br />";
	echo "Your credit number is: $credit_no <br />";
	echo "Your security is $security <br />";
	echo "Your shipping carrier is: $shipping <br />";
		foreach($shipping as $value){
		echo "$value,";
	echo "Your shipping method is: $shipping_method <br />";
	echo "Your instructions are: $instructions <br />";

	
}
?>



Was This Post Helpful? 0
  • +
  • -

#4 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 442
  • View blog
  • Posts: 1,890
  • Joined: 30-April 10

Re: PHP error: form handle

Posted 12 February 2013 - 10:04 PM

I don't see an error in the lines leading to the opening { as your message has indicated.

Are you sure you saved before testing?
Was This Post Helpful? 1
  • +
  • -

#5 jackieandrosie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-February 13

Re: PHP error: form handle

Posted 12 February 2013 - 10:11 PM

Yes : (

Here is the form:


<html>
<head>
	<title>Order from HatFact</title>
</head>
<body>
<div>
	<form method="POST" action="displayerrors.php">
		Hat Type: <select name="hat_type" id="hat_type" size="1"
			<option value="The Wellington">The Wellington</option>
			<option value="Continental">Continental</option>
			<option value="Navy">Navy</option>
			<option value="Army">Army</option>
			<option value="Clerical">Clerical</option>
			<option value="The Paris Beau">The Paris Beau</option>
			<option value="The Regen">The Regen</option>
			<option value="Dorsay">Dorsay</option>
			
	</select>
	</div>
	
		<fieldset>
			<legend>Credit Card </legend>
			<div>
			Visa <input type="radio" name="credit_type" id="visa" value="visa" />
			 Master Card<input type="radio" name="credit_type" id="mastercard" value="mastercard" />
			 American Express <input type="radio" name="credit_type" id="americanexpress" value="americanexpress" />
			 Discover <input type="radio" name="credit_type" id="discover" value="discover" checked="checked" />
			</div>
			<div>
			Credit Card #: <input type="text" name="credit_no" id="credit_no" size="16" maxlength="16" />
			 Security Code#: <input type="text" name="security" id="security" size="3" maxlength="3" />
			</div>
			</fieldset>
			
			<fieldset>
			<legend>Shipping Info</legend>
			Carrier:UPS <input type="checkbox" name="shipping[]" id="ups" value="ups" />
				 USPS <input type="checkbox" name="shipping[]" id="usps" value="usps" />
				 FEDEX <input type="checkbox" name="shipping[]" id="fedex" value="fedex" />
			Method:
			<select id="shipping_method" name="shipping_method" size="1">
			<option value="ground">Ground</option>
			<option value="express">Express</option>
			</select>
			</fieldset>
				<div>
				Instructions:<br />	
				<textarea name="instructions" id="instructions" rows="5" cols="40">Type your special instructions here...</textarea>
				</div>
			 <div>
	<input type="submit" value="Submit" />
	<input type="reset" value="Reset" />
</div>
	
	</form>

</body>
</html>




If anyone sees any errors, I would greatly appreciate your help. I am getting a white screen and I just don't see where it is.
Was This Post Helpful? 0
  • +
  • -

#6 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 442
  • View blog
  • Posts: 1,890
  • Joined: 30-April 10

Re: PHP error: form handle

Posted 12 February 2013 - 10:21 PM

Got it,

The error was on line 11 if(!empty($_POST['security'])&& is_numeric(($_POST['security'])){,

Spoiler


notice the extra ( in the is_numeric() function call.
Was This Post Helpful? 2
  • +
  • -

#7 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: PHP error: form handle

Posted 12 February 2013 - 10:24 PM

Well, if you notice closely, you will find that your select tag is not closed in line 8.

regards,
Raghav
Was This Post Helpful? 1
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6078
  • View blog
  • Posts: 23,546
  • Joined: 23-August 08

Re: PHP error: form handle

Posted 13 February 2013 - 04:35 AM

View Postlaytonsdad, on 13 February 2013 - 12:21 AM, said:

Got it,

The error was on line 11 if(!empty($_POST['security'])&& is_numeric(($_POST['security'])){,

Spoiler


notice the extra ( in the is_numeric() function call.


Using a good code editor that provides parentheses/bracket matching will help prevent these types of problems.
Was This Post Helpful? 2
  • +
  • -

#9 jackieandrosie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-February 13

Re: PHP error: form handle

Posted 14 February 2013 - 07:34 PM

Thank you so much! What text editor do you guys like for PHP? My teacher has us using notepad++ which is not much help!

Thank you so much! What text editor do you guys like for PHP? My teacher has us using notepad++ which is not much help!

Thank you so much! What text editor do you guys like for PHP? My teacher has us using notepad++ which is not much help!

Thank you so much! What text editor do you guys like for PHP? My teacher has us using notepad++ which is not much help!

Thank you so much! What text editor do you guys like for PHP? My teacher has us using notepad++ which is not much help!

Thank you so much! What text editor do you guys like for PHP? My teacher has us using notepad++ which is not much help!
Was This Post Helpful? 0
  • +
  • -

#10 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 442
  • View blog
  • Posts: 1,890
  • Joined: 30-April 10

Re: PHP error: form handle

Posted 14 February 2013 - 08:29 PM

I use:

Microsoft Expression Studio 4 ( it was free through https://www.dreamspark.com/ )

and

NetBeans http://netbeans.org/downloads/
Was This Post Helpful? 1
  • +
  • -

#11 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: PHP error: form handle

Posted 15 February 2013 - 02:54 AM

Well, Netbeans is an IDE and not a text editor.

Well, you can try Komodo Edit

regards,
Raghav
Was This Post Helpful? 1
  • +
  • -

#12 jackieandrosie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-February 13

Re: PHP error: form handle

Posted 17 February 2013 - 01:28 PM

Thanks guys, I will try one.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1