Error Unexpected T_encapsed_and_whitespace Expecting T_string Or T_variable Or
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 about Stack Overflow the company expecting identifier (t_string) or variable (t_variable) or number (t_num_string) Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs parse error: syntax error, unexpected t_encapsed_and_whitespace, expecting ']' Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, t_encapsed_and_whitespace wordpress 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 blanky at this
Unexpected T_constant_encapsed_string
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,83341137 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 syntax error, unexpected t_variable 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 93621222 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 answered Mar 6 '12 at 11:55 kumar_v 6,75272343 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:40 answered Mar 6 '12 at 11:45 xato 1,4517
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 unexpected t_string about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Parse Error: Syntax Error, Unexpected End Of File
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each
Heredoc In Php
other. Join them; it only takes a minute: Sign up How do I fix this “T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING” error? up vote 0 down vote favorite I am writing a simple php registration page using MySQL http://stackoverflow.com/questions/9583035/unexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-or-t-num as the database. I am quite new to it and I came across this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\w4wregister.php on line 34 I have gone through the little bit of code that I added that caused that error for the past hour and cannot see anything wrong with it. Below I have the code I added. I believe I was able to narrow it down to the http://stackoverflow.com/questions/4558223/how-do-i-fix-this-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-o while statement but I gave the other code for context. if($r) { echo "
Thanks for registering!
Current Users:
"; $q2 = "SELECT username AS users FROM users ORDER BY registration_date"; $r2 = @mysqli_query ($dbc, $q2); //gets all users if ($r2) { echo '
Current Users:
"; $q2 = "SELECT username AS users FROM users ORDER BY registration_date"; $r2 = @mysqli_query ($dbc, $q2); //gets all users if ($r2) { echo 'Username |
$row['users'] |
here for a quick overview of the site Help Center Detailed answers to any questions http://stackoverflow.com/questions/32293692/parse-error-syntax-error-unexpected-t-encapsed-and-whitespace-expecting-t-str 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 syntax error, community of 4.7 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, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:/… on line 10 [duplicate] up vote -4 down vote favorite 1 This question already has an answer here: PHP Parse/Syntax syntax error, unexpected Errors; and How to solve them? 10 answers I don't know what is the error in line 10, line 10 is: $sql= "INSERT INTO inside VALUES{($_POST['name']),($_POST['telephone']),($_POST['comment'])}"; My database name is comments and table name is inside, and also sometimes when I finished this I got the result as 'error' I think it comes from the line 18. can you please tell me how to solve this, I'am fed of this! php mysql share|improve this question asked Aug 30 '15 at 6:00 chamiya 12 marked as duplicate by Paul Crovella, Rizier123php Users with the php badge can single-handedly close php questions as duplicates and reopen them as needed. Aug 30 '15 at 11:15 This question has been asked before and already has an answer. If those answers do not fully address your question, please