Php Error Unexpected T_encapsed_and_whitespace
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more parse error: syntax error, unexpected t_encapsed_and_whitespace, expecting ']' about Stack Overflow the company Business Learn more about hiring developers or posting t_encapsed_and_whitespace wordpress ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack unexpected t_constant_encapsed_string Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE) [duplicate] up vote 3
Syntax Error, Unexpected T_variable
down vote favorite 1 This question already has an answer here: Reference - What does this error mean in PHP? 29 answers Full Error: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) It says that the error is on line 12. Here is what I have there: $introduction="INSERT INTO Introduction (Title, Description) VALUES ('$_POST[introtitle]','$_POST['introdescription']')"; Any help would be greatly appreciated! php unexpected t_string mysql share|improve this question edited Jul 25 '13 at 20:49 Erman Belegu 2,7471431 asked Jul 25 '13 at 20:44 user1804933 1041210 marked as duplicate by Michael Berkowski, bwoebi, Gordon Jul 25 '13 at 20:48 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. 1 See stackoverflow.com/questions/12769982/… It's the quotes in $_POST['introdescription'] –Michael Berkowski Jul 25 '13 at 20:45 1 Not onto the more serious issue - this is highly vulnerable to SQL injection. You ought to be using parameterized queries via PDO or MySQLi. Read over this question and its answers. –Michael Berkowski Jul 25 '13 at 20:45 You need to read up on SQL injection bugs and how to properly escape data before you write any more SQL code. –tadman Jul 25 '13 at 20:48 add a comment| 1 Answer 1 active oldest votes up vote 6 down vote accepted You have extra single quotes : $introduction="INSERT INTO Introduction (Title, Description) VALUES ('$_POST[introtitle]','$_POST[introdescription]')"; share|improve this answer edited Jan 29 '15 at 6:12 answered Jul 25 '13 at 20:45 Fabien TheSolution 3,9201521 1 Any answer with $_POST in the query string is
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the heredoc in php company Business Learn more about hiring developers or posting ads with us Stack Overflow
Parse Error: Syntax Error, Unexpected End Of File
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2
Undefined Index Php
million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error up vote 5 down vote favorite 4 i've been staringly http://stackoverflow.com/questions/17868387/parse-error-syntax-error-unexpected-t-encapsed-and-whitespace blanky at this error and can't seem to know what the problem is.When i run the query i get this error: unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING at this line: $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user=$rows['user'] "; php mysql select share|improve this question edited Jun 11 at 0:46 Thamilan 5,96841237 asked Mar 6 '12 at 11:43 che 44116 $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user=$rows[user]"; –Gordon http://stackoverflow.com/questions/9583035/unexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-or-t-num Mar 6 '12 at 11:49 See the chapter on variable parsing in strings. And let's hope you sanitized these values before interpolating them into your query instead of using prepared statements. –Gordon Mar 6 '12 at 11:52 add a comment| 4 Answers 4 active oldest votes up vote 16 down vote accepted try this echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' "; share|improve this answer edited Mar 6 '12 at 12:47 Toto 47.2k163981 answered Mar 6 '12 at 11:48 Ullas Prabhakar 94621222 thanks,it worked.but now let's say i want to updat more than one row how do i do that because this code doesn't seem to work: echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty AND name=$name WHERE user='".$rows['user']."' "; –che Mar 9 '12 at 12:40 add a comment| up vote 3 down vote Use { before $ sign. And also add addslashes function to escape special characters. $sqlupdate1 = "UPDATE table SET commodity_quantity=".$qty."WHERE user=".addslashes($rows['user'])."'"; share|improve this answer edited Mar 6 '12 at 12:47 Toto 47.2k163981 answered Mar 6 '12 at 11:55 kumar_v 6,78272443 add a comment| up vote 1 down vote Try $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user={$rows['user']} "; You need curly brackets for array access in double quoted strings. share|improve this answer edited Mar 6 '12 at 12:
here for a quick overview of the site Help Center Detailed answers to any questions you might have http://stackoverflow.com/questions/35310991/error-parse-error-syntax-error-unexpected-t-encapsed-and-whitespac Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like syntax error, you, helping each other. Join them; it only takes a minute: Sign up Error : ( ! ) Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) up vote 1 down vote favorite Good morning I am having some issues with this search script this morning i keep getting this error ! ) Parse error: syntax error, unexpected syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\wamp\www\schoolmanagementsystem\search.php on line 24 My Source code Looks like this
Enter Student name : "; // Error here } mysqli_free_result($result); //$result->close(); } ?> Need Help Seriously php mysql row share|improve this question asked Feb 10 at 9:16 Nnaerich Doughan 124 1 try this echo "{$row['Fullname']} {$row['studentNo']} {$row['SubjectName']} {$row['GPA']} {$row['CGPA']} {$row['SCORE']}
"; And are you trying to concatinate those strings? –roullie Feb 10 at 9:19 Works great! but can i put in tables