munky334 Posted October 19, 2008 Share Posted October 19, 2008 Hi there I'm getting the following error when trying to run this script and I have no idea , any advise? "Parse Error , syntax error , unexpected T_VARIABLE" - Line 19 I'm using PHP 5.2.6 together with wampserver. <?php /* File: shop_form_shipinfo.inc * Desc: Contains the code for a form that collects * shipping information for the order. */ include("functions.inc"); include("Vars.inc"); $ship_info = array("email" => "Email Address", "ship_name" => "Name", "ship_street" => "Street", "ship_city" => "City", "ship_state" => "State", "ship_zip" => "Zip", "phone" => "Phone", "cc_type" => "Credit Card Type", "cc_number" => "Credit Card Number", "cc_exp" => "Expiration Date" ) $cc_types = array("visa" => "Visa", "mc" => "Master Card", "amex" => "American Express" ); $length = array("email" => "55", "ship_name" => "40", "ship_street" => "55", "ship_city" => "40", "ship_zip" => "10", "phone" => "15", "cc_number" => "20" ); $months = array (1=> "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); $today = time("Y-m-d"); if(!isset($_POST) or $_POST['Ship'] == "Edit Shipping Information" ) { $cxn = mysqli_connect($host,$user,$passwd,$database); $sql = "SELECT ship_name,ship_street,ship_city,ship_state, ship_zip,phone,email FROM CustomerOrder WHERE order_number = '{$_SESSION['order_number']}'"; $result = mysqli_query($cxn,$sql) or die("Error: ".mysqli_error($cxn)); $n = mysqli_num_rows($result); if($n > 0) { $row = mysqli_fetch_assoc($result); extract($row); } } ?> <head><title>Furniture Order: Shipping Information</title> <style type="text/css"> <!-- #form { margin: 1.5em 0 0 0; padding: 0; } #field {padding-bottom: 1em;} label { font-weight: bold; float: left; width: 20%; text-align: right; clear: left; margin-right; 1em; } --> </style> </head> <h2 align='center'>Furniture Shop: Shipping Information</h2> <p style='font-style: italic; font-weight: bold'>Please fill in the information below <?php echo "<form action='$_SERVER[php_SELF]’ method=’POST’> <div id=’form’>\n"; if(isset($message)) { echo "<p style=\"font-weight: bold; font-style: italic; font-size: 90%; color: red\"> $message</p>"; } foreach($ship_info as $field => $value) { if($field == "ship_state”) { echo "<div id=’field’> <label for '$field’>State: </label> <select name=’$field’ id=$field>”; $stateName=getStateName(); $stateCode=getStateCode(); for ($n=1;$n<=50;$n++) { $state=$stateName[$n]; $scode=$stateCode[$n]; echo "<option value=’$scode’”; if($scode == @$_POST['state’] || $scode == @$ship_state) echo " selected"; echo ">$state\n"; } echo "</select></div>"; } elseif($field == "cc_type") { echo "<div id='field'> <label for '$field'>$value: </label> <select name=’cc_type'></p>”; foreach($cc_types as $field => $value) { echo "<option value='$field'"; echo ">$value\n"; } echo "</select></div>"; } elseif($field == "cc_exp") { echo "<div id='field'> <label for '$field'>$value: </label> <select name='cc_exp_mo'></p>"; for($n=1;$n<=12;$n++) { echo "<option value='$n'>{$months[$n]}\n"; } echo "</select>\n"; echo "<select name='cc_exp_da'>"; for($n=1;$n<=31;$n++) { echo " <option value='$n'>$n\n"; } echo "</select>\n"; echo "<select name='cc_exp_yr'>"; $start_yr = date("Y",$today); for($n=$start_yr;$n<=$start_yr+5;$n++) { echo " <option value='$n'>$n\n"; } echo "</select></div>\n"; } else { echo "<div id='field'> <label for='$field'>$value: </label> <input type='text' id='$field' name='$field' value='".@$$field."' size='{$length[$field]}' maxsize='{$length[$field]}' /> </div>\n"; } } ?> <p style="margin-top: .05in"> <input style='margin-left: 33%' type="submit" name="Summary" value="Continue" /> </form></body></html> Link to comment https://forums.phpfreaks.com/topic/129061-solved-parse-error-syntax-error-unexpected-t_variable/ Share on other sites More sharing options...
ratcateme Posted October 19, 2008 Share Posted October 19, 2008 you missed the ; off the end of first array Scott. Link to comment https://forums.phpfreaks.com/topic/129061-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-669097 Share on other sites More sharing options...
hmvrulz Posted October 19, 2008 Share Posted October 19, 2008 <?php /* File: shop_form_shipinfo.inc * Desc: Contains the code for a form that collects * shipping information for the order. */ include("functions.inc"); include("Vars.inc"); $ship_info = array("email" => "Email Address", "ship_name" => "Name", "ship_street" => "Street", "ship_city" => "City", "ship_state" => "State", "ship_zip" => "Zip", "phone" => "Phone", "cc_type" => "Credit Card Type", "cc_number" => "Credit Card Number", "cc_exp" => "Expiration Date" ); $cc_types = array("visa" => "Visa", "mc" => "Master Card", "amex" => "American Express" ); $length = array("email" => "55", "ship_name" => "40", "ship_street" => "55", "ship_city" => "40", "ship_zip" => "10", "phone" => "15", "cc_number" => "20" ); $months = array (1=> "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); $today = time("Y-m-d"); if(!isset($_POST) or $_POST['Ship'] == "Edit Shipping Information" ) { $cxn = mysqli_connect($host,$user,$passwd,$database); $sql = "SELECT ship_name,ship_street,ship_city,ship_state, ship_zip,phone,email FROM CustomerOrder WHERE order_number = '{$_SESSION['order_number']}'"; $result = mysqli_query($cxn,$sql) or die("Error: ".mysqli_error($cxn)); $n = mysqli_num_rows($result); if($n > 0) { $row = mysqli_fetch_assoc($result); extract($row); } } ?> <head><title>Furniture Order: Shipping Information</title> <style type="text/css"> <!-- #form { margin: 1.5em 0 0 0; padding: 0; } #field {padding-bottom: 1em;} label { font-weight: bold; float: left; width: 20%; text-align: right; clear: left; margin-right; 1em; } --> </style> </head> <h2 align='center'>Furniture Shop: Shipping Information</h2> <p style='font-style: italic; font-weight: bold'>Please fill in the information below <?php echo "<form action='$_SERVER[php_SELF]’ method=’POST’> <div id=’form’>\n"; if(isset($message)) { echo "<p style=\"font-weight: bold; font-style: italic; font-size: 90%; color: red\"> $message</p>"; } foreach($ship_info as $field => $value) { if($field == "ship_state”) { echo "<div id=’field’> <label for '$field’>State: </label> <select name=’$field’ id=$field>”; $stateName=getStateName(); $stateCode=getStateCode(); for ($n=1;$n<=50;$n++) { $state=$stateName[$n]; $scode=$stateCode[$n]; echo "<option value=’$scode’”; if($scode == @$_POST['state’] || $scode == @$ship_state) echo " selected"; echo ">$state\n"; } echo "</select></div>"; } elseif($field == "cc_type") { echo "<div id='field'> <label for '$field'>$value: </label> <select name=’cc_type'></p>”; foreach($cc_types as $field => $value) { echo "<option value='$field'"; echo ">$value\n"; } echo "</select></div>"; } elseif($field == "cc_exp") { echo "<div id='field'> <label for '$field'>$value: </label> <select name='cc_exp_mo'></p>"; for($n=1;$n<=12;$n++) { echo "<option value='$n'>{$months[$n]}\n"; } echo "</select>\n"; echo "<select name='cc_exp_da'>"; for($n=1;$n<=31;$n++) { echo " <option value='$n'>$n\n"; } echo "</select>\n"; echo "<select name='cc_exp_yr'>"; $start_yr = date("Y",$today); for($n=$start_yr;$n<=$start_yr+5;$n++) { echo " <option value='$n'>$n\n"; } echo "</select></div>\n"; } else { echo "<div id='field'> <label for='$field'>$value: </label> <input type='text' id='$field' name='$field' value='".@$$field."' size='{$length[$field]}' maxsize='{$length[$field]}' /> </div>\n"; } } ?> <p style="margin-top: .05in"> <input style='margin-left: 33%' type="submit" name="Summary" value="Continue" /> </form></body></html> try this Link to comment https://forums.phpfreaks.com/topic/129061-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-669104 Share on other sites More sharing options...
munky334 Posted October 19, 2008 Author Share Posted October 19, 2008 thanx again. Link to comment https://forums.phpfreaks.com/topic/129061-solved-parse-error-syntax-error-unexpected-t_variable/#findComment-669255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.