Jump to content

Recommended Posts

I'm having a problem with a PHP parse error coming from a variable and I can't tag down the source of the issue.  I'm not extremely experienced in PHP which may very well be the problem, but I have exhausted every measure I know to fix the issue and nothings working.  I'm not sure why it's throwing back an error from a variable...I thought that as long as I had everything in the parentheses it would take it for surface value and not examine the code within it.  I also have put slashes in front of all of the parentheses within the variable.  Let me show you what I'm getting:

 

Parse error: parse error, unexpected T_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/g/a/r/gardenrelics/html/PHPscripts/do_addinv3.php on line 133

 

I won't include all of my code since it is rather lenghty, but I will include the part that relates the most.  I have also tryed to make line 133 stand out a bit...it's more towards the bottom:

 

//IF user hasn't yet submitted information
if ($_POST[part_num] == NULL || $_POST[part_name] == NULL) {
$pagedisp == "<h1>Add an item to inventory</h1>
<FORM METHOD=\"POST\" ACTION=\"do_addinv3.php\">
<P><em>General Information:</em></P>

<P><STRONG>Part Number:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"part_num\" SIZE=14 MAXLENGTH=10></P>

<P><STRONG>Product Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"part_name\" SIZE=50 MAXLENGTH=100></P>

<P><STRONG>Set of: </STRONG>
<INPUT TYPE=\"text\" NAME=\"peices\" SIZE=6 MAXLENGTH=10></P>

<P><STRONG>Product Description:</STRONG> (if entered, this will be displayed on the product page)<BR>
<TEXTAREA NAME=\"part_desc\" COLS=50 ROWS=5 WRAP=virtual></textarea></P>

<P><STRONG>Finish:</STRONG><BR>
  <select name=\"finish\" id=\"finish\">
<option value=\"aged\" selected>aged</option>
<option value=\"bamboo\">bamboo</option>
<option value=\"blp\">BLP</option>
<option value=\"cham\">cham</option>
<option value=\"fountain\">fountain</option>
<option value=\"glazed\">glazed</option>
<option value=\"metal\">metal</option>
<option value=\"rustic\">rustic</option>
<option value=\"rv\">RV</option>
<option value=\"sand finish\">sand finish</option>
<option value=\"sandstone\">sandstone</option>
<option value=\"test\">test</option>
<option value=\"toadstools\">toadstools</option>
  </select>
</P>

<P><STRONG>Color:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"color\" SIZE=35 MAXLENGTH=100></P>

<STRONG>NOTE:</STRONG><em> All dimensions are in inches.  Please type in numbers only.</em><br><br>
<fieldset><STRONG>Size 1 Name: </STRONG>(ex: large, small)<BR>
<INPUT TYPE=\"text\" NAME=\"size1name\" SIZE=10 MAXLENGTH=25>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width\" SIZE=8 MAXLENGTH=8></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height\" SIZE=8 MAXLENGTH=8></P></fieldset>

<P><fieldset><STRONG>Size 2 Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"size2name\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width2\" SIZE=8 MAXLENGTH=8></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height2\" SIZE=8 MAXLENGTH=8></P></fieldset>

<P><fieldset><STRONG>Size 3 Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"size3name\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width3\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height3\" SIZE=10 MAXLENGTH=25></P></fieldset>

<P><fieldset><STRONG>Size 4 Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"size4name\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width4\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height4\" SIZE=10 MAXLENGTH=25></P></fieldset>

<P><fieldset><STRONG>Size 5 Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"size5name\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width5\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height5\" SIZE=10 MAXLENGTH=25></P></fieldset>

<P><em>Product Availibilty:</em></P>

<P><STRONG>Current Ammount in Stock:</STRONG><BR>
<INPUT TYPE=\"int\" NAME=\"in_stock\" SIZE=10 MAXLENGTH=10></P>

<P><STRONG>Current Ammount on Order:</STRONG><BR>
<INPUT TYPE=\"int\" NAME=\"on_order\" SIZE=10 MAXLENGTH=10></P>

<P><em>Product Pricing:</em></P>

<P><STRONG>Wholesale Price:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"whole_price\" SIZE=10 MAXLENGTH=10></P>

<P><STRONG>Retail Price:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"ret_price\" SIZE=10 MAXLENGTH=10></P>

<input type='hidden' name='submitted' value='TRUE' id='<?=time();?>' >
  <input type='hidden' name='MAX_FILE_SIZE' value='<?=$max_file_size;?>' >
<?   for($x=0;$x<$num_of_uploads;$x++){
     $form .= \"<input type='file' name='file[]'><br />\";
   }
   $form .= \"<br />
   <font color='red'>*</font>Maximum file length (minus extension) is 15 characters. Anything over that will be cut to only 15 characters. Valid file type(s): \";
   for($x=0;$x<count($file_types_array);$x++){
     if($x<count($file_types_array)-1){
       $form .= $file_types_array[$x].\", \";
     }else{

       $form .= $file_types_array[$x].\".\";
     }
   }
    echo($form);

if(isset($_POST[\"submitted\"])){     THIS IS LINE 133  --  THIS IS LINE 133 -- THIS IS LINE 133 -- 
    uploaderFILES($num_of_uploads, $file_types_array, $max_file_size, $upload_dir);
}
?> 

<!-- Cancel for now <P><STRONG>Picture Link:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc\" SIZE=75 MAXLENGTH=100></P>

<P><STRONG>Extra Picture Link 1 (if applicable):</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc2\" SIZE=75 MAXLENGTH=100></P>

<P><STRONG>Extra Picture Link 2 (if applicable):</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc3\" SIZE=75 MAXLENGTH=100></P>

<P><STRONG>Extra Picture Link 3 (if applicable):</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc4\" SIZE=75 MAXLENGTH=100></P>

<P><STRONG>Extra Picture Link 4 (if applicable):</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc5\" SIZE=75 MAXLENGTH=100></P> -->

<P><INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Enter Item Into Inventory\"></P>
</FORM>

<P><a href=\"cntrconmgrgrbw.php\">Go Back to Main Menu</a></P>";
}

 

I appreciate any help in advance.  PLEASE SAVE ME FROM MY OWN CODE!  ;D

 

-Mark

Link to comment
https://forums.phpfreaks.com/topic/68057-parse-error/
Share on other sites

try:

if(isset($_POST['submitted'])){   

 

Good suggestion...I tried it a bit earlier and got another parse:

 

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/g/a/r/gardenrelics/html/PHPscripts/do_addinv3.php on line 133

Link to comment
https://forums.phpfreaks.com/topic/68057-parse-error/#findComment-342127
Share on other sites

hmmm...I think your issues go a little bit deeper then that. I found a lot of extra excapes in your code that could have been messing it up. Try this:

<?php 

//IF user hasn't yet submitted information
if ($_POST[part_num] == NULL || $_POST[part_name] == NULL) {
$pagedisp == "<h1>Add an item to inventory</h1>
<FORM METHOD=\"POST\" ACTION=\"do_addinv3.php\">
<P><em>General Information:</em></P>

<P><STRONG>Part Number:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"part_num\" SIZE=14 MAXLENGTH=10></P>

<P><STRONG>Product Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"part_name\" SIZE=50 MAXLENGTH=100></P>

<P><STRONG>Set of: </STRONG>
<INPUT TYPE=\"text\" NAME=\"peices\" SIZE=6 MAXLENGTH=10></P>

<P><STRONG>Product Description:</STRONG> (if entered, this will be displayed on the product page)<BR>
<TEXTAREA NAME=\"part_desc\" COLS=50 ROWS=5 WRAP=virtual></textarea></P>

<P><STRONG>Finish:</STRONG><BR>
  <select name=\"finish\" id=\"finish\">
<option value=\"aged\" selected>aged</option>
<option value=\"bamboo\">bamboo</option>
<option value=\"blp\">BLP</option>
<option value=\"cham\">cham</option>
<option value=\"fountain\">fountain</option>
<option value=\"glazed\">glazed</option>
<option value=\"metal\">metal</option>
<option value=\"rustic\">rustic</option>
<option value=\"rv\">RV</option>
<option value=\"sand finish\">sand finish</option>
<option value=\"sandstone\">sandstone</option>
<option value=\"test\">test</option>
<option value=\"toadstools\">toadstools</option>
  </select>
</P>

<P><STRONG>Color:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"color\" SIZE=35 MAXLENGTH=100></P>

<STRONG>NOTE:</STRONG><em> All dimensions are in inches.  Please type in numbers only.</em><br><br>
<fieldset><STRONG>Size 1 Name: </STRONG>(ex: large, small)<BR>
<INPUT TYPE=\"text\" NAME=\"size1name\" SIZE=10 MAXLENGTH=25>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width\" SIZE=8 MAXLENGTH=8></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height\" SIZE=8 MAXLENGTH=8></P></fieldset>

<P><fieldset><STRONG>Size 2 Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"size2name\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width2\" SIZE=8 MAXLENGTH=8></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height2\" SIZE=8 MAXLENGTH=8></P></fieldset>

<P><fieldset><STRONG>Size 3 Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"size3name\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width3\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height3\" SIZE=10 MAXLENGTH=25></P></fieldset>

<P><fieldset><STRONG>Size 4 Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"size4name\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width4\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height4\" SIZE=10 MAXLENGTH=25></P></fieldset>

<P><fieldset><STRONG>Size 5 Name:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"size5name\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Width:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"width5\" SIZE=10 MAXLENGTH=25></P>

<P><STRONG>Height:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"height5\" SIZE=10 MAXLENGTH=25></P></fieldset>

<P><em>Product Availibilty:</em></P>

<P><STRONG>Current Ammount in Stock:</STRONG><BR>
<INPUT TYPE=\"int\" NAME=\"in_stock\" SIZE=10 MAXLENGTH=10></P>

<P><STRONG>Current Ammount on Order:</STRONG><BR>
<INPUT TYPE=\"int\" NAME=\"on_order\" SIZE=10 MAXLENGTH=10></P>

<P><em>Product Pricing:</em></P>

<P><STRONG>Wholesale Price:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"whole_price\" SIZE=10 MAXLENGTH=10></P>

<P><STRONG>Retail Price:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"ret_price\" SIZE=10 MAXLENGTH=10></P>

<input type='hidden' name='submitted' value='TRUE' id='".time()."' >
  <input type='hidden' name='MAX_FILE_SIZE' value='".$max_file_size."' >";
  for($x=0;$x<$num_of_uploads;$x++){
     $form .= "<input type='file' name='file[]'><br />";
   }
   $form .= "<br /><font color='red'>*</font>Maximum file length (minus extension) is 15 characters. Anything over that will be cut to only 15 characters. Valid file type(s):";
   for($x=0;$x<count($file_types_array);$x++){
     if($x<count($file_types_array)-1){
       $form .= $file_types_array[$x].", ";
     }else{
       $form .= $file_types_array[$x].".";
     }
   }
    echo($form);

if(isset($_POST['submitted'])){
    uploaderFILES($num_of_uploads, $file_types_array, $max_file_size, $upload_dir);
}
$form .= "

<!-- Cancel for now <P><STRONG>Picture Link:</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc\" SIZE=75 MAXLENGTH=100></P>

<P><STRONG>Extra Picture Link 1 (if applicable):</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc2\" SIZE=75 MAXLENGTH=100></P>

<P><STRONG>Extra Picture Link 2 (if applicable):</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc3\" SIZE=75 MAXLENGTH=100></P>

<P><STRONG>Extra Picture Link 3 (if applicable):</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc4\" SIZE=75 MAXLENGTH=100></P>

<P><STRONG>Extra Picture Link 4 (if applicable):</STRONG><BR>
<INPUT TYPE=\"text\" NAME=\"pic_loc5\" SIZE=75 MAXLENGTH=100></P> -->

<P><INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Enter Item Into Inventory\"></P>
</FORM>

<P><a href=\"cntrconmgrgrbw.php\">Go Back to Main Menu</a></P>";
}

?>

 

...another hint that will help you out, try not to output that much html in php. It would be a lot easier on you if you stop the php write the html then start the php again.

Link to comment
https://forums.phpfreaks.com/topic/68057-parse-error/#findComment-342143
Share on other sites

Your problem is line 1

you haven't started your PHP tag

and then you faile to close the variable

 

problem one:

//IF user hasn't yet submitted information
if((!$_POST['part_num'])||(!$_POST['part_name'])) {
$pagedisp == "<h1>Add an item to inventory</h1>

 

and problem two:

 <?
 for($x=0;$x<$num_of_uploads;$x++){
    $form .= \"<input type='file' name='file[]'><br />\";
  }

Link to comment
https://forums.phpfreaks.com/topic/68057-parse-error/#findComment-342145
Share on other sites

hmmm...I think your issues go a little bit deeper then that. I found a lot of extra excapes in your code that could have been messing it up. Try this:

 

...another hint that will help you out, try not to output that much html in php. It would be a lot easier on you if you stop the php write the html then start the php again.

 

In this particular code I need it to decypher whether or not the user has entered information and then choose which html layout to give the page...so I have to have alot of HTML in the PHP.  Also the code you sent breaks up all of the HTML that I want contained in the variable $pagedisp.

Link to comment
https://forums.phpfreaks.com/topic/68057-parse-error/#findComment-342150
Share on other sites

Your problem is line 1

you haven't started your PHP tag

and then you faile to close the variable

 

problem one:

//IF user hasn't yet submitted information
if((!$_POST['part_num'])||(!$_POST['part_name'])) {
$pagedisp == "<h1>Add an item to inventory</h1>

 

and problem two:

 <?
 for($x=0;$x<$num_of_uploads;$x++){
    $form .= \"<input type='file' name='file[]'><br />\";
  }

 

Yeah I already modified the if statement at the top because it wasn't displaying.....but the issue I'm having ATM is that my file upload section isn't showing up.  suggestions?

Link to comment
https://forums.phpfreaks.com/topic/68057-parse-error/#findComment-342152
Share on other sites

1. try this:

$number_of_files = count($_FILES['file']['name']);
for($i=0; $i<=$number_of_files; $i++)
{
#	Loop
if( (isset($_FILES['file']['name'][$i])) && (!empty($_FILES['file']['name'][$i])) )
{	#	If upload is specified
	$upload_dir = "/uploads/";	#	Where to mvoe files to
	$new_filename = md5(time()*rand()) . substr(basename($_FILES['file']['name'][$i]), -4);	#	Rename
	move_uploaded_file($_FILES['file']['tmp_name'][$i], $upload_dir . $new_filename);	#	Move uploaded file
}
}

 

2. I would not suggest using hidden fields for validation; becuase they can be edited

and made larger.

Link to comment
https://forums.phpfreaks.com/topic/68057-parse-error/#findComment-342158
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.