I have been painstackinly over this code over a million trillon times. I have not found second instance of that function. Someone made a suggestion that I may be including a file that has the function redefined twice but I am not doing that either. All I am doing is including my function pages into an initialization file and then including the initialization in all my other files that need access to the functions. Well here is the code:
// functions page
[php]<?php
function logged_in(){
return (isset($_SESSION['id'])) ? TRUE : FALSE;
}
function update_users($update_data){
array_walk($update_data, 'array_sanitize');
foreach($update_data as $fields => $data){
$update[] = '`' .$field. '` = \'' .$data. '\'';
}
mysql_query("UPDATE `Users` SET " . implode(', ', $update) . " WHERE `id` = " . $_SESSION['id'] . "") or die(mysql_error());
}
function register_users($register_data){
array_walk($register_data, 'array_sanatize');
$register_data['password'] = md5($register_data['password']);
$fields = '`' . implode('`, `', array_keys($register_data)) . '`';
$data = '\'' . implode('\', \'', $register_data) . '\'';
mysql_query(“INSERT INTO Users
($fields) VALUES($data)”);
$to = $register_data[‘email’];
$subject = ‘Activate your account’;
$body = “Hello {$register_data[‘first_name’]} ,\n\nYou need to activate your account, so paste the link below in the address bar:\n\nhttp://domain.co.cc/login/activate.php?email= {$register_data[‘email’]} $email_code= {$register_data[‘email_code’]} \n\n-domain”;
$header = ‘From: [email protected]’;
mail($to, $subject, $body, $header);
}
function activate($email, $email_code){
$email = mysql_real_escape_string($email);
$email_code = mysql_real_escape_string($email_code);
if(mysql_result(mysql_query("SELECT COUNT(`id`) FROM `Users` WHERE `email` = '$email' AND `email_code` = '$email_code' AND `active` = 0"), 0) == 1){
mysql_query("UPDATE `Users` SET `active` = 1 WHERE `email` = '$email'");
return TRUE;
}else{
return FALSE;
}
}
function user_count(){
$query = mysql_query("SELECT COUNT(`id`) WHERE `active` = 1");
return mysql_result($query, 0);
}
function user_exists($un){
$un = sanitize($un);
$query2 = mysql_query("SELECT COUNT(`id`) FROM `Users` WHERE `username` = '$un'");
return (mysql_result($query2, 0) == 1) ? TRUE : FALSE;
}
function email_exists($em){
$em = sanitize($em);
$query3 = mysql_query("SELECT COUNT(`id`) FROM `Users` WHERE `email` = '$em'");
return (mysql_result($query3, 0) == 1) ? TRUE : FALSE;
}
function user_active($un){
$un = sanitize($un);
$query4 = mysql_query("SELECT COUNT(`id`) FROM `Users` WHERE `username` = '$un' AND `active` = 1");
return (mysql_result($query4, 0) == 1) ? TRUE : FALSE;
}
function id_from_username($un){
$un = sanitize($un);
$query5 = mysql_query("SELECT `id` FROM `Users` WHERE `username` = '$un'");
return mysql_result($query5, 0, 'id');
}
function login($un, $pw){
$id = id_from_username($un);
$un = sanitize($un);
$pw = md5($pw);
$query6 = mysql_query("SELECT COUNT(`id`) FROM `Users` WHERE `username` = '$un' AND `password` = '$pw'");
return (mysql_result($query6, 0) == 1) ? $id : FALSE;
}
?>
//initialization file
<?php session_start(); //error_reporting(0); require 'database/connect.php'; require 'functions/users.php'; require 'functions/general.php'; if(logged_in() === TRUE){ $query = mysql_query("SELECT * FROM `Users` WHERE `id` = '".$_SESSION['id']."'") or die(mysql_error()); while($row = mysql_fetch_array($query)){ $usn = $row['username']; $paw = $row['password']; $first_name = $row['first_name']; $eml = $row['email']; $em_code = $row['email_code']; } } ?>[/php]