php Error description: Incorrect string value: '\xF4t l'\xE9…' on insert

前端 未结 2 1976
孤街浪徒
孤街浪徒 2021-01-13 07:08

I am inserting data from a UTF8-general-ci table to another UTF8-general-ci table. These are articles. About 20 or 30 will not insert due to random use of French titles or p

2条回答
  •  花落未央
    2021-01-13 07:11

    Try this with utf8_encode();

            $sql = "INSERT INTO table (col1)
            VALUES ('".utf8_encode($input_variable)."')";
    
            if ($conn->query($sql) === TRUE) 
            {
                echo "Inserted!";
            } else {
                echo "Error: " . $sql . "
    " . $conn->error; }

提交回复
热议问题