dongzanghua8422 2017-11-06 01:14
浏览 153

插入数据库utf-8编码

I get some data in java from http and then I want insert all data in one query to my database using java and php script but i have error:

You have an error in your SQL syntax; check the manual >that corresponds to your MariaDB server version for the >right syntax to use near '??okietka', '247335'), at line 1

What is interesting when i copy text from http and add manualy it works, but when i get data from url and then my program put this data i have this error. I think it is a coding problem. my insert php file :

   <?php
require "connection.php";
header('Content-Type: text/html; charset=utf-8');
ini_set('default_charset', 'UTF-8');

$table_name = $_POST["table_name"];
$rows_name = $_POST["rows_name"];


$values = $_POST["values"];
mysqli_set_charset($connection,'utf8');

$mysql_query = "insert ignore into $table_name $rows_name values $values";
if(mysqli_query($connection,$mysql_query) == TRUE){
    echo "Insert Succesful" ;
}
else{
    echo "Error: " . $mysql_query . "<br>" . $connection->error;
}
mysqli_close($connection);
?>

Other data from http I successfully inserted.

Edit: I think i solved this problem adding this to php:

 header('Content-Type: text/html; charset=utf-8');
ini_set('default_charset', 'UTF-8');
mysqli_set_charset($connection,'utf8');
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?