1

我遇到了一个错误,我一生都无法弄清楚。我的代码有点乱,所以要小心:

$hostname = ""; //SET SERVER/HOSTNAME
$dbusername = ""; //SET DATABASE USERNAME
$dbname = ""; //SET DATABASE NAME
$dbpassword = ""; //SET DATABASE USERNAME
$link = mysqli_connect($hostname, $dbusername, $dbpassword, $dbname); 
if (!$link) { 
die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); 
}

$sql = "SELECT * FROM utility WHERE `program_code` = '$program_code'"; 
$result = mysqli_query($link, $sql, MYSQLI_USE_RESULT);
if (!$result) 
{ 
    echo 'Error: ', $mysqli->error;
}



while($row = $result->fetch_assoc()){
    $program_code1 = $row['program_code'];
    $utility_company = $row['utility_company'];
    $rate = $row['rate'];
    $term = $row['term'];
}

$sql1 = "INSERT INTO v88374 (id, ldc_account_num, revenue_class_desc, first_name, last_name, home_phone_num, sline1_addr, scity_name, spostal_code, marketer_name, distributor_name, service_type_desc, bill_method, enroll_type_desc, requested_start_date, plan_desc, contract_start_date, contract_end_date, fixed_commodity_amt, vendor_id, office_id, agent_id, customer_name, contact_name, result, promo_code, validation_code, email, state, bname, baddress, program_code, date) VALUES ( '','$ldc_account_num1','$revenue_class_desc','$first_name1','$last_name1', '$home_phone_num1','$sline1_addr1','$scity_name1','$spostal_code1','','$utility_company','$service_type_desc','$bill_method','$enroll_type_desc','$requested_start_date','$plan_desc','$contract_start_date','$contract_end_date','$rate','$vendor_id','$office_id','$agent_id1','$customer_name','$contact_name','$result','$promo_code','$validation_code1','$email1','$state1','$bname1','$baddress1','$program_code1', now())"; 
$result1 = mysqli_query($link, $sql1, MYSQLI_STORE_RESULT);
if (!$result1) 
{ 
echo 'Error: ', $mysqli->error;
}
else if ($result1){

        echo "Thank you. Information submitted.";

}

当我的第二个 sql 语句开始时,我收到错误(在这个问题的主题中),在 $sql1 = long_string_of_code 我认为这可能与我的第一个语句中的变量有关?如果我从第一个语句中回显我的变量,我会得到它们。所以我不确定这笔交易是什么。任何帮助表示赞赏,我知道这是很多代码。谢谢你。

4

1 回答 1

2
contact_name','$result','$promo_code'

您在第二个 SQL 中的使用结果。它是一个对象,因此您不能将其用作字符串。更改该变量,它应该可以工作

于 2013-08-02T22:49:19.917 回答