Parse Error Syntax Error Unexpected T_encapsed_and_whitespace Expecting T_string 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
Unexpected T_encapsed_and_whitespace, Expecting T_string Or T_variable Or T_num_string
Learn more about Stack Overflow the company Business Learn more about hiring developers t_encapsed_and_whitespace wordpress or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack parse error syntax error unexpected t_encapsed_and_whitespace expecting identifier t_string Overflow Community Stack Overflow is a community of 6.2 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
Unexpected T_constant_encapsed_string
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 0:46 Thamilan 5,96841237 asked
Syntax Error, Unexpected T_variable
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 = "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 a
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 unexpected t_string Overflow the company Business Learn more about hiring developers or posting ads with us
Parse Error: Syntax Error, Unexpected End Of File
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community heredoc in php 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 down vote favorite 1 This http://stackoverflow.com/questions/9583035/unexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-or-t-num 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 mysql share|improve this question edited Jul 25 http://stackoverflow.com/questions/17868387/parse-error-syntax-error-unexpected-t-encapsed-and-whitespace '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 hazardously wrong. This is also incorrect because it won't interpolate correctly. –tadman Jul 25 '13
(T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VA Hie i want to update my database from the form and from this code , i am getting this error >>>>>> "Parse error: syntax error, https://teamtreehouse.com/community/-parse-error-syntax-error-unexpected-tencapsedandwhitespace-expecting-identifier-tstring-or-variable-tva 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 help !! // Allow certain file formats //Note: This can be replaced by including a access type if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != syntax error "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; exit(); } 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"]; parse error syntax $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" .""; } else { echo "Error creating table: " . $conn->error.""; } //Checking if newsupdate has been added to the database $query = "SELECT * FROM $tab_nam WHERE title = $_POST['title'] AND story = $_POST['story']"; $result = mysql_query($query); if ( mysql_num_rows ( $result ) > 1 ) { /* Username already exists */ echo 'Username already exists. '; } else { //sql Inserting data into the news table $sql = "INSERT INTO $tab_nam (title, story, reporter, img, det) VALUES ($_POST['title'], $_POST['story'], $_POST['reporter-name'], $_FILES[file]['img'], $zuva)"; if