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 Commented Feb 8, 2013 at 18:55
  • 2
    Do you have a file called “AccountView.php?id=” on your server? Commented 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. Commented Feb 8, 2013 at 18:56
  • Are you sure you want to do an include and not a redirect? Commented 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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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 Comments

Thanks! How would I pass the variable $ID to the next program?
@user2055499 It's within the scope of your parent script. You would just call it in AccountView.php

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.