Encapsed Error Error Expecting Parse Syntax T Unexpected Whitespace
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have expecting identifier (t_string) or variable (t_variable) or number (t_num_string) Meta Discuss the workings and policies of this site About Us parse error syntax error unexpected t_encapsed_and_whitespace expecting Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with t_encapsed_and_whitespace wordpress us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers,
Syntax Error, Unexpected T_variable
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 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 '' unexpected t_string (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 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 bug
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 parse error: syntax error, unexpected end of file About Us Learn more about Stack Overflow the company Business Learn more about
Heredoc In Php
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Php Code Checker
the Stack Overflow Community Stack Overflow is a community of 4.7 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 http://stackoverflow.com/questions/17868387/parse-error-syntax-error-unexpected-t-encapsed-and-whitespace or T_VARIABLE or T_NUM_STRING error up vote 5 down vote favorite 4 i've been staringly 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 http://stackoverflow.com/questions/9583035/unexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-or-t-num 0:46 Thamilan 5,81841137 asked Mar 6 '12 at 11:43 che 44116 $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user=$rows[user]"; –Gordon 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.1k163981 answered Mar 6 '12 at 11:48 Ullas Prabhakar 93121222 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.1k163981 an
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and http://stackoverflow.com/questions/15547689/php-parse-error-syntax-error-unexpected-t-encapsed-and-whitespace-expecting-t policies of this site About Us Learn more about Stack Overflow the http://stackoverflow.com/questions/16018364/php-parsing-error-parse-error-received-on-unexpected-t-encapsed-and-whitespace 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 4.7 million programmers, just like you, helping each other. Join them; it only takes syntax error a minute: Sign up PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING [closed] up vote -3 down vote favorite This is outputting the error listed in the title. Why? $query = mysql_query("UPDATE users SET imagelocation='.$location.' WHERE user_name='.$_SESSION['user_name'].'"); php mysql share|improve this question asked Mar 21 '13 at 12:34 Charles Harris 6125 closed as not a real syntax error, unexpected question by Michael Berkowski, CBroe, fancyPants, Robby Pond, JP Silvashy Mar 21 '13 at 18:43 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question. 2 It's missing the Double quotes that separate variable from the string $query = mysql_query("UPDATE users SET imagelocation='".$location."' WHERE user_name='".$_SESSION['user_name']."'"); –MackieeE Mar 21 '13 at 12:36 add a comment| 5 Answers 5 active oldest votes up vote 1 down vote accepted Try this : $query = mysql_query("UPDATE users SET `imagelocation`='".$location."' WHERE `user_name`='".$_SESSION['user_name']."'"); share|improve this answer answered Mar 21 '13 at 12:36 Prasanth Bendra 12.4k22951 Thanks, fixed it. –Charles Harris Mar 21 '13 at 12:42 @CharlesHarris : Accept any of the answer here which helped you to solve your issue. That will be helpful for other user who come cross same issue.
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 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 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up PHP Parsing error: “Parse Error received on unexpected T_ENCAPSED AND WHITESPACE.” [closed] up vote -1 down vote favorite I am receiving a PHP Error: Parse Error received on unexpected T_ENCAPSED AND WHITESPACE. The line: ($insert .= "($POST...) is the one that is generates the error. (string)$insert; if(is_array($_POST['Year'])) { foreach($_POST['Year'] as $k=>$v) { //the following line returns the error $insert .= "($_POST['Name'][$k], $_POST['One'][$k], $_POST['Two'][$k], $_POST['Four'][$k], $_POST['Eight'][$k], $_POST['Fifteen'][$k], $_POST['LJump'][$k], $_POST['HJump'][$k], $_POST['Shotputt'][$k], $_POST['Discuss'][$k], $_POST['Javelin'][$k], $_POST['Date'][$k], $_POST['Year'][$k]),"; } $insert = substr_replace($insert ,0,-1); } else { $insert .= "($_POST['Name'], $_POST['One'], $_POST['Two'], $_POST['Four'], $_POST['Eight'], $_POST['Fifteen'], $_POST['LJump'], $_POST['HJump'], $_POST['Shotputt'], $_POST['Discuss'], $_POST['Javelin'], $_POST['Date'], $_POST['Year'])"; } $sql="INSERT INTO results_main (Name, One, Two, Four, Eight, Fifteen, LJump, HJump, Shotputt, Discuss, Javelin, Date, Year) VALUES ".$insert; $result = mysql_query($sql) or die(mysql_error()); php mysql parsing whitespace share|improve this question edited Apr 23 '13 at 16:03 JNK 41k475106 asked Apr 15 '13 at 14:54 Chris D 61 closed as too localized by John Conde, deefour, Eric Leschinski, moonwave99, NullPoiиteя Apr 15 '13 at 14:58 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