dean7 Posted July 13, 2010 Share Posted July 13, 2010 Hi all, ive been working on one of my scripts for my website most of today but ive came to an error which im not sure about. The Error says: Catchable fatal error: Object of class stdClass could not be converted to string in /home/www/*****-******.com/hts2.php on line 372 $racelost = mysql_query("SELECT racelost FROM garage WHERE id='$carid'") or die (mysql_error()); That is line 372, but I carnt see nothing wrong with it . Can anyone help me here please? Thanks. Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/ Share on other sites More sharing options...
Mchl Posted July 13, 2010 Share Posted July 13, 2010 What's $carid ? Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/#findComment-1085399 Share on other sites More sharing options...
dean7 Posted July 13, 2010 Author Share Posted July 13, 2010 What's $carid ? That the varibal which gets what car the user is in. Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/#findComment-1085402 Share on other sites More sharing options...
Mchl Posted July 13, 2010 Share Posted July 13, 2010 What does var_dump($carid); say? Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/#findComment-1085406 Share on other sites More sharing options...
dean7 Posted July 13, 2010 Author Share Posted July 13, 2010 What does var_dump($carid); say? Where you get that bit from? Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/#findComment-1085408 Share on other sites More sharing options...
Mchl Posted July 13, 2010 Share Posted July 13, 2010 You put it in your code just before line 372 and see what gets displayed. Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/#findComment-1085412 Share on other sites More sharing options...
dean7 Posted July 13, 2010 Author Share Posted July 13, 2010 oh sorry lol didnt noticed I had to copy it. But this is what It displayed: object(stdClass)#3 (1) { ["carid"]=> string(1) "1" } Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/#findComment-1085414 Share on other sites More sharing options...
Mchl Posted July 13, 2010 Share Posted July 13, 2010 Here's your error. $carid is in fact an object (I'm guessing coming from mysql_fetch_object) that contains the value you need. Your query should look like this: $racelost = mysql_query("SELECT racelost FROM garage WHERE id='{$carid->carid}'") or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/#findComment-1085415 Share on other sites More sharing options...
dean7 Posted July 13, 2010 Author Share Posted July 13, 2010 Here's your error. $carid is in fact an object (I'm guessing coming from mysql_fetch_object) that contains the value you need. Your query should look like this: $racelost = mysql_query("SELECT racelost FROM garage WHERE id='{$carid->carid}'") or die (mysql_error()); Thanks, that worked to remove that error. Link to comment https://forums.phpfreaks.com/topic/207619-catchable-fatal-error/#findComment-1085424 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.