I've got a situation where I must make use of a php file "query.php" to appear take whether $_POST or $_GET value because the MySQL query. It appears such as this:

//verify data has been sent via POST or GET and set strings
//find supplied table name
    $strSuppliedTableName = $_POST['tblName'];
    $strSuppliedTableName = $_GET['tblName'];
    $strSuppliedTableName = 'roles';

//find supplied field name or default to all fields in the table
    $strSuppliedFieldName = $_POST['fieldName'];
else if(isset($_GET['fieldName'])){
    $strSuppliedFieldName = $_GET['fieldName'];
    $strSuppliedFieldName = '*';

//query db
$query = 'SELECT ' . $strSuppliedFieldName . ' FROM ' . $strSuppliedTableName;

$results = mysql_query($query) or die(mysql_error());

After that, I wish to include this file "query.php" in another file which will manage the outcomes. I am attempting to make this as modular as you possibly can.

......... (while loop, yadi yadi

However, I buy a mistake:

Warning: require_once(query.php?tblName=classes) [function.require-once]: unsuccessful to spread out stream: No such file or directory

Isn't it acceptable to pass through GET values for your incorporated file? PHP will not process this?

include/require both have a filename like a spec, not really a URI. PHP does not parse it as being a URI, what exactly you are trying will not work.

Better to setup an item the incorporated/needed file may then inspect.

You don't need to pass through variables inside a get or Publish like way when including or needing files, the variables are shared between your files, as lengthy because the values are positioned prior to the including happens.


file1.php known as as file1.php?var2=value2

$var1 = "value1";
$var2 = $_GET['value'];
include "file2.php";


echo $var1.' '.$var2;

will output:

value1 value2

Like a shortcut, you should use $_REQUEST inside, that is an amalgam from the _GET, _Publish, _COOKIE, and _Atmosphere superglobals. Exactyl which of them get into it's in check from the request_order .ini setting.

Alternatively, an absolutely reliable approach to check which METHOD you are handling is $_SERVER['REQUEST_METHOD']. This value is definitely set when handling an HTTP request, and will also be GET, Publish, Mind, etc... Unlike checking for the existence of an application area, it's absolutely reliable - the shape area might not be posted (unchecked checkbox?), it might be re-named within the HTML however, you forget to alter the script, etc...

For your require(), unless of course you specify a complete url (http://...), PHP will interpret its argument like a request a nearby file, and won't pass it with the HTTP layer. Unless of course you've got a file named query.php?tblName..., it will be "file not found" and also the require() fails.

the proper way to do that would be to define your computer data as variables inside your mother file after which inside your child file use individuals variables.
within the code you gave the parser searches for the file 'query.php?tblName=classes' and clearly it doesn't exist.