Hi .. I have been trying to solve this for two days now .. I have read many threads here and php forums and tried many suggestions .. (encode, decodes .. StringUtils) but nothing is working .. so any help would be welcome.
I am sending a JSON string with Http.Poststring to PHP script to Insert data to mySQL.
If any portion / field of the string contains an "&" ampersand the php fails.
In the end I am try to store a complete URL .. but even a simple title "Abc&123" will cause it to fail.
My Lack of PHP expertise doesn't help either ..
Is there a simple way of sending an array containing a URL and storing it in a mySQL db or is there more to it that that.
Regards
PHP
I am sending a JSON string with Http.Poststring to PHP script to Insert data to mySQL.
If any portion / field of the string contains an "&" ampersand the php fails.
In the end I am try to store a complete URL .. but even a simple title "Abc&123" will cause it to fail.
My Lack of PHP expertise doesn't help either ..
Regards
PHP
B4X:
include ("config.php");
$con = mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
mysql_query("SET CHARACTER SET utf8");
{
$json = $_POST["MyJSON"];
$jsall = array();
$jsone = array();
$jsall=json_decode($json, true);
$x = 0;
while($x < count($jsall)) {
$jsone=$jsall[$x];
$id=$jsone["ID"];
$title=$jsone["Title"];
$url=$jsone["Url"];
//$url = filter_var($jsone["Url"], FILTER_SANITIZE_URL);
//$nurl=htmlspecialchars($url);
echo $url;
//$q = mysql_query("INSERT INTO test_tbl(table_id, title, url) VALUES($id, '$title', '$nurl')");
$x++;
}
print json_encode("Inserted Data");
}
?>