Author Topic: help with include_once  (Read 6624 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
help with include_once
« on: November 27, 2017, 03:26:02 PM »
Hi guys,

At first i thought this may be a database problem but i think its a php problem somehow..

here is the gist.. i cannot run any queries on a database using the mysql_query function, it comes back with the error access denied for user ''@'localhost'(Using password NO)

anyway.. i have been doing some additional work and investigation and i have found that for some reason my settings file is not being processed properly..

let me explain..

i have a file, i have called settings.php which contains the DB connection string, as well as a login checker system that verifies if a user is logged in, if not it changes the page that is displayed..

Now, every page on my site, loads up and the first command used is

Include_once("settings.php");

so this should pull the settings file into the page.. however

to display the page required i use a variable called $pagetoshow
if a user is not logged in the page to show variable is set to Login
the script then calls the page in the following manner

iframe src="<? echo $pagetoshow; ?>.php"

now.. if i place the login code on the actual page, it works fine. but when its in the settings file its not working..

any ideas as to why the script is not being processed, and the page updated accordingly?

cheers
any help apreciated..

keith

Offline
*
Re: help with include_once
« Reply #1 on: November 27, 2017, 03:28:32 PM »
ADDITIONAL INFO

There is no problem sending variables from one page to another, my login form sends both the username and password across to a second script no problem, of course i cant use the data to check the db because of the settings file not being included properly..

Cheers
keith

Offline
*
Re: help with include_once
« Reply #2 on: November 27, 2017, 07:02:35 PM »
ADDITIONAL

ok.. so after further investigation there is somehting strange happening..

i have a html page. set up. which creates a table and puts an image inside the table.. now. if i set a variable, lets say $totalcost = 100; at the top of the page, and then put echo $totalcost at hte bottom of hte page, nothing shows..

however if i put the $totalcost = 100 a line or two above the echo statement it prints the variable to the screen.. for example

Code: [Select]
<?
$totalcost = 100;
?>
<html>
<head>
</head>
<body>
</body>
</html>
<?
echo $totalcost;
?>
 

This does not work

Code: [Select]
<html>
<head>
</head>
<body>
</body>
<?
$totalcost = 100;
?>
</html>
<?
echo $totalcost;
?>

This works..

i really dont understand this