Object of Class Stdclass Could Not Be Converted to String

Object of class stdClass could not be converted to string

Most likely, the userdata() function is returning an object, not a string. Look into the documentation (or var_dump the return value) to find out which value you need to use.

Object of class stdClass could not be converted to string - laravel

$data is indeed an array, but it's made up of objects.

Convert its content to array before creating it:

$data = array();
foreach ($results as $result) {
$result->filed1 = 'some modification';
$result->filed2 = 'some modification2';
$data[] = (array)$result;
#or first convert it and then change its properties using
#an array syntax, it's up to you
}
Excel::create(....

Object of class stdClass could not be converted to string (php)

$responsible->contactInfo is a stdClass instance, which is not accepted by the logger.

You have to convert it to an array:

 Log::debug($responsible->contactInfo); // error
Log::debug((array) $responsible->contactInfo); // should works (logged as an array)
Log::debug(json_encode($responsible->contactInfo)); // should works (logged as json)

Object of class stdClass could not be converted to string (Error Number: 1064)

You are trying to use update_batch() on the same data you just queried from the database table tournament_seed, but you are not using the new $_POST data to update.

You also use update_batch() within the loop, which is wrong. The loop is just to create the array you want to update, then outside the loop you update_batch()

use the following to create an array, which later can be used for update_batch(), something like:

$seeded=array();
$sd=array();
foreach($_POST['your_newly_posted_seeds'] as $key=>$value){
$sd['id']=$value->id;
$sd['tournament_id']=$tournament_id;
//...
array_push($seeded, $sd);
}

$this->db->update_batch('tournament_seed', $seeded, 'id');

update_batch() from the docs, scroll down or search: $this->db->update_batch() as there is no bookmark to it.

Object of class stdClass could not be converted to string

I think that your problem is in this line:

$data['user_id'] = $res[$i];

You should change it to:

  $data['user_id'] = $res[$i]->id;

Because the id's values are in the object stored in the array $res

The code:

for($i=0; $i<count($res); $i++)
{
$data['user_id'] = $res[$i]->id;
$data['client_id'] = $client_last;
$this->db->insert("notifications", $data);
}

Object of class stdClass could not be converted to string

You're using mysql_fetch_object (which returns an object) and then trying to output it as a string. That won't work.

In your case, you should use a function that is capable of printing the contents of the object. There are many but the most straight-forward ones are print_r or var_dump. if you're outputting in an HTML context, you might wan to wrap a <pre> tag around the output to make it more readable or click "View source" in your browser.

If you're writing your own objects, they can also be "converted" to strings by implementing the __toString() magic method

Also, as people have said in the comments, your code will run the query on each pass through the loop. Check out the documentation here and read the examples.

Note: You might have simplified the example for SO's sake, but make sure to sanitize your variables (e.g. $begin) to avoid SQL injections!

PHP Object of class stdClass could not be converted to string

You don't know what you're trying here?

$a = "<?php echo $this->prodDet->v_price?>";

$a looks after the assignment like <?php echo <the value of $this->prodDet->v_price>?>. The <?php part there is not executed. You surely want to write:

$a = $this->prodDet->v_price;

And make sure that $a is not an object at the end! (what you can check via var_dump($a); in the line after the assignment)

Object of class stdClass could not be converted to string ERROR

As return $this->db->get()->row(); returns object you are getting this error
You need to refer this link

So now, I will suggest you one thing to return data properly.
In your Controller change return $this->db->get()->row();

to

  return $this->db->get()->result_array();

Now you are getting data in the format of Array and you can echo this in your View using

// In your view

foreach($start_lunes as $var){
$value = $var['MIN(horario.hrs_ini)'];
}

<input type="text" id="fecha_actual" name="fecha_actual" value="<?php echo $value?>"


Related Topics



Leave a reply



Submit