Joe_Dean Posted February 12, 2009 Share Posted February 12, 2009 // Tests, if logged in function ssi_dotest($output_method = 'echo') { function curPageName() { return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); } global $context, $scripturl; $curPageName = curPageName(); if ($context['user']['is_guest']) { echo 'Please <a href="', $scripturl, '?action=login"><span>Login</span></a> or <a href="', $scripturl, '?action=register"><span>Register</span></a> to take this test.'; } else { include 'home/lvrcrcom/public_html/tests/', $curPageName, ''; } } I'm trying to include a page from within the the /tests/ directory of which has the same filename as the one in the current URL. It doesn't seem to work when I use include, but if I echo it, it seems to show the correct path. Parse error: syntax error, unexpected ',' in /home/lvrcrcom/public_html/forum/SSI.php on line 248 Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/ Share on other sites More sharing options...
Brian W Posted February 12, 2009 Share Posted February 12, 2009 Which line is 248? Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760491 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 else { include 'home/lvrcrcom/public_html/tests/', $curPageName, ''; } Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760494 Share on other sites More sharing options...
Adam Posted February 12, 2009 Share Posted February 12, 2009 Should be: else { include 'home/lvrcrcom/public_html/tests/' . $curPageName; } Adam Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760496 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 Thanks, it's working. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760497 Share on other sites More sharing options...
Brian W Posted February 12, 2009 Share Posted February 12, 2009 that makes since, duh. lol that just is using "." to concat rather than ",". There may be a problem with using "," because include is actually a function though it is not documented like one. http://us.php.net/include/ Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760498 Share on other sites More sharing options...
Adam Posted February 12, 2009 Share Posted February 12, 2009 Includes a statement..technically. Adam Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760501 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 Ehh, well, the actual include sorta works but it's not working as I expected. I basically took a quiz script and included it onto a page, but when I try to answer the questions on the page, the quiz script doesn't go to the next question like it does if I were to go to the quiz script directly. A bit harder to explain, but look at these examples: http://www.lvrcr.com/test.php <-- the page in which I'm including the quiz on http://www.lvrcr.com/tests/test.php <-- the direct link to the quiz script You'll see that you can actually take the test using the direct link to the quiz, but you cannot on the page that's including the quiz. :/ Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760503 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 I guess I could try actually putting the quiz script inside my page so I don't have to use includes. Not sure if that will work though, but I'll give it a shot. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760505 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 Didn't work. lol, sorry, I'm new with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760516 Share on other sites More sharing options...
Brian W Posted February 12, 2009 Share Posted February 12, 2009 you may need to set the method for your form, but that's just a thought. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760517 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 The method shouldn't need to be changed, should it? If it did, it wouldn't work using the direct link either. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760520 Share on other sites More sharing options...
Adam Posted February 12, 2009 Share Posted February 12, 2009 Pass a parameter through the URL telling you what page / question to include. Then have the form from the quiz redirect to that page so you can progress through.. If that makes sense? Adam Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760526 Share on other sites More sharing options...
Brian W Posted February 12, 2009 Share Posted February 12, 2009 btw, I couldn't see the quiz on the include page because it wanted a login... make the method like this method="<?php echo $_SERVER['PHP_SELF']; ?>" EDIT/PS: Adam, your totally right about include being a statement. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760530 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 I edited it so you don't have to login/register to see it. Brian, I'm not totally sure how to implement that into the script. There are a few instances, but all form tags look like this: echo "<form action=\"$PHP_SELF\" method=\"post\">\n"; Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760550 Share on other sites More sharing options...
Brian W Posted February 12, 2009 Share Posted February 12, 2009 echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n"; and your right, its action, not method. I'm getting another cup of coffee and getting off of phpfreaks. May be doing more damage than I am helping. **** Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760552 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 Still doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760554 Share on other sites More sharing options...
Brian W Posted February 12, 2009 Share Posted February 12, 2009 I looked at http://www.lvrcr.com/tests/test.php the form action still isn't showing up. Did you implement the change? I noticed an issue. PHP_SELF gets returns the path from root, so you need echo "<form action=\"http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."\" method=\"post\">\n"; Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760560 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 Still doesn't work. As I mentioned before, I just implemented the quiz script into the page itself so no includes are being used (this was my noobish attempt to see if it fixed things, but it doesn't ) Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760574 Share on other sites More sharing options...
Brian W Posted February 12, 2009 Share Posted February 12, 2009 Please post the code for the quiz (the php processing part and the form). Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760611 Share on other sites More sharing options...
gizmola Posted February 12, 2009 Share Posted February 12, 2009 The test script is using some sort of technique to track the user's progress through the quiz. Without understanding it there is no way to help you understand why it's broken. We need the source code for the quiz script. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760661 Share on other sites More sharing options...
Joe_Dean Posted February 12, 2009 Author Share Posted February 12, 2009 It's a very small script: http://www.lvrcr.com/quiz.php.txt Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-760728 Share on other sites More sharing options...
Joe_Dean Posted February 13, 2009 Author Share Posted February 13, 2009 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-761362 Share on other sites More sharing options...
gizmola Posted April 15, 2009 Share Posted April 15, 2009 If that server actually resolved so we could see the code, there might be some progress, but alas, it doesn't. Quote Link to comment https://forums.phpfreaks.com/topic/144929-help-please-php-noob/#findComment-810348 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.