Php Syntax Error Unexpected T_encapsed_and_whitespace Expecting T_string
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 6.2 million programmers, just
Parse Error Syntax Error Unexpected T_encapsed_and_whitespace Expecting Identifier T_string
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 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, unexpected t_constant_encapsed_string 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 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 =
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 syntax error, unexpected t_variable company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Unexpected T_string
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million
Heredoc In Php
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 down vote favorite 1 This question already has an http://stackoverflow.com/questions/9583035/unexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-or-t-num 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 mysql share|improve this question edited Jul 25 '13 at 20:49 Erman Belegu 2,7471431 asked http://stackoverflow.com/questions/17868387/parse-error-syntax-error-unexpected-t-encapsed-and-whitespace 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 hazardously wrong. This is also incorrect because it won't interpolate correctly. –tadman Jul 25 '13 at 20:47 @tadman it's not my code ...so why do you downvo
(T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VA Hie i want to update my database from the form https://teamtreehouse.com/community/-parse-error-syntax-error-unexpected-tencapsedandwhitespace-expecting-identifier-tstring-or-variable-tva and from this code , i am getting this error >>>>>> "Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\about.php on line 85" HERE IS LINE 85: $query = "SELECT * FROM $tab_nam WHERE title = $_POST['title'] AND story = $_POST['story']"; Please syntax error help !! // Allow certain file formats //Note: This can be replaced by including a access type if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; exit(); syntax error unexpected } else { $uploadOk = 1; echo "Good"; echo ""; } if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; $servername = "127.0.0.1"; $username = "root"; $password = ""; $dbname = "news_db2"; $tab_nam= "news_tab"; $when=getdate(); $yr=$when["year"]; $mon=$when["month"]; $day=$when["mday"]; $zuva=$day." ".$mon." ".$yr; $conn = new mysqli($servername, $username, $password); // Create database $sql = "CREATE DATABASE IF NOT EXISTS $dbname"; if ($conn->query($sql) === TRUE) { echo "Database created successfully".""; } else { echo "Error creating database: " . $conn->error.""; } // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // sql to create table $sql = "CREATE TABLE IF NOT EXISTS $tab_nam( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, title VARCHAR(150) NOT NULL, story TEXT(30) NOT NULL, reporter VARCHAR(50), img VARCHAR(50), det VARCHAR(50) )"; if ($conn->query($sql) === TRUE) { echo "Table ".$tab_nam." created successfully" ."