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. Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 13, 2010 Share Posted July 13, 2010 What's $carid ? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 13, 2010 Share Posted July 13, 2010 What does var_dump($carid); say? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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" } Quote Link to comment 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()); Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.