我使用了 ' PHP
surlencode
和INSERTED
使用....database
PDO
bindParamiter
我知道我不应该关心
urlencoding
数据,我应该让PHP-PDO
Sanitize
但是,有些我想urlencode
先成为databas
ing。
就像是:
if(isset($_POST['url'])) {
$_POST['url'] = urlencode($_POST['url']);
//INSERT QUERY:
"INSERT INTO table_name (url_1) VALUES (:url_1)"
PDO 绑定:
/*** bind the paramaters ***/
$stmt->bindParam(':url_1', $_POST['url'])
}
检索数据:PHP
if(isset($_GET['url_string'])){
//RUN Select Query using PDO Mysql
$getURL = "SELECT url_1 FROM table_name"
//The $getURL variable will contain an associative array like:
// array [0]['url_1'] ///This will be the valued inserted previously.
///Then json_encode()
$sendOut = json_encode(array('url_DATA' => $getURL))
echo $sendOut;
}
问题:
我正在使用 jQuery 的$.getJSON
函数从数据库中获取数据。
就像是:
$.getJSON('ulr.func.php',{url_string:""},function(myOutPut){
// Then I decode the URL retrieved from the DATABASE here.
decodeURIComponent(myOutPut.url_DATA)
decodeURIComponent 尖叫:
URIError:格式错误的 URI 序列
})
在Response下的 Firebug 控制台中,我看到了完美的所需输出,例如:
[{"unit_id":"46","unit_name":"21A","unit_pic_url":"*uProf/46/pcs/pdsp/p500/c2f971b1e92b2dce68489198cf0a300a_158_15875.jpg*uProf/46/pcs/pdsp/p500/b5c4045574cb0f927fb096b6369f4ba5_78_72234. jpg*uProf/46/pcs/pdsp/p500/6fb26702857b0f464c543a9c13a1f7b1_333_228657.jpg*uProf/46/pcs/pdsp/p500/69c18d8cbf8e940b23f9abe8138d0e7f_303_211896.jpg*uProf/46/pcs/pdsp/p500/9e74b1d7d037cd9de95c0b78522e04a2_321_79258.jpg","unit_default_pic":" uProf/46/pcs/pdsp/p500/c2f971b1e92b2dce68489198cf0a300a_158_15875.jpg","unit_building":"21","unit_building_name":"ELIZABETH+PLACE","unit_location":"4","location_name":"Salcedo+Village" ,"城市":"2","city_name":"马卡蒂","unit_for":"1","unit_type":"2","unit_size":"109sqm","unit_improvements":"Fully+Furnished","unit_view":"Elizabeth+Place","unit_condition":"Well+已维护","unit_status":"Vacant+","unit_availability":"Anytime","unit_parkings":"1","unit_price":"75,000.00","unit_amenities":"Swimming+pool%2CGym+and+Function+ Room","unit_proximities":"+Near+Salcedo+Village","unit_remarks":"2+Bedroom+For+Rent+%40+ELIZABETH+PLACE%0D%0ADescription%3A+FULLY+FURNISHED+%0D%0AA询问+价格%3A+P75%2C000+包括+协会+会费+%0D%0A楼层+面积%3A109+平方米%0D%0A楼层+楼层%3A+高层%0D%0A联系人+人员%3A+女士。+Angel+Velo%0D%0ACel+no.+%3A+09175790257%2F+09989748767%0D%0ATel+no.%3A+894-4745%2F+979-4842","unit_map":"%3Ciframe+width %3D%22425%22+height%3D%22350%22+frameborder%3D%220%22+scrolling%3D%22no%22+marginheight%3D%220%22+marginwidth%3D%220%22+src%3D %22https%3A%2F%2Fmaps.google.com.ph%2Fmaps%3Ff%3Dq%26amp%3Bsource%3Ds_q%26amp%3Bhl%3Den%26amp%3Bgeocode%3D%26amp%3Bq%3Delisabeth%2Bplace%2Bmakati%2Csalcedo %2Bvillage%26amp%3Baq%3D%26amp%3Bsll%3D14.546956%2C121.05351%26amp%3Bsspn%3D0.007685%2C0.013078%26amp%3Bie%3DUTF8%26amp%3Bhq%3Delizabeth%2Bplaceo%2Bmakati%2Cal %2Bvillage%26amp%3Bhnear%3D%26amp%3Bll%3D14.561158%2C121.022669%26amp%3Bspn%3D0.030738%2C0。052314%26amp%3Bt%3Dm%26amp%3Bz%3D14%26amp%3Biwloc%3DA%26amp%3Bcid%3D8098826603847629943%26amp%3Boutput%3Dembed%22%3E%3C%2Fiframe%3E%3Cbr+%2F%3E%3Csmall% 3E%3Ca+href%3D%22https%3A%2F%2Fmaps.google.com.ph%2Fmaps%3Ff%3Dq%26amp%3Bsource%3Dembed%26amp%3Bhl%3Den%26amp%3Bgeocode%3D%26amp%3Bq% 3Delisabeth%2Bplace%2Bmakati%2Csalcedo%2Bvillage%26amp%3Baq%3D%26amp%3Bsll%3D14.546956%2C121.05351%26amp%3Bsspn%3D0.007685%2C0.013078%26amp%3Bie%3DUTF8%26amp%3Bq 3Delizabeth%2Bplace%2Bmakati%2Csalcedo%2Bvillage%26amp%3Bhnear%3D%26amp%3Bll%3D14.561158%2C121.022669%26amp%3Bspn%3D0.030738%2C0.052314%26amp%3Bt%3Dm%26amp%3Bz% 3D14%26amp%3Biwloc%3DA%26amp%3Bcid%3D8098826603847629943%22+style%3D%22color%3A%230000FF%3Btext-align%3Aleft%22%3EView+Larger+Map%3C%2Fa%3E%3C%2Fsmall% 3E","unit_display_mode":"1","add_by":"Angel_Baldo_Velo"," added_by_email":"eirishanjelavelo@yahoo.com"," added_date":"2013-12-05 01:17:08","stags":"2BR, 109sqm, ELIZABETH+PLACE, [1] 停车场( s), 空置+, 马卡蒂"}]
编辑 *这是复制并粘贴在这里: * http://meyerweb.com/eric/tools/dencoder/
并且不产生错误,但decodes
完全符合要求。
他们在做什么以便他们的网站可以轻松地解码编码数据?...任何建议都非常感谢。