pcw Posted February 19, 2009 Share Posted February 19, 2009 I ma just trying to translate some perl code into php. However, when I run a syntax check on it, I get the following error: Parse error: parse error, unexpected T_VARIABLE in sb.php on line 297 $v = "yes"; if($v == ""); { if (preg_match_all("m/$v/i", $values{$k}) $out .= "checked"; # this is line 297 } } Does anyone know what I have done wrong, been stuck on this for the past hour :-( Quote Link to comment https://forums.phpfreaks.com/topic/146002-out-unexpected-t_variable-error/ Share on other sites More sharing options...
Philip Posted February 19, 2009 Share Posted February 19, 2009 a few things, but this should work: $v = "yes"; if(empty($v)) { if (preg_match_all("m/$v/i", $values{$k})) $out .= "checked"; } Where is out being set? You should be careful with trying to continue a variable that may not exist Quote Link to comment https://forums.phpfreaks.com/topic/146002-out-unexpected-t_variable-error/#findComment-766507 Share on other sites More sharing options...
pcw Posted February 19, 2009 Author Share Posted February 19, 2009 Thanks KingPhilip, that done the trick :-) Its ok, $out was set earlier in the script. The script is too loarge to paste here, so I just copied that section. Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/146002-out-unexpected-t_variable-error/#findComment-766511 Share on other sites More sharing options...
Mark Baker Posted February 19, 2009 Share Posted February 19, 2009 The real error here was the spurious ; in if($v == ""); { Quote Link to comment https://forums.phpfreaks.com/topic/146002-out-unexpected-t_variable-error/#findComment-766528 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.