scottt Posted January 28, 2009 Share Posted January 28, 2009 I'm trying to check whether a variable in my code is equal to a session variable I've stored, and set a radio button accordingly. The following code gives a "Function Name Must Be a String" error on the line with the $_SESSION variable. I'm not sure what I'm doing wrong since I'm fairly new to PHP still. In the debugger I'm using, $_SESSION('item_icon') is a string such as "car.jpg" or "boat.jpg". Thanks. print "<td><img src=$file><br><input type=\"radio\" name=\"myradio\" id=\"myradio\" value=\"$file\""; if ($_SESSION('item_icon') == $file) { print "checked = \"true\""; } else { print "checked = \"false\""; } print "\"></td>"; Link to comment https://forums.phpfreaks.com/topic/142848-solved-function-name-must-be-a-string-error/ Share on other sites More sharing options...
gevans Posted January 28, 2009 Share Posted January 28, 2009 if ($_SESSION['item_icon'] == $file) { You were using parenthesis instead of square brackets Link to comment https://forums.phpfreaks.com/topic/142848-solved-function-name-must-be-a-string-error/#findComment-748831 Share on other sites More sharing options...
DarkWater Posted January 28, 2009 Share Posted January 28, 2009 The correct syntax is $_SESSION['item_icon']. You're using ( ). By doing that, you're making PHP think you're calling a function. Link to comment https://forums.phpfreaks.com/topic/142848-solved-function-name-must-be-a-string-error/#findComment-748832 Share on other sites More sharing options...
scottt Posted January 28, 2009 Author Share Posted January 28, 2009 Thanks, I knew it had to be something stupid. Link to comment https://forums.phpfreaks.com/topic/142848-solved-function-name-must-be-a-string-error/#findComment-748836 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.