I have found similar queries like mine in stackoverflow,but found no solutions . So I am asking it again. I have the following insert
query :
$purchase_date = date("Y-m-d");
$init = substr($info[fname], 0, 2);
$odr = rand(0,255);
$invoice_number = $this->get_invoice_number();
//$invoice_number = $invoice_number+1;
//$invoice_number = 400 + rand(0,100);
$order_number = $init.'-'.$odr;
$session_id = session_id();
$sql = "
INSERT INTO
tbl_checkout
SET
fname = '$info[fname]',
lname = '$info[lname]',
email = '$info[email]',
phone = '$info[phone]',
address = '$info[address]',
pin = '$info[pin]',
session_id = '$session_id',
purchase_date = '$purchase_date',
invoice_number = '$invoice_number',
order_number = '$order_number' <----This is line no 1038
";
$this->db->insertQuery($sql);
But when I tried to execute it, it shows error like Catchable fatal error: Object of class stdClass could not be converted to string in c:\.....on line 1038
I am lost because I can't even understand what the error means ! Please help.
$this->get_invoice_number()
is probably returning an object.
you can cast it to a string:
$invoice_number = (string) $this->get_invoice_number();
There is nothing wrong in line 1038,
most likely is line 1037 having an error
(valuable casting issue)
$invoice_number = $this->get_invoice_number();
You should do a
var_dump( $this->get_invoice_number() );
Then likely you just need to refer to the object property like
$invoice_number->SOME_PROPERTY;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With