WatsonN Posted May 15, 2010 Share Posted May 15, 2010 I'm writing a php page that will take the url variable and depending on the variable it will load diffrent pages. But i keep getting the error Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' on line 8 And i'm not sure what needs to happen in the code to fix this. <?php $url = (isset($_GET['p']) ? $_GET['p'] : home); ?> <?php if ($url == $1) { include('$l1'); } elseif ($url == $2) { include('$l2'); } elseif ($url == $3) { include('$l3'); } else { include('home'); } ?> <?php $1 = "foo1" $2 = "foo2" $3 = "foo3" $home = "home.php" $l1 = "bar1.php" $l2 = "bar2.php" $l3 = "bar3.php" ?> So any help possible would be greatly appreciated Link to comment https://forums.phpfreaks.com/topic/201828-help-with-a-parse-error-syntax-error/ Share on other sites More sharing options...
trq Posted May 15, 2010 Share Posted May 15, 2010 Variable names cannot start with a number. Link to comment https://forums.phpfreaks.com/topic/201828-help-with-a-parse-error-syntax-error/#findComment-1058629 Share on other sites More sharing options...
WatsonN Posted May 15, 2010 Author Share Posted May 15, 2010 Thanks. I changed all the variables that started with a number to something like s1, s2, s3. but now I'm getting an Parse error: syntax error, unexpected T_VARIABLE on line 19 this is the new code <?php $url = (isset($_GET['p']) ? $_GET['p'] : home); ?> <?php if ($url == $s1) { include('$l1'); } elseif ($url == $s2) { include('$l2'); } elseif ($url == $s3) { include('$l3'); } else { include('$home'); } ?> <?php $s1 = "foo1" $s2 = "foo2" //Line 19 $s3 = "foo3" $home = "home.php" $l1 = "bar1" $l2 = "bar2" $l3 = "bar3" ?> And i made sure the Var didn't start with a number and I'm no longer getting the "T_LNUMBER" error. Link to comment https://forums.phpfreaks.com/topic/201828-help-with-a-parse-error-syntax-error/#findComment-1058932 Share on other sites More sharing options...
Daniel0 Posted May 15, 2010 Share Posted May 15, 2010 Statements need to be terminated with a semi-colon. Link to comment https://forums.phpfreaks.com/topic/201828-help-with-a-parse-error-syntax-error/#findComment-1058933 Share on other sites More sharing options...
WatsonN Posted May 15, 2010 Author Share Posted May 15, 2010 I knew i was forgetting something. Thank Ya Much Link to comment https://forums.phpfreaks.com/topic/201828-help-with-a-parse-error-syntax-error/#findComment-1058936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.