2013-01-23 71 views
1

我的代碼是這樣的解析錯誤MySQL的2個變量

$newentry = " 
    UPDATE url 
    FROM auction_media 
    JOIN auctions ON auction_media.auction_id = auctions.auction_id            
    SET media_url = '$row2['url']/$match[0]' 
    WHERE media_type = '3'"; 

我得到的錯誤是

解析錯誤:語法錯誤,意想不到的T_ENCAPSED_AND_WHITESPACE,期待T_STRING或T_VARIABLE或T_NUM_STRING

回答

1

這段代碼似乎是錯誤的:

SET media_url = '$row2['url']/$match[0]' 

更正如下:

SET media_url = '" . $row2['url'] . "/" . $match[0] . "' 

試試這個:

$newentry = "UPDATE url FROM auction_media JOIN auctions ON auction_media.auction_id = auctions.auction_id SET media_url = '" . $row2['url'] . "/" . $match[0] . "' WHERE media_type = '3'"; 
1

假設查詢將實際工作:

$newentry = "UPDATE url 
    FROM auction_media 
    JOIN auctions 
     ON auction_media.auction_id = auctions.auction_id 
    SET media_url = '" . $row2['url'] . '/' . $match[0] . "' 
    WHERE media_type = '3'"; 
+0

你是什麼意思? – user1989379