user3628807
user3628807

Reputation: 325

Integer is being transformed to an object

Here is my code: https://pastebin.com/aR299wuz

When I open the file, for example: rate.php?permalink=game-of-thrones&rating=5

The parameters from the array right before executing the query is returning rating as an object instead of an integer, although I get it from the URL like this: (int)$_GET['rating'];

This is the error I get:

Array ( [:permalink] => game-of-thrones [:rating] => Rating Object ( [dbh:Rating:private] => PDO Object ( ) ) [:ip] => ::1 [:userid] => 32 )

Catchable fatal error: Object of class Rating could not be converted to string in D:\xampp\htdocs\TVShowCalendar\inc\rate.php on line 20

What could be the reason?

Upvotes: 0

Views: 25

Answers (1)

Jerodev
Jerodev

Reputation: 33186

You are overwriting the $rating variable on line 33 with a new object before using it on line 35.

Consider using another name for either variable.

Upvotes: 2

Related Questions