By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

help with echoing out the url

P: 80
hi this should work but i do not know why its not working


Expand|Select|Wrap|Line Numbers
  1.  
  2. $url = $_GET['url'];
  3. echo $url;
  4.  
  5.  
Mar 12 '12 #1

✓ answered by Rabbit

Looks like the errors stem from line 3 and cascade downwards. It's saying that the url variable isn't being passed in GET. Look at the form that is submitted and make sure there's a form control with the name url.

Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,347
What do you mean by not working? Are there error messages? If so, what are they? Is it not printing out the value that was passed? If so, what value was passed and what did it print instead?
Mar 12 '12 #2

P: 80
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $url = $_GET["url"];
  4. echo $url;
  5.  
  6.  
  7. require 'controllers/' .$url;
  8.  
  9. $controller = new $url;
  10.  
  11.  
  12.  
  13. ?>
  14.  
  15.  
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. class Index {
  4.  
  5.     function __construct() {
  6.  
  7.         echo 'we are in index'; 
  8.     }
  9. }
  10.  
  11. ?>
  12.  
  13.  
error:

( ! ) Notice: Undefined index: url in C:\wamp\www\mvc\index.php on line 3
Call Stack
# Time Memory Function Location
1 0.0008 364448 {main}( ) ..\index.php:0

( ! ) Warning: require(C:\wamp\www\mvc\controllers) [function.require]: failed to open stream: Permission denied in C:\wamp\www\mvc\index.php on line 7
Call Stack
# Time Memory Function Location
1 0.0008 364448 {main}( ) ..\index.php:0

( ! ) Fatal error: require() [function.require]: Failed opening required 'controllers/' (include_path='.;C:\php\pear') in C:\wamp\www\mvc\index.php on line 7
Call Stack
# Time Memory Function Location
1 0.0008 364448 {main}( ) ..\index.php:0
Mar 13 '12 #3

Rabbit
Expert Mod 10K+
P: 12,347
Looks like the errors stem from line 3 and cascade downwards. It's saying that the url variable isn't being passed in GET. Look at the form that is submitted and make sure there's a form control with the name url.
Mar 13 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.