0

i`m having this problem after whenever include or require is Used.
help please i dont know how to solve this.
Fatal error: Cannot redeclare validateemail() (previously declared in C:\wamp\www\kislat\functions\functions.php:3) in C:\wamp\www\kislat\functions\functions.php on line 26

<?php session_start();
   require "config.php";
   
   
 $user=$_SESSION['user'];
  $id=$_SESSION['id'];
  if(!session_is_registered('user')){
  header("Location: checklogin.php");
exit;
}
  define('INCLUDE_CHECK',1);
	require"functions/functions.php";
	require"includes/functions.php";
//$user=$_POST['user'];
//$password=($_POST['password']);
$user=$_SESSION['user'];
//$user=peacemaker;
$id=$_SESSION['id'];
//retrieve the users informations
 if(isset($_GET['wewe'])){	   
//$userid=$_GET['wewe']; 
require_once("filter/class.inputfilter_clean.php");
$_POST["tags"] = '&, ||,or,and,<br>';
$_POST["attr"] = 'good, style';
$_POST["tagmethod"]=0;
$_POST["attrmethod"]=0;
$_POST["xssauto"] ='y';
//strip the input text
$_GET['wewe']=stripslashes($_GET['wewe']);



//tags array
	$tags = explode(',', $_POST["tags"]);
	for ($i = 0; $i < count($tags); $i++) $tags[$i] =trim($tags[$i]);
	// attr array
	$attr = explode(',', $_POST["attr"]);
	for ($i = 0; $i < count($attr); $i++) $attr[$i] =trim($attr[$i]);
	// select fields
	$tag_method = $_POST["tagmethod"];
	$attr_method = $_POST["attrmethod"];
	if ($_POST["xssauto"] == 'n') $xss_auto = 0;
	else $xss_auto = 1;
	// more info on parameters in documentation.
	$myFilter = new InputFilter($tags, $attr, $tag_method, $attr_method, $xss_auto);
	// process input
	$userid1= $myFilter->process($_GET['wewe']);
	$userid=mysql_real_escape_string($userid1);
	
	if($userid==$id){
	 header("Location: myprofile.php");//direct to the home page if the user is the one who cliked his own profile
	exit;
}


$query = "SELECT *FROM profile where id=$userid";

$result=mysql_query($query);

if(!$result)
{
include"index.php";//return to the home page
exit();
}else{
$row=mysql_fetch_array($result);
$profid=$row['id'];
$name=$row['names'];
$username=$row['users'];
$email=$row['emails'];
$country=$row['countrys'];
$location=$row['locations'];
$langu1=$row['langu1s'];
}
}

here is where the error appears

if(!$result)
{
include"index.php";//return to the home page 
exit();
}

And the file C:\wamp\www\kislat\functions\functions.php

<?php

function ValidateEmail($email)
{
/*
Name: Letters, Numbers, Dots, Hyphens and Underscores
@ sign
Domain (with possible subdomain(s) ). Contains only letters, numbers, dots and hyphens (up to 255 characters)
. sign
Extension: Letters only (up to 10 (can be increased in the future) characters)
*/

$regex = "([a-z0-9_\.\-]+)". # name

"@". # at

"([a-z0-9\.\-]+){2,255}". # domain & possibly subdomains

"\.". # period

"([a-z]+){2,10}"; # domain extension 

$eregi = eregi_replace($regex, '', $email);

return empty($eregi) ? true : false;
}



?>

I HOPE ONE CAN HELP WITH THIS PROBLEM

Edited by mrcniceguy: n/a

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by mrcniceguy
0

This simply means you have the function ValidateEmail in two different places (function/functions.php and includes/functions.php). Easy to solve: if the function is the same in both files, then remove it from one of the files. If they are different, then rename one of the functions to remove the conflict.

0

Thankx Guys for ur suggestions.
While i was still doing some searches through google i found this PHP built in function which helped to solve the problem.

if(!function_exists('ValidateEmail'))
{
 //inside i put the ValidateEmail function.

}

the function_exists() checks to see if the function has been called or Not.

0

Thankx Guys for ur suggestions.
While i was still doing some searches through google i found this PHP built in function which helped to solve the problem.

if(!function_exists('ValidateEmail'))
{
 //inside i put the ValidateEmail function.

}

the function_exists() checks to see if the function has been called or Not.

Just a suggestion, but renaming or removing one instance of the function is probably a much better practice. If you include those two files on each page, the ValidateEmail function that is wrapped in the function_exists check will never be executed, so it might as well be removed. It will make your code more readable and support easier for you (or anyone else that works on it).

Just my $.02

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.