Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

A person gets the error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE

from the following code:

$query = "SELECT story,video FROM `storycodes` WHERE `code` = '$code"';
share|improve this question

closed as too localized by John Conde, SERPRO, N.B., tereško, DaveRandom Apr 26 '13 at 8:17

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

4  
You answered your own question rather quickly –  John Conde Feb 7 '13 at 15:01
    
A person posts on stackoverflow and checks the code to realize that solving this parse error is trivial, even for a non-programmer and all it takes is a bit of reading that doesn't exceed 20 seconds of person's time. –  N.B. Feb 7 '13 at 15:05
    
I posted this to share my knowledge with others, not to ask for help on something I already know the answer for. –  michael b Feb 8 '13 at 14:19
add comment

1 Answer 1

up vote 2 down vote accepted

This error code results from placing the quotes in the wrong order. In this code it says '$code"' when it should be '$code'"

The fixed code would look like this:

$query = "SELECT story,video FROM `storycodes` WHERE `code` = '$code'";
                                                                    ^^--here
share|improve this answer
    
it's generally a good idea to put a visual indicator of where you made the change, especially when you're swapping two characters that at a glance are very similar. +1 for the right answer, though. –  Marc B Feb 7 '13 at 15:02
    
@MarcB He did the question and answered it straight away.. it's kind of weird. –  SERPRO Feb 7 '13 at 15:03
    
@serpro... blink blink I think I need to get some coffee or something. didn't even notice that. –  Marc B Feb 7 '13 at 15:08
1  
@SERPRO - No, it's not. That's actually one of the new capabilities of the question-asking interface. –  Brad Larson Feb 7 '13 at 16:01
1  
Why did I get minused for no research effort when I asked it for Q&A so I could share my knowledge. That is very unfair. People need to look closer. –  michael b Feb 7 '13 at 23:03
show 2 more comments

Not the answer you're looking for? Browse other questions tagged or ask your own question.