Solved

Object of class PDOStatement could not be converted to int

Posted on 2010-09-14
4
1,214 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

757 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

18 Experts available now in Live!

Get 1:1 Help Now