Call to undefined function mysql_real_escape_string()

11,756

Try using:

$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
$value = trim($_POST['image']);
$value = mysqli_real_escape_string($link, $value);
mysqli_close();

Since new php version mysqli is used instead of mysql. Notice the letter "i". Where $link stands for the mysqli_connect.

Share:
11,756
Md. Rafsan Biswas
Author by

Md. Rafsan Biswas

Updated on December 02, 2022

Comments

  • Md. Rafsan Biswas
    Md. Rafsan Biswas over 1 year

    //Here is the code from insert.php


    if ($_SERVER["REQUEST_METHOD"] == "POST") { if(isset($_POST['image']) && isset($_POST['cate']) ){

            $image = mysql_real_escape_string(trim($_POST['image']));
    
            $cate = mysql_real_escape_string(trim($_POST['cate']));
    
    
    
            $query_input = "INSERT INTO category(cat_name,image) VALUES('$cate','$image')";
            $result_input = insert_fun($query_input);
    
    • Thamilhan
      Thamilhan about 7 years
      Are you using PHP 7? Then it is removed. You can't use it. If not this
    • Thamilhan
      Thamilhan about 7 years
    • Md. Rafsan Biswas
      Md. Rafsan Biswas about 7 years
      @Thamilan yes I'm using php