Getting error Object of class mysqli_result could not be converted to string

I am getting an error and for the life of my can't figure it out. My code is kind of messy so watch out:

$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.";


I am getting the error (in the subject of this question)when my second sql statement starts, at $sql1 = long_string_of_code I'm thinking it's something with my variables from the first statement maybe? If I echo my variables from the first statemenet, I get them all ok. So I am not sure what the deal is. Any help is appreciated, I know this is a lot of code to go through. Thank you.



Your using result in the second SQL. Its an object so you can't use it as a string. Change that variable and it should work

Need Your Help

Facebook Open Graph in development environments

facebook-graph-api opengraph facebook-opengraph

We're developing a web application using Facebook Graph API. Naturally, we have a Facebook application, which I'll call "MyApp" for the sake of this question.

jquery gallery with banner ads

jquery gallery slideshow

Does anyone know if there's a JQuery gallery plugin that supports banner ads? I've seen a lot of many different slideshow/gallery options out there but I'm looking for one that will enable me to ha...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.