2011-10-28 19 views
0

好了,由於某種原因,我只得到$這個 - >信息獲取發送到mysql數據庫

即:它應該是這個

"UPDATE `shop_products` SET shopid = 1 WHERE id = 42" 

而是我得到這個

"UPDATE `shop_products` SET 1 WHERE 42" 

這裏是我使用的代碼。 我不知道這是爲什麼不工作

public function addstoreproduct($id,$shopid,$categoryid,$productname,$description,$price,$rcb) 
    { 
     $this->id = $id; 
     $this->shopid = $shopid; 
     $this->categoryid = $categoryid; 
     $this->productname = $productname; 
     $this->descriptionid = $description; 
     $this->price = $price; 
     $this->rcb = $rcb; 

     mysql_query("UPDATE `shop_products` SET shopid = "+$this->shopid+" WHERE id = "+$this->id+""); 

     //$this->updatedb('shop_products','shopid='+$this->shopid+'','"id='+$this->id+'"'); 


    } 

回答

2

嘗試

mysql_query("UPDATE shop_products SET shopid = " . $this->shopid . " WHERE id = " . $this->id);

+0

呀我認爲他已經掌握了。 PHP中的字符串連接是「。」 「+」不適用於字符串。 –

0

是否顯示正確的查詢,當您第一次像這樣構建它... ...

public function addstoreproduct($id,$shopid,$categoryid,$productname,$description,$price,$rcb) 
{ 
    $this->id = $id; 
    $this->shopid = $shopid; 
    $this->categoryid = $categoryid; 
    $this->productname = $productname; 
    $this->descriptionid = $description; 
    $this->price = $price; 
    $this->rcb = $rcb; 
    $query = "UPDATE `shop_products` SET shopid = "+$this->shopid+" WHERE id = "+$this->id+""; 
    echo $query; 
    mysql_query($query); 

    //$this->updatedb('shop_products','shopid='+$this->shopid+'','"id='+$this->id+'"'); 


} 
相關問題