phpbeginner Posted April 11, 2007 Share Posted April 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/ Share on other sites More sharing options...
Orio Posted April 11, 2007 Share Posted April 11, 2007 You need to add a semicolon after each echo statement: <option value='<?php echo("$row_Recordset1['areatype']"); ?>'><?php echo ("$row_Recordset1['areatype']"); ?></option> Orio. Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226843 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226848 Share on other sites More sharing options...
Lumio Posted April 11, 2007 Share Posted April 11, 2007 <option value='<?php echo("{$row_Recordset1['areatype']}"); ?>'><?php echo ("{$row_Recordset1['areatype']}"); ?></option> Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226851 Share on other sites More sharing options...
kenrbnsn Posted April 11, 2007 Share Posted April 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226856 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 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 !!! Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226876 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226895 Share on other sites More sharing options...
sasa Posted April 11, 2007 Share Posted April 11, 2007 can we see 5 more lines before your code snippet Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226904 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 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 ! Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226925 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 can we see 5 more lines before your code snippet Thanks sasa but I'll continue to battle this on my own.....I do appreciate the help though ! Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226929 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 Anytime bud, at least now you will maybe learn something instead of having your code fixed for you and never learning how to fix it on your own. Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226932 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 well, maybe we should get them to shut the forums down......90% of posts in here are asking for help on code. Get well soon ! Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226937 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 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....??? Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226946 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226950 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 Nope, I'm good. Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226953 Share on other sites More sharing options...
sasa Posted April 11, 2007 Share Posted April 11, 2007 Parse error: parse error, unexpected T_VARIABLE you miss ; inline before Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226957 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 Thanks sasa, I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-226967 Share on other sites More sharing options...
phpbeginner Posted April 11, 2007 Author Share Posted April 11, 2007 Thanks to kenrbnsn and sasa.....I finally got it going, I appreciate your help and patience. Quote Link to comment https://forums.phpfreaks.com/topic/46595-solved-one-parse-error-to-another/#findComment-227025 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.