?
Solved

Object of class PDOStatement could not be converted to int

Posted on 2010-09-14
4
Medium Priority
?
1,384 Views
Last Modified: 2012-05-10
what could this error mean

I am using php and sql server (pdo)
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Expert Comment

by:Amar Bardoliwala
ID: 33679272
Hello rgb192,

above error says that you are trying to assign variable containing "Object of class PDOStatement" to variable of type int or variable which can store int only.

Thanks.
0
 
LVL 2

Expert Comment

by:ciprian-dobrea
ID: 33680365
Could you paste the error line in please?
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 33690839
Please install this code snippet and run it -- you will see how the error is caused.  It is undoubtedly a program logic error.  Look at the line number in your error message to find the failing instruction.
<?php // RAY_temp_rgb192.php
error_reporting(E_ALL);
echo "<pre>";

// CREATE A CLASS DEFINITION
class Thing
{
    public $value;
    public function __construct()
    {
        $this->value = 'Hello World';
    }
}

// INSTANTIATE AN OBJECT
$x = new Thing;
echo $x->value;

// TRY TO CONVERT THE OBJECT TO AN INTEGER
$y = (int)$x;

// TRY IT AGAIN
if ($x > 3) echo "WE COMPARED AN OBJECT TO AN INTEGER";

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 33711871
thanks
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question