0

I'm trying to load another page using the include statement but I keep getting the error:

Warning: include(AccountView.php?id=) [function.include]: failed to open stream: No such file or directory in /home/public_html/InsertAccount.php on line 62 

$return = "AccountView.php?id=".$ID;
include $return;

I'm not sure what I'm missing to make this perform correctly. Another set of eyes would really be great.

4
  • 6
    When you include a local file, you can't use GET parameters
    – Pekka
    Feb 8, 2013 at 18:55
  • 2
    Do you have a file called “AccountView.php?id=” on your server? Feb 8, 2013 at 18:55
  • As an addendum to @Pekka웃's comment, when you include a PHP file, it will receive all variables in scope at which the include statement is executed. You could use your $ID variable that way.
    – ajp15243
    Feb 8, 2013 at 18:56
  • Are you sure you want to do an include and not a redirect? Feb 8, 2013 at 19:00

2 Answers 2

1

There's no file with this name:

AccountView.php?id=

The ?id= part is killing you. You're trying to include an URL there, not a filename.

1
  • Thats correct, sorry. I am trying to include the url with the variable $return. Yes, the file exists and is functioning correctly. I'm trying to return to that page after performing an update to a table. Feb 8, 2013 at 19:15
1

Unless you have a file called AccountView.php?id=.php, this won't work.

What you want to do is set the variable ($ID), include your file and then use $ID in the included file:

$ID = '5';
$return = "AccountView.php";
include $return;
2
  • Thanks! How would I pass the variable $ID to the next program? Feb 8, 2013 at 19:31
  • @user2055499 It's within the scope of your parent script. You would just call it in AccountView.php
    – Kermit
    Feb 8, 2013 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.