-1
function update($data, $table, $id)
{
    global $conid;
    //echo $id;
        /*Assuming array keys are = to database fileds*/
        if (count($data) > 0) {
            foreach ($data as $key => $value) {

                $value = mysqli_real_escape_string($value); // this is line shows a warning
                $value = "'$value'";
                $updates[] = "$key = $value";
            }
        }
        $implodeArray = implode(', ', $updates);
        $sql = ("UPDATE $table  SET $implodeArray WHERE id=$id");
        mysqli_query($conid, $sql);


}

This is update code for all forms but it gives a warning. warning shows only in that line other works perfectly i didn't find why this happen..

Shri
  • 7
  • 4

2 Answers2

0

Since your using mysqli_* function then you have to include your connection to database into mysqli_real_escape function :

You need to change

$value = mysqli_real_escape_string($value);

to

$value = mysqli_real_escape_string($conid, $value);
Milan Chheda
  • 8,159
  • 3
  • 20
  • 35
0

mysql

 $value = mysqli_real_escape_string($value);

mysqli //in mysqli 2 perameter needed as connection object and string data

 $value = mysqli_real_escape_string($conid,$value);//connection object
Bhargav Chudasama
  • 6,928
  • 5
  • 21
  • 39