i want to connect to a database server using php , and then echo the data as JSON so later i can use it in android but JSON shows /
as \/
for example if http://www.google.com/ was in the database if shows it as
"http:\/\/www.google.com\/" .
i made connections and all and here is how i fetch the data
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}catch (PDOException $ex) {
$response["success"] = 0;
$response["message"] = "Database Error1. Please Try Again!";
die(json_encode($response));
}
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
$array[] = $row;
echo json_encode($array);
This is valid json and the correct way to encode it, see http://codepad.viper-7.com/6PbdmJ
When you decode it in for example javascript or php, you will get your original URL back:
javascript:
JSON.parse('"http:\/\/www.google.com\/"');
php:
var_dump(json_decode(json_encode('http://www.google.com/')));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments