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');