kbown Posted June 13, 2005 Posted June 13, 2005 Hi All, These parsing errors are driving me nuts! Which symbols need a \ to avoid parsing errors? I have found several different posts that reference the single quote and asterisk. Are there any other symbols that require this? I just purchased the osCommerce books in hope this will help me but I they won't arrive for a couple more days. Any help would be greatly appreciated. This is the parsing error I am currently getting: Parse error: parse error, unexpected T_STRING in /hsphere/local/home/cardsbyk/cards-by-karen.com/catalog/includes/languages/english.php on line 146 Thanks, Karen
Guest Posted June 14, 2005 Posted June 14, 2005 Look for quotes " and ' Jenn Hi All, These parsing errors are driving me nuts! Which symbols need a \ to avoid parsing errors? I have found several different posts that reference the single quote and asterisk. Are there any other symbols that require this? I just purchased the osCommerce books in hope this will help me but I they won't arrive for a couple more days. Any help would be greatly appreciated. This is the parsing error I am currently getting: Parse error: parse error, unexpected T_STRING in /hsphere/local/home/cardsbyk/cards-by-karen.com/catalog/includes/languages/english.php on line 146 Thanks, Karen <{POST_SNAPBACK}>
kbown Posted June 14, 2005 Author Posted June 14, 2005 Look for quotes " and 'Jenn <{POST_SNAPBACK}> I'm not sure I understand ... I know that the information inside the single quotes is what is causing my problems. Are you saying that I also need to look at the info inside the double quotes as well? Also which symbols need the forward or backslash. I'm not sure which slash it needs. I know in the sense of an apostrophe the backslash is needed. I saw someone else respond elsewhere that a forward slash was needed in front of an asterisk. OR, are you refering specifcally to my parsing error for line 146? I'm not sure what your response is in response to. Thanks, Karen :'(
Guest Posted June 14, 2005 Posted June 14, 2005 I'm not sure I understand ... I know that the information inside the single quotes is what is causing my problems. Are you saying that I also need to look at the info inside the double quotes as well? Also which symbols need the forward or backslash. I'm not sure which slash it needs. I know in the sense of an apostrophe the backslash is needed. I saw someone else respond elsewhere that a forward slash was needed in front of an asterisk. OR, are you refering specifcally to my parsing error for line 146? I'm not sure what your response is in response to. Thanks, Karen :'( <{POST_SNAPBACK}> If it is so that it enters into a database without error then it is only ' that need to be escaped and it is a \' Use the php function addslashes($VariableThatNeedsFixed); When retrieved from the database you will need to use stripslashes() function. [rant] I just spent the past 2 hours fixing this for lastnames of customers (cant believe they didnt think of this when they wrote it. does no one in USA have a single quote in their last name like O'keefe) [/rant]
FalseDawn Posted June 14, 2005 Posted June 14, 2005 Mike, mysql_real_escape_string() is the preferred method to achieve this, and there are also other factors to consider, like whether or not magic_quotes_gpc is set on or not (IMO it should never be set, but I think OSC assumes it is set, so any GPC data should automatically be escaped anyway) Regarding the original problem, escapes are useful where you need to include apostrophes or double quotes in strings themselves. EG: DEFINE('MYSTRING', 'This is Bob's book'); Will give the error, since the parser sees the ' in Bob's as the end of the string. To correct this, it needs to be escaped, like so: DEFINE('MYSTRING', 'This is Bob\'s book'); Asterisks do not need to be escaped. You might be thinking of the /*... */ comment tags.
kbown Posted June 14, 2005 Author Posted June 14, 2005 I'm still confused. Could someone tell me why I am getting this parsing error? Parse error: parse error, unexpected T_STRING in /hsphere/local/home/cardsbyk/cards-by-karen.com/catalog/includes/languages/english.php on line 146 Here is the code slightly before and slightly after this line: // pull down default text define('PULL_DOWN_DEFAULT', 'Please Select'); define('TYPE_BELOW', 'Type Below'); // javascript messages define('JS_ERROR', 'Errors have occured during the process of your form.nnPlease make the following corrections:nn'); I'm not sure why I am getting an error here. I got a parsing error for line 79 prior to this. I tried putting the slash in front of the apostrophe in that line but would would never take. Since I had taken out the what's new part on the colum left/right php files I just commented it out of the english.php file. Currently I can not see my catalog. I could really use some help! Thanks, Karen
Guest Posted June 14, 2005 Posted June 14, 2005 Mike,mysql_real_escape_string() is the preferred method to achieve this... I guess it would depend on which version of PHP they are running as this was available from 4.3 onwards agree about the magic quotes, it should be checked using get_magic_quotes_gpc() function.
FalseDawn Posted June 14, 2005 Posted June 14, 2005 Karen, please post the whole file - there is nothing wrong with those lines (apart from the spurious nn's in there - but they wouldn't cause an error.)
kbown Posted June 15, 2005 Author Posted June 15, 2005 Hi All, My website host was able to help me. This was there response. Ok, so PHP uses single quotes to denote strings; so if you have single quotes in text fields they can cause problems sometimes. On line 146 you had the following, which has some mis-placed quotes: define('JS_REVIEW_TEXT', '* The 'Review Text' must have at least ' . REVIEW_TEXT_MIN_LENGTH . ' characters.n'); The all caps stuff are variables; essentially this line in combining a couple strings and variables into one big string. It's using single quotes, as you can see, to encapsilate each field. However, the "* The 'Review Text' must have at least" line contains single quotes inside the string; so essentially it's telling the script to end a string where it's not supposed to. To fix this you just add slashes to escape the single quotes; like so: define('JS_REVIEW_TEXT', '* The \'Review Text\' must have at least ' . REVIEW_TEXT_MIN_LENGTH . ' characters.n'); One small change, but it makes the world of difference as far as PHP is concerned. Thanks, Karen
Guest Posted June 15, 2005 Posted June 15, 2005 Well thats not the same Line 146 you pasted in previous posts. So unless you give us the correct info it pretty difficult to help. Mike
Recommended Posts
Archived
This topic is now archived and is closed to further replies.