在数据库php中插入Url最后2个字符
我正在尝试将Url的最后2个字符插入到我的数据库中。每次插入时都需要一些数字,如“2147483647”。如何插入正确的Url的最后2个字符。 “$array=json_decode(stripslashes($_POST['data'])) 对于($i=0,$l=sizeof($array);$i<$l;$i++){ $obj=$array[$i]在数据库php中插入Url最后2个字符,php,url,path,insert,Php,Url,Path,Insert,我正在尝试将Url的最后2个字符插入到我的数据库中。每次插入时都需要一些数字,如“2147483647”。如何插入正确的Url的最后2个字符。 “$array=json_decode(stripslashes($_POST['data'])) 对于($i=0,$l=sizeof($array);$i
if($obj->{'leaf'} == true){
$leaf = 1;
} else{
$leaf = 0;
}
if($obj->{'parentId'} == null){
$parentID = 'null';
} else{
$parentID = $obj->{'parentId'};
}
if($obj->{'Duration'}==''){
$duration = 0;
} else{
$duration = $obj->{'Duration'};
}
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$gantt_id = substr(strrchr($url, '='), 1);
/*if($obj->{'gantt_id'}==null){
$gantt_id = 0;
} else{
$gantt_id = $obj->{'gantt_id'};
}
*/
$q = 'INSERT INTO j_gantt_tasks SET Name = "'.$obj->{'Name'}.'", StartDate = "'.$obj->{'StartDate'}.'", EndDate = "'.$obj->{'EndDate'}.'",
Duration = "'.$obj->{'Duration'}.'", DurationUnit = "'.$obj->{'DurationUnit'}.'", PercentDone = "'.$obj->{'PercentDone'}.'", Cls = "'.$obj->{'Cls'}.'", gantt_id="'.$gantt_id.'",
parentId = "'.$obj->{'parentId'}.'"';
$r = mysql_query($q);
if(!$r){
echo db_error($q);
}
$obj->{'id'} = mysql_insert_id();
}
echo json_encode($array);' 试试看
$url = (!empty($_SERVER['HTTPS'])) ?
"https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] :
"http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$last2 = substring($url,-2);