hi all im trying to update a script and i have the following errors which ive googled and im lost if anyone can help be much appreciated ty jan x

PHP Notice: Use of undefined constant prepare_insert - assumed 'prepare_insert' in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 32
code for this error is below

//prepare to insert data
if(! function_exists(prepare_insert) ) 
{   
    function prepare_insert($data) {
        $data = trim ( $data );
        if (get_magic_quotes_gpc ())
            $data = stripslashes ( $data );

        return mysqli_escape_string ( $data );
    }
}

PHP Notice: Use of undefined constant prepare_show - assumed 'prepare_show' in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 43

if(! function_exists(prepare_show) ) 
{   
    //prepare to show in browes
    function prepare_show($data) {
        $data = stripslashes ( $data );
        $data = htmlspecialchars ( $data, ENT_QUOTES );
        return nl2br ( $data );
    }
}

PHP Notice: Use of undefined constant Age - assumed 'Age' in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 55

// find age
if(! function_exists(Age) ) 
{
    function Age($birthdate)
    { 
        return date("Y") - substr(trim($birthdate),-4,4);
    }
}

Recommended Answers

All 4 Replies

The argument for function_exists() must be a string, so:

if( ! function_exists(prepare_insert))

should be:

if( ! function_exists('prepare_insert'))

Docs: http://php.net/function-exists
Bye!

thats sorted most of the errors ty much appreciated but now ive encounted the following errors

PHP Fatal error: Uncaught Error: Call to undefined function unReadMsgCount() in /home/matureco/public_html/UPLOADIMAGE/header.php:49

if( ! function_exists('prepare_insert')) 
{   
    //prepare to show in browes
    function prepare_show($data) {
        $data = stripslashes ( $data );
        $data = htmlspecialchars ( $data, ENT_QUOTES );
        return nl2br ( $data );
    }
}
0 /home/matureco/public_html/UPLOADIMAGE/index.php(17): include()
<div id="wrapper">
  <?php include("header.php"); ?>
  <div id="maincont">
    <div id="illust">
1 {main}

thrown in /home/matureco/public_html/UPLOADIMAGE/header.php on line 49

<li><a href="inbox.php">Inbox
        <?php $ured = unReadMsgCount($_SESSION['userid']); if ($ured>0) { echo "(".$ured.")"; } ?>
        </a> </li>

if someone can help with this be much appreciate ty jan

ive tried the above which its fixed those errors now im getting
Undefined variable: conn in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 68

// find total message per user
if(! function_exists('unReadMsgCount') ) 
{
global $conn;
    function unReadMsgCount($id)
    {   
        return mysqli_num_rows(mysqli_query($conn,"select * from messages where rece_id='".$id."' and readflage = 0 and status=1"));

    }
}

[29-Oct-2016 20:51:29 America/Chicago] PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 68
[29-Oct-2016 20:51:29 America/Chicago] PHP Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 68
[29-Oct-2016 20:51:29 America/Chicago] PHP Notice: Undefined variable: conn in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 78
[29-Oct-2016 20:51:29 America/Chicago] PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 78
[29-Oct-2016 20:51:29 America/Chicago] PHP Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 78
[29-Oct-2016 20:51:29 America/Chicago] PHP Notice: Undefined variable: conn in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 212
[29-Oct-2016 20:51:29 America/Chicago] PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 212
[29-Oct-2016 20:51:29 America/Chicago] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 213
[29-Oct-2016 20:51:29 America/Chicago] PHP Notice: Undefined variable: response in /home/matureco/public_html/UPLOADIMAGE/config/db_connect.php on line 216

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.