PHP help
- Started
- Last post
- 27 Responses
- sherman
Warning: main(): Failed opening 'blog.php?pg=1' for inclusion (include_path='.:/php/includes... in /var/www/html/_newsite/index.php on line 33
Is there another way to include a file other then
< ? php include("blog.php?pg=1"); ? >
- pkmlta0
is there a reason you are passing a variable if you plan to include this script in another? once included it should have access to any variables with in the container script.
- cosmo0
u can't pass variable in that manner. variables should be accessible to others automatically.
$blog = 1
include ("watever.php");
- fifty500
i've used PHP includes dozens of times before but never ran into a problem with them until today, mysteriously. I did things the way I always do but today I got the same error as Sherman and I'm not adept enough to fix it on my own. Any solutions?
- Anarchitect0
include() cannot 'understand' query strings.
make our variable accessible before your include statement.
- fifty500
i don't know what that means. i've used includes before, and I've even tried using the includes that have worked for me before but today it's just not working.
- Mimio0
You can use a GET in the include call? something seems wrong with that.
- Anarchitect0
//instead of
include('page.php?var=val');//use
$var = val;include('page.php');
also the problem you might have been experienced is the change in recent versions of php regarding global variables: for security reasons they're not accessible immediatelly after form posts and/or url query strings.
you should add this to the beggining of your script to retrieve all $_GET/$_POST vars:
foreach ($_REQUEST as $key => $value) $$key = $value;
- fifty500
everything's just a bit over my head. I just know how to do simple includes and that's about it. i appreciate your help but i think i'll leave it until the morning and get someone in my office to help me.
- justjeff0
you should add this to the beggining of your script to retrieve all $_GET/$_POST vars:
foreach ($_REQUEST as $key => $value) $$key = $value;
Anarchitect
(Nov 15 05, 10:50)That's actually a bad idea, and it's as flawed as allowing register_globals to be on in the first place.
You should only use vars from $_REQUEST, $_POST, and $_GET as you need them - pulling them globally at the start of a script can lead to very common programming bugs where an initialized variable is meant to imply a known state, and a tainted REQUEST can override privilleges.
This was the most common security hole in PHP scripts for about 2 years from 2001-2003, and caused the PHP camp to finally disable register_globals by default.
- Anarchitect0
I'm aware of that
but I avoid using names that can conflict with any existent super global.
- fifty500
I have no clue what you guys are going on about -_-
- foreign0
try using require/require_once.
http://www.php.net/require
- UndoUndo0
once a file has been included the code in the included file is just like hving it in the original file, scope is also the same. you don't need to pass variables to it. if you have a function inside the included file and you want to pass a var to it. do it with myfunction($var); and have it return something
just make sure you call the function after the file has been included!
- fifty500
well i fixed the parsing error but there's something wrong in my code:
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
}
it's giving me an error:
mysql_fetch_array(): supplied argument is not a valid MySQL result
- UndoUndo0
while ($row = mysql_fetch_array($result)) {
&myVar = $row['expectedVar'];}
is all you need
- fifty500
unfortunately not. it's still taking the piss.
- determinedmoth0
unfortunately not. it's still taking the piss.
fifty50
(Nov 16 05, 01:30)I'm my experience PHP probably thinks you're giving it away.
- determinedmoth0
Undo...
Was it you asking about MS SQL? We've a rather large project that will require PHP + MSSQL. Have you experience of this?
- UndoUndo0
hi Moth,
yeah i was asking about a GUI for MS SQL but its with VB ASP and not my arena...we have another guy onto it.
why have you decided to go with MS SQL over MYSQL??
- UndoUndo0
fifty50 try this i made a mistake
while ($row = mysql_fetch_array($result)) {
$myVar = $row['expectedVar'];}