Jump to content

Include file error


emediastudios

Recommended Posts

My script work fine on localhost but get this error on my server online.

 

Fatal error: Cannot redeclare htmlspecialchars_decode() in /home/emediast/public_html/salondigitalentertainment/includes/include.php on line 88

 

Code

<?php

/*
** Database functions
*/
function dbConnect()
{
  $dbhost = "localhost";  //ex: LocalHost
  $dbuser = "emediast"; //ex: User
  $dbpass = "7833pjer"; //ex: iamapassword
  $db = "emediast_sde"; //ex: Resume
  $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass) 
      or die("The site database appears to be down."); 

  if ($db!="" and !@mysql_select_db($db)) 
      die("The site database is unavailable."); 
    
  return $dbcnx; 
}
/*
**  Universal Cleaning and Checking Functions
*/

function clean($var)
{
/*
  * Use preg_replace to replace things such as javascript: and any other nasties you can think of. This is the bloated bit.
  * Done because things like javascript: aren't caught by strip_tags. I also remove certain javascript functions for good measure
  */
//Now add in our own slashes
$var = mysql_real_escape_string($var);
//Strip any html tags
$var = strip_tags($var);
//Convert any special chars
$var = htmlspecialchars($var);
//turn it into html
$var = htmlentities($var);

$var = str_replace('\r\n','<br>',$var);
//Take out any slashes, in case php is set to add them
$var = stripslashes($var);

return $var;
}


function EmailChk($email){
$regex = '&^(?:
("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+")|
([-\w!\#\$%\&\'*+~/^`|{}]+(?:\.[-\w!\#\$%\&\'*+~/^`|{}]+)*))
@(((\[)?
(??:(??:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))\.){3}
(??:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))))(?(5)\])|
((?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)*[a-z0-9](?:[-a-z0-9]*[a-z0-9])?)
\.((?[^- ])[-a-z]*[-a-z])))
$&xi';
if( 0 < preg_match($regex, $email)) return true;
else return false;
}



function EmailCheck($email){
$r = mysql_query("SELECT * FROM resume WHERE email='".$email."'") or die(mysql_error());
$num =  mysql_num_rows($r);
if(!$num) return true;
else return false;
}

function cleanInputs(){
foreach($_GET as $key => $stuff){
  $_GET[$key] = clean($stuff);
}

foreach($_POST as $key => $stuff){
  if($key != "message" || $key != "choices") $_POST[$key] = clean($stuff);
}
}

/*
** Call On-Run Functions
*/
session_start();
dbConnect();
//cleanInputs();
if (!function_exists("htmlspecialc
hars_decode")) {
    function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) {
        return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
    }
}




?>

Link to comment
Share on other sites

Remove the hard return in the name ... your script is failing that if check, then trying to define the function when it already exists.  So the issue is most likely with that if statement.

 

I'd also recommend removing usernames and passwords from script when you post them :)

Link to comment
Share on other sites

Hmm i would say...

 

Replace this bit of code...

 

if (!function_exists("htmlspecialc
hars_decode")) {
    function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) {
        return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
    }
}

 

with...

 

function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) {
    return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.