drisate Posted December 5, 2008 Share Posted December 5, 2008 Hey guys ... i think i am facing a PHP compatibility issue with an open source script. My server is on PHP4 and this script $result = mysql_query("SELECT * FROM languages WHERE id = ".ucfirst($langdetect)) or die('Query failed get seasons: ' . mysql_error()); $detectedlang = mysql_fetch_object($result)->name; $result = mysql_query("SELECT * FROM languages WHERE id = $langid") or die('Query failed get seasons: ' . mysql_error()); $enteredlang = mysql_fetch_object($result)->name; $errormessage .= "You attempted to enter an $detectedlang overview into the $enteredlang overview field. Please pick the correct language and try again. If the language detected is wrong please come to the forums and let us know.<br/>"; is returning Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/betable/public_html/tv/index.php on line 284 Can you guys help me rephrase the code above? Quote Link to comment https://forums.phpfreaks.com/topic/135609-t_object_operator/ Share on other sites More sharing options...
genericnumber1 Posted December 5, 2008 Share Posted December 5, 2008 That error would only occur if you are using php 4. Upgrade to php 5 to fix it or just don't chain the function to the object operator. Quote Link to comment https://forums.phpfreaks.com/topic/135609-t_object_operator/#findComment-706537 Share on other sites More sharing options...
drisate Posted December 5, 2008 Author Share Posted December 5, 2008 Your a genious genericnumber1 (sarcastic) lol My question was "Can you guys help me rephrase the code above?" I new it was a compatibility issue hehe Quote Link to comment https://forums.phpfreaks.com/topic/135609-t_object_operator/#findComment-706783 Share on other sites More sharing options...
premiso Posted December 5, 2008 Share Posted December 5, 2008 Your a genious genericnumber1 (sarcastic) lol My question was "Can you guys help me rephrase the code above?" I new it was a compatibility issue hehe Why not just look up the functions it uses via php.net and see which is compatible with php 4 and or 5 and the proper usage for each? mysql_fetch_object You either need to create a class, and put the results in the class or I would suggest just using mysql_fetch_assoc instead. $detectedlang = mysql_fetch_assoc($result); $detectedlang = $detectedlang['name']; Quote Link to comment https://forums.phpfreaks.com/topic/135609-t_object_operator/#findComment-706790 Share on other sites More sharing options...
genericnumber1 Posted December 5, 2008 Share Posted December 5, 2008 No need to be snippy, I thought it was a good answer When you said "a compatibility issue" I assumed you were referring to you conflicting with a script, not that this wasn't your code. I'll repeat what I said: "don't chain the function to the object operator" <?php $detectedlang = mysql_fetch_object($result)->name; ?> changed to <?php $detectedlang = mysql_fetch_object($result); $detectedlang = $detectedlang->name; ?> Try to be polite and ask what I mean instead of assuming I didn't answer your question. Quote Link to comment https://forums.phpfreaks.com/topic/135609-t_object_operator/#findComment-707002 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.