Page 1 of 1

Register and Login errors

Posted: Sat Jan 28, 2012 7:34 pm
by AndrewD92
Hey! I'm doing programming as part of my computing uni course. I'm still a beginner but I want to learn. I'm taking things slowly and following the videos step by step. I'm up to Register and Login (User Account System), which I think is the third or forth playlist. Everything else I done works perfectly!

The errors I have is: (I have copied the errored lines)

Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\user_system\core\init.inc.php on line 7
<?php
 
session_start();
 
$exceptions = array('register', 'login');
 
$page = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])), 0, -4);
 
if (in_array($page, $exceptions) === false){
        if (isset($_SESSION['username']) === false){
                header('Location: login.php');
                die();
        }
}
 
mysql_connect('localhost', 'root', '');
mysql_select_db('user_system');

$path = dirname(__FILE__);
 
include("{$path}/inc/user.inc.php");

?>
(SOLVED THE OTHER 2)

Re: Register and Login errors

Posted: Sat Jan 28, 2012 10:33 pm
by jacek
Yeah this is a pain, essentially the problem is that php wants you to do
$page = explode('/', $_SERVER['SCRIPT_NAME']);
$page = end($page)l
$page = substr($page, 0, -4);
instaead of
$page = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])), 0, -4);
i.e separating all of the functions.

It's very convenient to be able to pass a function to another function though so you can just hide these messages which is what I do by doing
error_reporting(E_ALL & ~E_STRICT);
at the top of your file.

Re: Register and Login errors

Posted: Sat Jan 28, 2012 11:11 pm
by AndrewD92
Wow. Your so totally going to be my best friend for the next 3 years :D

Your tutorials are extremely good by the way. Clean, clear and easy to follow. Much better than a lecturer. Thanks for a personal reply!

Re: Register and Login errors

Posted: Tue Jan 31, 2012 6:10 pm
by jacek
AndrewD92 wrote:Your tutorials are extremely good by the way. Clean, clear and easy to follow. Much better than a lecturer. Thanks for a personal reply!
No problem :D Thank you for the nice things you said :D