Reputation: 171
I'm trying to debug my code (which honestly I'm not very good at and still trying to expand on those skills). How do I see the query string in my webpage from a separate php file? I put the query string into a variable and tried to echo the variable on the page but it killed my entire page.
PHP File:
$sqlCheck = "INSERT INTO change_of_address (parcel_id, address_1, address_2, City, State, Zip, Country) VALUES ('" . $parcel_id . "','" . $address1 . "','" . $address2 . "','" . $city . "','" . $state . "','" . $zip . "','" . $country . "')";
Webpage:
<?php
require_once('config.php');
require_once('classes/search.php');
require_once('classes/add-address.php');
echo $sqlCheck;
?>
The error I am getting is :
Warning: require_once(../config.php): failed to open stream:
No such file or directory in
/var/www/lcv-data-website/classes/add-address.php and ( ! )
Fatal error: require_once(): Failed opening required '../config.php'
(include_path='.:/usr/share/php:/usr/share/pear') in
/var/www/lcv-data-website/classes/add-address.php on line 2
Upvotes: 0
Views: 106
Reputation: 94662
First of all query string
is normally used to describe the values passed on the URL after the ?
character i.e. example.com/script.php?a=1&b=2&c=3
Your issue is nothing to do with displaying the value of the variable $sqlCheck;
.
If you actually read the error message it is saying I cannot find the file you are trying to include using the require_once
command
Remember that the include
and require
functions expect the path to the file that you are including to be relative to the location of the script that they are located in.
As you statement is require_once('config.php');
then PHP expects to find it in the same directory as this script.
I would therefore assume that config.php
does not exist in the same directory as the script The second error message is saying that PHP also cannot find this file in any of the directories that you (or someone) have configure the PHP search path to be either.
Change the statement so that the require_once('config.php');
is correctly path'd
Upvotes: 1