unexpected T_STRING

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thoughtcriminal
Forum Newbie
Posts: 6
Joined: Wed Feb 11, 2004 11:05 pm

unexpected T_STRING

Post by thoughtcriminal »

i am trying to write a dating site and am using mod_rewrite so, faceparty/paul = faceparty/?page=profile.php&user=paul, but also want to have faceparty/introduction = faceparty/?page=introduction. i am currently using this code

<?php
$page = $_GET["page"];
$path="C:/Apache/htdocs/faceparty";
if(file_exists($path/$page)) {include "$page.php";}
else
{include "profile.php&user=$page;}
;?>

which is returning this error message:

Parse error: parse error, unexpected T_STRING in C:\Apache\htdocs\faceparty\index.php on line 29

line 29 being ";?>".

any ideas what went wrong? i'm sorry if i've left out something stupid, i've tried changing the slashes direction as it's on windows, it's 5 am, so i apologise in adance if i have done something stupid.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

try changing

Code: Select all

include "profile.php&user=$page;
to

Code: Select all

include "profile.php&user=$page";
You jsut forgot the last quote!!
thoughtcriminal
Forum Newbie
Posts: 6
Joined: Wed Feb 11, 2004 11:05 pm

Post by thoughtcriminal »

damn, i can't believe that! i'm such a gimboid! thanks.
now i'm getting...

Warning: Division by zero in C:\Apache\htdocs\faceparty\index.php on line 25

Warning: main(profile.php&user=poo): failed to open stream: No such file or directory in C:\Apache\htdocs\faceparty\index.php on line 27

Warning: main(): Failed opening 'profile.php&user=poo' for inclusion (include_path='.;c:\php4\pear') in C:\Apache\htdocs\faceparty\index.php on line 27
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

change

file_exists($path/$page))

to

file_exists($path . "/" . $page))

and see if that works
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

and oh ya, you can't do an include like that... include only include a file it wont allow you pass information to though it... atleast i dont think it will. It never has when i've tried anything
thoughtcriminal
Forum Newbie
Posts: 6
Joined: Wed Feb 11, 2004 11:05 pm

Post by thoughtcriminal »

i tried that, and the response was the same as if i used:

<?php
$page = $_GET["page"];
if(file_exists($page.php)) {include "$page.php";}
else
{include "profile.php&user=$page";};
?>

which is, say if i went to faceparty/paul

Warning: main(profile.php&user=pauk): failed to open stream: No such file or directory in C:\Apache\htdocs\faceparty\index.php on line 26

Warning: main(): Failed opening 'profile.php&user=paul' for inclusion (include_path='.;c:\php4\pear') in C:\Apache\htdocs\faceparty\index.php on line 26
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Illusionist wrote:and oh ya, you can't do an include like that... include only include a file it wont allow you pass information to though it... atleast i dont think it will. It never has when i've tried anything
thoughtcriminal
Forum Newbie
Posts: 6
Joined: Wed Feb 11, 2004 11:05 pm

Post by thoughtcriminal »

the problem is definetly that the script doesn't seem to find the file, the rest of the script seems fine, mmm...
thoughtcriminal
Forum Newbie
Posts: 6
Joined: Wed Feb 11, 2004 11:05 pm

Post by thoughtcriminal »

ok, yeah, cool, thanks.
i changed profile.php accordingly, so it reads $page and changes it to $user.
the script seems to go straight to that party, it doesn't seem to find $page and automatically includes profile, i think maybe i shouyld be abl to work out the problem myself, thanks for your help though.
thoughtcriminal
Forum Newbie
Posts: 6
Joined: Wed Feb 11, 2004 11:05 pm

Post by thoughtcriminal »

yay!
<?php
$page = $_GET["page"];
if(file_exists("$page.php")) {include "$page.php";}
else
{include "profile.php";}
?>
works!
Post Reply