Jump to content

Object of class stdClass could not be converted to string


Orionsbelter

Recommended Posts

why do i keep getting this error from line 7?

 

Object of class stdClass could not be converted to string

<?php
include_once"../includes/db_connect.php";
$item_number="2";
$custom="54298";
$query=mysql_query("SELECT `prodID`, `quanity` FROM `cart` WHERE `sessID`='$custom'") or mysql_error();
while($cart=mysql_fetch_object($query)){
mysql_query("INSERT INTO  `orderItems` (  `id` ,  `orderInfoID` ,  `productID` ,  `quanity` ) VALUES ('',  '$item_number',  '$cart-> prodID',  '$cart->quanity');");
}
mysql_query("UPDATE `cart` SET `show`='1' WHERE `sessID`='$custom'");

?>

 

Link to comment
Share on other sites

Don't use a query in a loop. Instead, build a query like

 

INSERT INTO `table` ( `col1`, `col2` ) VALUES ( 'data1a', 'data1b' ), ( 'data2a', 'data2b' ), ( 'data3a', 'data3b' ) etc...

 

And rather than deal with an object, just use $cart=mysql_fetch_assoc($query) and your values will be $cart['prodID'] and $cart['quanity']

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.