Solved

Object of class PDOStatement could not be converted to int

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

I am using php and sql server (pdo)
0
Comment
Question by:rgb192
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 108

Accepted Solution

by:
Ray Paseur earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now