我使用PHP
urlencode
INSERTED
database
使用PDO
bindParamiter
....
我知道我不应该关注
urlencoding
数据而我应该这样做 让PHP-PDO
消毒
但是,有些我希望urlencode
首先考虑databas
。{/ p>
类似:
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 Screams:
URIError:格式错误的URI序列
})
在响应下的Firebug控制台中,我看到了完美的所需输出,例如:
[{ “UNIT_ID”: “46”, “UNIT_NAME”: “21A”, “unit_pic_url”:“* uProf / 46 /只/ PDSP / P500 / c2f971b1e92b2dce68489198cf0a300a_158_15875.jpg * uProf / 46 /只/ 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 /只/ PDSP / P500 / c2f971b1e92b2dce68489198cf0a300a_158_15875.jpg “ ”unit_building“: ”21“, ”unit_building_name“: ”+ ELIZABETH PLACE“, ”unit_location“: ”4“, ”LOCATION_NAME“:” Salcedo的+村 “ ”城市“: ”2“, ”CITY_NAME“: ”马尼拉“, ”unit_for“: ”1“, ”UNIT_TYPE“: ”2“, ”unit_size“: ”109sqm“, ”unit_improvements“:” 全+家具 “ ”unit_view“: ”伊丽莎白+地方“, ”unit_condition“: ”好+维护“, ”unit_status“: ”空置+“, ”unit_availability“: ”任何时候“, ”unit_parkings“: ”1“,” UNIT_PRICE “:” 75,000.00" , “unit_amenities”: “游泳+池%2CGym +和+功能+客房”, “unit_proximities”: “+ +附近萨尔塞多村+”,“U nit_remarks “:” 2 +卧室+有关+出租+%40 + ELIZABETH + PLACE%0D%0ADescription%3A + FULLY + FURNISHED +%0D%0AAsking +价格%3A + P75%2C000 +包容+协会+会费+%0D%0AFloor +面积%3A109 +平米%0D%0AFloor +级别%3A +高楼层%0D%0AContact +人称%3A + + +天使腭女士%0D%0ACel +号码+%3A + 09175790257%2F + 09989748767%0D %0ATel +没有%3A + 894-4745%2F + 979-4842" , “unit_map”:“%3Ciframe +宽度%3D%22425%22 +高度%3D%22350%22 + FRAMEBORDER%3D%220%22 +滚动%3D%22no%22 + MARGINHEIGHT%3D%220%22 + MARGINWIDTH%3D%220%22 + SRC%3D%22https%3A%2F%2Fmaps.google.com.ph%2Fmaps%3FF%3DQ%26安培%3Bsource%3Ds_q%26安培%3Bhl%3Den%26安培%3Bgeocode%3D%26安培%3BQ%3Delisabeth%2Bplace%2Bmakati%2Csalcedo%2Bvillage%26安培%3Baq%3D%26安培%3Bsll%3D14.546956%2C121.05351%26安培%3Bsspn%3D0.007685%2C0.013078%26安培%3Bie%3DUTF8%26安培%3Bhq%3Delizabeth%2Bplace%2Bmakati%2Csalcedo%2Bvillage%26安培%3Bhnear%3D%26安培%3Bll%3D14.561158%2C121.022669%26安培%3Bspn%3D0.030738%2C0.052314%26安培%3BT%3DM%26安培%3BZ%3D14%26安培%3Biwloc%3DA%26安培%3Bcid%3D8098826603847629943%26安培%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%26安培%3Bsource %3Dembed%26安培%3Bhl%3Den%26安培%3Bgeocode%3D%26安培%3BQ%3Delisabeth%2Bplace%2Bmakati%2Csalcedo%2Bvillage%26安培%3Baq%3D%26安培%3Bsll%3D14.546956%2C121.05351%26安培%3Bsspn %3D0.007685%2C0.013078%26安培%3Bie%3DUTF8%26安培%3Bhq%3Delizabeth%2Bplace%2Bmakati%2Csalcedo%2Bvillage%26安培%3Bhnear%3D%26安培%3Bll%3D14.561158%2C121.022669%26安培%3Bspn %3D0.030738%2C0.052314%26安培%3BT%3DM%26安培%3BZ%3D14%26安培%3Biwloc%3DA%26安培%3Bcid%3D8098826603847629943%22 +风格%3D%22color%3A%230000FF%3Btext对齐%3Aleft %22%3EView +更大+地图%3C%2FA%3E%3C%2Fsmall%3E”, “unit_display_mode”: “1”, “added_by”: “Angel_Baldo_Velo”, “added_by_email”: “eirishanjelavelo@yahoo.com”, “ADDED_DATE”:“2013年12月5日 01:17:08“,”stags“:”2BR,109平方米,ELIZABETH + PLACE,[1]停车场, 空缺+,马卡蒂“}]
修改 * 这是复制并粘贴在这里: * http://meyerweb.com/eric/tools/dencoder/
和产生NO ERROR ,但decodes
完全符合要求。
他们正在做什么,以便他们的网站可以轻松解码编码数据?...任何建议都非常感谢。
答案 0 :(得分:2)
我认为您可以稍后尝试unescape
字符串decodeURI
,因为PHP-PDO
会转义字符串中的内容。