کلیدستان

نسخه‌ی کامل: ایجاد دو رکورد تکراری در mysql توسط صفحه php (برنامه نویسی اندروید)
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
سلام
دوستان
مشکل من اینه که وقتی از سمت اندروید دیتایی رو وارد دیتابیس mysql روی سایت با php وارد میکنم بجای اینکه رکورد وارد کنه دو رکورد تکراری وارد میشه مشکل کجاست؟ لطفا راهنمایی کنید.
سلام.
لطفا کدهای صفحه PHP و همچنین کدهای بخش اندروید را ذکر کنید.

Flower
سلام
ممنونم از لطفتون:

کدهای سمت اندروید:

کد:
public class Insert extends AsyncTask{
    String Name,Family,Ostan,City,Tel,sef1,bodjeh1,tabgh,imgs,fimage;
   public Insert(String name,String family,String ostan,String city,String tel,String sef,String b,String tabaghe,String imagess,String image_f){
Name=name;
Family=family;
Ostan=ostan;
City=city;
 Tel=tel;
 sef1=sef;
 bodjeh1=b;
 tabgh=tabaghe;
 imgs=imagess;
 fimage=image_f;
}

@Override
protected Object doInBackground(Object... arg0) {
    
    try {
        
        
        
        
        String data=URLEncoder.encode("name",  "UTF-8")+"="+URLEncoder.encode(Name,  "UTF-8");
            data+="&"+URLEncoder.encode("family",  "UTF-8")+"="+URLEncoder.encode(Family,  "UTF-8");
            data+="&"+URLEncoder.encode("city",  "UTF-8")+"="+URLEncoder.encode(City,  "UTF-8");
            data+="&"+URLEncoder.encode("ostan",  "UTF-8")+"="+URLEncoder.encode(Ostan,  "UTF-8");
            data+="&"+URLEncoder.encode("tel",  "UTF-8")+"="+URLEncoder.encode(Tel,  "UTF-8");
             data+="&"+URLEncoder.encode("sef",  "UTF-8")+"="+URLEncoder.encode(sef1,  "UTF-8");
             data+="&"+URLEncoder.encode("bod",  "UTF-8")+"="+URLEncoder.encode(bodjeh1,  "UTF-8");
             data+="&"+URLEncoder.encode("tab",  "UTF-8")+"="+URLEncoder.encode(tabgh,  "UTF-8");
             data+="&"+URLEncoder.encode("img",  "UTF-8")+"="+URLEncoder.encode(imgs,  "UTF-8");
             data+="&"+URLEncoder.encode("imgf",  "UTF-8")+"="+URLEncoder.encode(fimage,  "UTF-8");
             
 /*            

    nameValuePairs.add(new BasicNameValuePair("img",imgs));
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(MainActivity.url+"/***************/order.php");
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));        
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity entity = response.getEntity();
      
             
*/
    URL link=new URL(MainActivity.url+"/****************/order.php");
    
    URLConnection con=link.openConnection();
    
    con.setDoOutput(true);
    
    OutputStreamWriter wrw=new OutputStreamWriter(con.getOutputStream());
    
    wrw.write(data);
    wrw.flush();
    
    BufferedReader br=new BufferedReader(new InputStreamReader(con.getInputStream()));
    
    StringBuilder sb=new StringBuilder();
    String l="";
    
    
    while((l=br.readLine())!=null){
        sb.append(l);
        
    }
    
    r=sb.toString();
    
//    wrw.close();
    br.close();


کدهای سمت server:


کد:
<?php

include ('connect.php');

$name=$_POST['name'];
$family_name=$_POST['family'];
$city=$_POST['city'];
$ostan=$_POST['ostan'];
$tel=$_POST['tel'];
$comment=$_POST['sef'];
$bod=$_POST['bod'];
$tab=$_POST['tab'];
$img=$_POST['img'];
$imgf=$_POST['imgf'];

$sql="INSERT INTO `customer_table`(`id`, `name`, `family_name`, `city`, `ostan`, `tel`, `comment`,`bodjeh`,`tabagheh`,`imag_f`,`image`)
 VALUES ('','$name','$family_name','$city','$ostan','$tel','$comment','$bod','$tab','$imgf','$img')";

mysql_query($sql);
if(mysql_query($sql)==TRUE){
    echo "1";
}else{
    echo "0";
}

?>