After searching the forum for various different permutations of this question, I've still not found an answer that helps me so I'm asking here.
I've run into an issue on my live server and decided to use XAMPP in order to attempt to troubleshoot my problem. So basically I started out with a very simple setup:
I exported my live database, and then imported it into localhost/phpmyadmin.
I removed all users so that there is only one set of data to deal with.
Then I tried calling something like $user_data['first_name']; or something in my test.php page... below are images that show the setup of the database and my file structure, etc:
I do apologize for the dimensions of this image. I attempted to resize it to make it smaller however doing so made the text virtually unreadable so it is at its base size of 1585 by 106. Screenshot at http://valkyries.usa.cc/images/ref1.jpg
And here is the structure of my database: Screenshot at http://valkyries.usa.cc/images/ref2.jpg
Here is my file structure: Screenshot at http://valkyries.usa.cc/images/ref3.jpg
So rather than trying to work with the full site from my live server, I just copied the users.php and general.php from my live site which contains all the functions I need.
I have my main page, which at the moment is simply named test.php and includes the init.php file at the top:
- Code: Select all
<?php require "core/init.php";
?>
<html>
<head>
<title>Test Site</title>
</head>
<body>
<?php
echo "Hello world! $foo"
?>
</body>
My init.php:
- Code: Select all
<?php
session_start();
//error_reporting(0);
require 'database/connect.php'; // Tells where to look for database connection info.
require 'functions/general.php'; // Tells where to look for general functions.
require 'functions/users.php'; // Tells where to look for user related functions.
$current_file = explode('/', $_SERVER['SCRIPT_NAME']);
$current_file = end($current_file);
if (logged_in() === true) {
$session_user_id = $_SESSION['user_id'];
$user_data = user_data($session_user_id, 'user_id', 'username', 'password', 'first_name', 'last_name', 'email', 'legion_char', 'password_recover', 'rank', 'allow_emails', 'rules');
if (user_active($user_data['username']) === false){
session_destroy();
header('Location: index.php');
exit();
}
if ($current_file !== 'changepassword.php' && $current_file !== 'logout.php' && $user_data['password_recover'] == 1) {
$URL="changepassword.php?force";
echo '<META HTTP-EQUIV="refresh" content="0;URL=' . $URL . '">';
exit();
}
// Code for outputting specific data: echo $user_data['username'];
}
$errors = array();
?>
The Init.php does still include some things from my live server but I didn’t think they would really hurt anything. (Could be wrong?)
I tried to call one of the functions from users.php and received the undefined variable notice/error and so I tried defining
- Code: Select all
function foo(){
echo("foobar");
}
in the users.php file and that too gave me this notice/error:
Notice: Undefined variable: foo in C:\xampp\htdocs\a\test.php on line 9
So anyway I’m not entirely sure what the problem is, but perhaps you can help. Thanks!