php - insert query store 0 in all fields -
when create api , image name consist projectid
,user_id
,category
can't save image in database because image project_id
,image_id
,image
not getting post
method.please in advance
<?php error_reporting(e_all); require_once('confi.php'); //destination of images define('img_destination',dirname(__file__).'/images/'); define('db_name','chat_neeraj'); //saving data image table function saveimagedata($data,$imgfile){ $project_id = isset($_post['project_id']) ? mysql_real_escape_string($_post['project_id']) : ""; $image_id = isset($_post['image_id']) ? mysql_real_escape_string($_post['image_id']) : ""; //$user_id = isset($_post['user_id']) ? mysql_real_escape_string($_post['user_id']) : ""; $image_name = isset($_post['image_name']) ? mysql_real_escape_string($_post['image_name']) : ""; if(isset($_files['tmp_name']) && filesize($_files['tmp_name'])>0) saveimagefile($imgfile['tmp_name'],$image_id."_".$project_id."_".$category_id."_".$image_name); $category_id = isset($_post['category_id']) ? mysql_real_escape_string($_post['category_id']) : ""; $houssup_id = isset($_post['houssup_id']) ? mysql_real_escape_string($_post['houssup_id']) : ""; $location_id = isset($_post['location_id']) ? mysql_real_escape_string($_post['location_id']) : ""; // insert data data base $sql = "insert `".db_name."`.`image_table`(`project_id`, `image_id`,`image_name`,`category_id`,`houssup_id`,`location_id`) values(null,'$image_id','$image_name','$category_id','$houssup_id','$location_id')"; echo $sql; if(mysql_query($sql)) return true; else return false; } //saving image file diskk function saveimagefile($src,$des){ copy($src,$dest); } //select image function selectimage(){ } //save image hash tag function saveimagehashtag(){ } $action=isset($_request['action'])?$_request['action']:""; switch($action){ case "save": if($_server['request_method'] == "post" && isset($_post)){ if(saveimagedata($_post,$_files)){ echo "saved"; }else{ echo "failed"; } }else{ echo "nothing save"; } break; default: echo "live"; break; } //closing db connection if($conn){ @mysql_close($conn); }
try:
$sql = "insert image_table ('project_id', 'image_id','image_name','category_id','houssup_id','location_id') values(null,$image_id,'$image_name',$category_id,$houssup_id,$location_id)";
Comments
Post a Comment