hjames82 Posted November 22, 2008 Share Posted November 22, 2008 I am trying to add a URL to the following code but keep receiving the error mentioned in the subject. I don't know much about php and did a search on google and yahoo but came up with no similar matches. Any help would be appreciated. Original Code: $msg .= ($test->passed) ? "PASS" : "FAIL" ; Modified Code: $msg .= ($test->passed) ? "PASS" : "FAIL - <a href="index.php?option=com_lms&task=showresults">Retake The Course</a>" ; Thanks, James Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/ Share on other sites More sharing options...
Mark Baker Posted November 22, 2008 Share Posted November 22, 2008 Proper syntax highlighting should show you where the error lies: $msg .= ($test->passed) ? "PASS" : "FAIL - <a href="index.php?option=com_lms&task=showresults">Retake The Course</a>" ; Look to escaping your quotes within quotes Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696455 Share on other sites More sharing options...
hjames82 Posted November 22, 2008 Author Share Posted November 22, 2008 Sorry buddy, I don't exactly know what you mean about escaping quotes within quotes. Can you provide me with an example? Thanks, James Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696479 Share on other sites More sharing options...
Mark Baker Posted November 22, 2008 Share Posted November 22, 2008 $msg .= ($test->passed) ? "PASS" : "FAIL - <a href=\"index.php?option=com_lms&task=showresults\">Retake The Course</a>" ; or $msg .= ($test->passed) ? "PASS" : 'FAIL - <a href="index.php?option=com_lms&task=showresults">Retake The Course</a>' ; Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696481 Share on other sites More sharing options...
hjames82 Posted November 22, 2008 Author Share Posted November 22, 2008 Ok I see now your reffering to the "\" correct? I tried using your code to se if it would work unfortunately I got this error: Parse error: syntax error, unexpected T_STRING in /home/.sylvie/hjames82/test2.bamsites.ifoundjoomla.com/components/com_lms/lms.php(1423) : eval()'d code on line 6 This is line 1423: eval ("\$message = \"$msg\";"); Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696482 Share on other sites More sharing options...
hjames82 Posted November 22, 2008 Author Share Posted November 22, 2008 I have attached the file in question [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696487 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 eval ("$message = \"$msg\";"); You have to escape only quotes within other quotes. And as to this eval line... why not just do $message = "$msg"; ?? Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696489 Share on other sites More sharing options...
hjames82 Posted November 22, 2008 Author Share Posted November 22, 2008 that seems to have worked. Can you explain why? I don't like to ask that but if I don't I will never learn for myself. Thanks, James Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696492 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 To be honest I don't know... After thinking a little, I decided it wouldn't work... and yet it does... I'm confused... Which one did you use? Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696493 Share on other sites More sharing options...
revraz Posted November 22, 2008 Share Posted November 22, 2008 Because of the way you had your double quotes. You ended the string by using the double quote in the URL. Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696495 Share on other sites More sharing options...
hjames82 Posted November 22, 2008 Author Share Posted November 22, 2008 I put this: $message = "$msg"; inplace of what was there: eval ("$message = \"$msg\";"); I have test it twice and works every time now. No errors or anything. Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696496 Share on other sites More sharing options...
Mchl Posted November 22, 2008 Share Posted November 22, 2008 Ok... eval is a function, that basically runs the code, that is passed to it in parentheses... I don't know why author of this script decided to use it here, because just running the code should work fine (and it seems it does). Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696498 Share on other sites More sharing options...
hjames82 Posted November 22, 2008 Author Share Posted November 22, 2008 Thanks a lot! I really appreciate you guys help (All of You!) Are any of you familiar with Joomla? I need a programmer to do some work and am willing to pay. Link to comment https://forums.phpfreaks.com/topic/133820-unexpected-t_string/#findComment-696500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.