MYsql Issue

i have the following code

	// Process your response here
	$jsonData = json_decode($response);

if ($jsonData->status === 'success') {

	// Grab Message ID
	foreach($jsonData->messages as $txtid)
   // Got Message ID
   // Success code
	echo ('Sent: message to '.$to.' appearing to be sent from '.$from.' <br><br> One Credit used.<br><br>');

// Insert Details to log
    $sth2 = $db->prepare ("INSERT INTO logs (id,`to`,`from`,message,`txtid`) VALUES (:id,:to,:from,:message,:txtid)");
    $sth2->bindParam(':id', $id, PDO::PARAM_INT);
    $sth2->bindParam(':to', $to, PDO::PARAM_INT);
    $sth2->bindParam(':from', $from, PDO::PARAM_INT);
    $sth2->bindParam(':message', $message, PDO::PARAM_STR);
	$sth2->bindParam(':txtid', $txtid, PDO::PARAM_STR);

and i am getting the following error

Catchable fatal error: Object of class stdClass could not be converted to string in

i have tried txtid as PARAM_INIT and STR

the database is set to varchar and it the txtid will be numbers

i did a var dump and get the following

object(stdClass)#5 (2) { ["id"]=> string(10) "1163196774" ["recipient"]=> int(447777777777) }

a var dump of what?

$txtid i thought this would be the best to dump to see if this could help

So $txtid doesn’t contain an id, but an object.
Maybe (just a guess because I don’t know the meaning of the data you’re working with) you should use $txtid->id ?

Just a guess, but you are binding the “to” and “from” values as Integers, when I would think they s/b strings. Could that be the issue?

i changed

$sth2->bindParam(':txtid', $txtid, PDO::PARAM_STR);


$sth2->bindParam(':txtid', $txtid->id, PDO::PARAM_STR);

and this has worked wonders thank you very much!