Page 1 of 1

unexpected T_STRING

Posted: Wed Feb 11, 2004 11:05 pm
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.

Posted: Wed Feb 11, 2004 11:11 pm
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!!

Posted: Wed Feb 11, 2004 11:13 pm
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

Posted: Wed Feb 11, 2004 11:20 pm
by Illusionist
change

file_exists($path/$page))

to

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

and see if that works

Posted: Wed Feb 11, 2004 11:22 pm
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

Posted: Wed Feb 11, 2004 11:28 pm
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

Posted: Wed Feb 11, 2004 11:32 pm
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

Posted: Wed Feb 11, 2004 11:34 pm
by thoughtcriminal
the problem is definetly that the script doesn't seem to find the file, the rest of the script seems fine, mmm...

Posted: Wed Feb 11, 2004 11:42 pm
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.

Posted: Wed Feb 11, 2004 11:44 pm
by thoughtcriminal
yay!
<?php
$page = $_GET["page"];
if(file_exists("$page.php")) {include "$page.php";}
else
{include "profile.php";}
?>
works!