Jump to content

Recommended Posts

I been having trouble with an editing form for a real estate site. I want to grab areas selected from a table in this form but show the current area from another table. I originally had this error .....

 

parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

 

changed my code and now ......

 

Parse error: parse error, unexpected T_VARIABLE

 

Here is the snippet of code where I am getting the dreaded parse errors.....

 

<option selected=\"$a_row[area]\"> $a_row[area]</option>  
<?php 
do { 
?>    
<option value='<?php echo("$row_Recordset1['areatype']")?>'><?php echo ("$row_Recordset1['areatype']") ?></option>
<?php 
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); 
$rows2 = mysql_num_rows($Recordset1); 
if($rows2 > 0) { 
mysql_data_seek($Recordset1, 0); 
$row_Recordset1 = mysql_fetch_assoc($Recordset1); 
$a_row[area]=$row_Recordset1['areatype'];
} 
?>

 

Thanks in Advance

Link to comment
https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/
Share on other sites

Thanks for the response Orio but I get the exact same error....

 

Parse error: parse error, unexpected T_VARIABLE on line 264

 

which is this line

 

<option value='<?php echo("$row_Recordset1['areatype']"); ?>'><?php echo ("$row_Recordset1['areatype']"); ?></option>

The problem on this line

<option value='<?php echo("$row_Recordset1['areatype']")?>'><?php echo ("$row_Recordset1['areatype']") ?></option>

is not missing semi-colons (which you don't need if you only have one line between the "<?php" and "?>", but the mixture of double quotes and single quotes when using array references. There are three ways of fixing this error:

1)

<option value='<?php echo $row_Recordset1['areatype'] ?>'><?php echo $row_Recordset1['areatype'] ?></option>

 

2)

<option value='<?php echo("{$row_Recordset1['areatype']}")?>'><?php echo ("{$row_Recordset1['areatype']}") ?></option>

 

3)

<?php
echo '<option value="' . $row_Recordset1['areatype'] . '"> . $row_Recordset1['areatype'] . '</option>';
?>

 

If you use the third option, delete the "?>" preceding that line and the "<?php" after it. I would use the third option.

 

Ken

 

Yeah, this is why I have posted this, it's been giving me a damn headache......Here is what i have tried and what has happened.

 

Code 1 gives me this error

parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

 

Code 2 gives me this

unexpected '{'

 

And Code 3 gives me

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING

 

I appreciate all the help you guys are giving me on this !!!

 

Ken made a mistake, forgive him for setting the grounds and you not being able to debug php.

 

<?php
echo '<option value="' . $row_Recordset1['areatype'] . '">' . $row_Recordset1['areatype'] . '</option>';
?>

 

As for this code you wrote, it is a huge mess. I would suggest you learn PHP syntax correctly before proceeding. Do some unit tests on different scenarios and see how stuff works. Because parse errors are the easiest thing to fix, I mean it tells you exactly what error it is and where it is.

Wow, thanks for all the help frost110. I really appreciate the comments ( huge mess, learn php syntax correctly, etc..)

 

I'll get in touch with you to see if I am at the proper level before I post again in the forums. I have several forums which are used for a number of different reasons and I must say, we tend to help people out rather than tell them to go learn more before proceeding.

 

I did a search and have found a huge amount of threads on parse errors.....so I guess I'm not alone on this topic. Some find it just so easy to criticize. Have a good one !  

lol, you know what the sad part is. I looked at all of your posts, you only ask for help, never even bothered to try to help someone. Now tell me, where is my motivation to help someone who just takes and takes and never gives back the community?

 

hmmmm....???

phpbeginner <--- ! I am certainly not proficient, as you had already pointed out, but I am trying. I found these forums to be of help and mostly very friendly. If I was more experienced and confident I would certainly help out. There are many forums other than PHP where I offer help and support and give back. 

 

I'm sure you'll have something else to say though.

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.