2010-05-01 273 views
0

我有一個存儲過程的問題:有插入到數據庫

CREATE PROCEDURE busi_reg 
    (IN instruc VARCHAR(10), 
    IN tble VARCHAR(20), 
    IN busName VARCHAR(50), IN busCateg VARCHAR(100), 
    IN busType VARCHAR(50), 
    IN phne VARCHAR(20), IN addrs VARCHAR(200), IN cty VARCHAR(50), 
    IN prvnce VARCHAR(50), IN pstCde VARCHAR(10), IN nm VARCHAR(20), 
    IN surname VARCHAR(20), IN eml VARCHAR(50), IN pswd VARCHAR(20), 
    IN srce VARCHAR(50), IN refr VARCHAR(50), IN sess VARCHAR(50)) 

BEGIN 

INSERT INTO b_register SET 

     business_name = busName, 
     business_category = busCateg, 
     business_type = busType, 
     phone = phne, 
     address = addrs, 
     city = cty, 
     province = prvnce, 
     postal_code = pstCde, 
     firstname = nm, 
     lastname = surname, 
     email = eml, 
     password = pswd, 
     source = srce, 
     ref_no = refr; 

END; 

這是我的PHP腳本:

$busName = $_POST['bus_name'];  
$busCateg = $_POST['bus_cat']; 
$busType = $_POST['bus_type'];  
$phne = $_POST['phone']; 
$addrs = $_POST['address'];  
$cty = $_POST['city'];  
$prvnce = $_POST['province'];  
$pstCde = $_POST['postCode'];  
$nm = $_POST['name'];  
$surname = $_POST['lname'];  
$eml = $_POST['email'];  
$srce = $_POST['source'];  
$ref = $_POST['ref_no']; 

$result2 = $db->query("CALL busi_reg('$instruc', '$tble', '$busName', 
    '$busCateg', '$busType', '$phne', '$addrs', '$cty', '$prvnce', 
    '$pstCde', '$nm', '$surname', '$eml', '$pswd', '$srce', '$refr', '')"); 

if($result) 
{ 
    echo "Data has been saved"; 
} 
else 
{ 
    printf("Error: %s\n",$db->error); 
} 

現在的錯誤,我得到:

**Commands out of sync; you can't run this command now** 
+0

您使用的是哪種表格類型? – 2010-05-01 21:54:35

回答

0

我假設,因爲這是MySQLi標記的,你正在使用它。

您使用的是MYSQLI_USE_RESULT嗎?快速谷歌搜索錯誤迅速帶給我:http://php.net/manual/en/mysqli.query.php

如果這是問題,你需要釋放你的最後結果之前執行新的。

+0

爲什麼這是低調的?這可能不是解決方案,但它不是誤導。 – egrunin 2010-05-02 17:26:40