Solved

Object of class PDOStatement could not be converted to int

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 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