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.
$add = mysql_query("INSERT INTO vote (konu,mail,Code) VALUES ('$subject','$row ["email"]','$sayilar[$j]')");

Parse error: syntax error, unexpected T_STRING in on line 68

share|improve this question
2  
Use an editor with syntax highlighting: there's a " in there that ends your literal string. –  Wrikken Dec 18 '13 at 23:29
1  
This question appears to be off-topic because it is about obsolete technology (the MySQL extension). The question and subsequent answers will help nobody. –  Phil Dec 18 '13 at 23:32
1  
@MikeBrant The MySQL extension does not allow developers to use parameter binding. If the OP used one of the alternatives with a prepared statement and bound parameters, this problem would not arise at all. –  Phil Dec 18 '13 at 23:36
3  
This question appears to be off-topic because it is about syntax errors. –  mario Dec 18 '13 at 23:38
2  
@MikeBrant This is one of the stupidest questions on SO –  user4035 Dec 18 '13 at 23:40
show 5 more comments

closed as off-topic by Phil, mario, user4035, TLama, Michael Hampton Dec 19 '13 at 0:58

  • This question does not appear to be about programming within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

up vote 0 down vote accepted

Look at the syntax highlighting in your question. It will clearly show you that you have unescaped quotes in your string.

Developers learning PHP often fall into the trap of trying to rely too much on PHP flexibility to interpolate variables in strings. I would strongly recommend you not rely on this functionality and instead clearly seperate your vairables from fixed string elements. It will make you code easier to read and avoid the vast majority of escaping problems.

So your code could look like this:

query("INSERT INTO vote (konu,mail,Code) VALUES ('" . $subject . "','" . $row['email'] . "','" . $sayilar[$j] . "')");

See how much clearer it is in with syntax highlighting to see exactly where your variables are?

share|improve this answer
add comment

Try either

$add = mysql_query("INSERT INTO vote (konu,mail,Code) VALUES ('$subject','".$row ["email"]."','$sayilar[$j]')");

or better

$add = mysql_query(sprintf("INSERT INTO vote (konu,mail,Code) VALUES ('$subject','%s','%s')", $row ["email"], $sayilar[$j]));

The reason: The double quotes starting at "INSERT end at $row[", makeing the string construct invalid

share|improve this answer
 
@user4035 Wow! Thanks a lot for your commentless downvote. I am sure it will help the "author [, who] doesn't understand basic PHP syntax" becom less "completely useless" –  Eugen Rieck Dec 18 '13 at 23:44
add comment

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