unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING errorunexpected T_ENCAPSED_AND_WHITESPACEunexpected '' (T_ENCAPSED_AND_WHITESPACE)unexpected (T_ENCAPSED_AND_WHITESPACE) errorMultiple Updates in MySQLParse Error: (T_ENCAPSED_AND_WHITESPACE)PHP: shopping cart empty after clicking the add buttonConvert HTML + CSS to PDF with PHP?Reference — What does this symbol mean in PHP?PHP Parse Error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRINGHow does PHP 'foreach' actually work?Reference - What does this error mean in PHP?PHP parse/syntax errors; and how to solve them?Can not figure outsyntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING(T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)update function: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRINGError unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

what kind of chord progession is this?

Could a 19.25mm revolver actually exist?

How did these characters "suit up" so quickly?

Pirate democracy at its finest

Popcorn is the only acceptable snack to consume while watching a movie

Need to understand my home electrical meter to see why bill is so high and/or if neighbor is on same meter

Why are C64 games inconsistent with which joystick port they use?

Why do most published works in medical imaging try to reduce false positives?

Construct a word ladder

Have 1.5% of all nuclear reactors ever built melted down?

Why didn't Thanos use the Time Stone to stop the Avengers' plan?

Is it true that cut time means "play twice as fast as written"?

Which melee weapons have the Two-Handed property, but lack Heavy and Special?

How should I introduce map drawing to my players?

Is the Indo-European language family made up?

Where is the logic in castrating fighters?

Can I tell a prospective employee that everyone in the team is leaving?

Can a person survive on blood in place of water?

Using credit/debit card details vs swiping a card in a payment (credit card) terminal

Apache redirect to https:/www only partially working

Why is this Simple Puzzle impossible to solve?

The usage of "run a mile" in a sentence

Should I disclose a colleague's illness (that I should not know) when others badmouth him

Grammar Question Regarding "Are the" or "Is the" When Referring to Something that May or May not be Plural



unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error


unexpected T_ENCAPSED_AND_WHITESPACEunexpected '' (T_ENCAPSED_AND_WHITESPACE)unexpected (T_ENCAPSED_AND_WHITESPACE) errorMultiple Updates in MySQLParse Error: (T_ENCAPSED_AND_WHITESPACE)PHP: shopping cart empty after clicking the add buttonConvert HTML + CSS to PDF with PHP?Reference — What does this symbol mean in PHP?PHP Parse Error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRINGHow does PHP 'foreach' actually work?Reference - What does this error mean in PHP?PHP parse/syntax errors; and how to solve them?Can not figure outsyntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING(T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)update function: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRINGError unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








15















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'] ";









share|improve this question
























  • $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


















15















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'] ";









share|improve this question
























  • $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














15












15








15


6






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'] ";









share|improve this question
















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















share|improve this question













share|improve this question




share|improve this question








edited Jun 11 '16 at 0:46









Thamilan

10.9k42649




10.9k42649










asked Mar 6 '12 at 11:43









cheche

94117




94117












  • $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


















  • $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

















$sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user=$rows[user]";

– Gordon
Mar 6 '12 at 11:49





$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






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













4 Answers
4






active

oldest

votes


















31














try this



echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' ";





share|improve this answer

























  • 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



















8














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
































    6














    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




















    • 1





      you dont need to add curly braces. you can simply omit the single quotes.

      – Gordon
      Mar 6 '12 at 11:47












    • Move the bracket in front of the dollar sign

      – MMM
      Mar 6 '12 at 11:49



















    2














    Change your code to.



    <?php
    $sqlupdate1 = "UPDATE table SET commodity_quantity=".$qty."WHERE user=".$rows['user'];
    ?>


    There was syntax error in your query.






    share|improve this answer























    • thanks,it worked.but now let's say i want to update 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:44











    • For that see this. stackoverflow.com/questions/3432/multiple-updates-in-mysql and tizag.com/sqlTutorial/sqlupdate.php

      – Milap
      Mar 9 '12 at 12:57












    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9583035%2funexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-or-t-num%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    31














    try this



    echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' ";





    share|improve this answer

























    • 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
















    31














    try this



    echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' ";





    share|improve this answer

























    • 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














    31












    31








    31







    try this



    echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' ";





    share|improve this answer















    try this



    echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' ";






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 6 '12 at 12:47









    Toto

    67.7k1758100




    67.7k1758100










    answered Mar 6 '12 at 11:48









    Ullas PrabhakarUllas Prabhakar

    1,38332024




    1,38332024












    • 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


















    • 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

















    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






    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














    8














    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





























      8














      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



























        8












        8








        8







        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















        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














        share|improve this answer



        share|improve this answer








        edited Mar 6 '12 at 12:47









        Toto

        67.7k1758100




        67.7k1758100










        answered Mar 6 '12 at 11:55









        Kumar VKumar V

        7,88083252




        7,88083252





















            6














            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




















            • 1





              you dont need to add curly braces. you can simply omit the single quotes.

              – Gordon
              Mar 6 '12 at 11:47












            • Move the bracket in front of the dollar sign

              – MMM
              Mar 6 '12 at 11:49
















            6














            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




















            • 1





              you dont need to add curly braces. you can simply omit the single quotes.

              – Gordon
              Mar 6 '12 at 11:47












            • Move the bracket in front of the dollar sign

              – MMM
              Mar 6 '12 at 11:49














            6












            6








            6







            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















            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














            share|improve this answer



            share|improve this answer








            edited Mar 6 '12 at 12:40

























            answered Mar 6 '12 at 11:45









            xatoxato

            1,9111122




            1,9111122







            • 1





              you dont need to add curly braces. you can simply omit the single quotes.

              – Gordon
              Mar 6 '12 at 11:47












            • Move the bracket in front of the dollar sign

              – MMM
              Mar 6 '12 at 11:49













            • 1





              you dont need to add curly braces. you can simply omit the single quotes.

              – Gordon
              Mar 6 '12 at 11:47












            • Move the bracket in front of the dollar sign

              – MMM
              Mar 6 '12 at 11:49








            1




            1





            you dont need to add curly braces. you can simply omit the single quotes.

            – Gordon
            Mar 6 '12 at 11:47






            you dont need to add curly braces. you can simply omit the single quotes.

            – Gordon
            Mar 6 '12 at 11:47














            Move the bracket in front of the dollar sign

            – MMM
            Mar 6 '12 at 11:49






            Move the bracket in front of the dollar sign

            – MMM
            Mar 6 '12 at 11:49












            2














            Change your code to.



            <?php
            $sqlupdate1 = "UPDATE table SET commodity_quantity=".$qty."WHERE user=".$rows['user'];
            ?>


            There was syntax error in your query.






            share|improve this answer























            • thanks,it worked.but now let's say i want to update 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:44











            • For that see this. stackoverflow.com/questions/3432/multiple-updates-in-mysql and tizag.com/sqlTutorial/sqlupdate.php

              – Milap
              Mar 9 '12 at 12:57
















            2














            Change your code to.



            <?php
            $sqlupdate1 = "UPDATE table SET commodity_quantity=".$qty."WHERE user=".$rows['user'];
            ?>


            There was syntax error in your query.






            share|improve this answer























            • thanks,it worked.but now let's say i want to update 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:44











            • For that see this. stackoverflow.com/questions/3432/multiple-updates-in-mysql and tizag.com/sqlTutorial/sqlupdate.php

              – Milap
              Mar 9 '12 at 12:57














            2












            2








            2







            Change your code to.



            <?php
            $sqlupdate1 = "UPDATE table SET commodity_quantity=".$qty."WHERE user=".$rows['user'];
            ?>


            There was syntax error in your query.






            share|improve this answer













            Change your code to.



            <?php
            $sqlupdate1 = "UPDATE table SET commodity_quantity=".$qty."WHERE user=".$rows['user'];
            ?>


            There was syntax error in your query.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 6 '12 at 11:47









            MilapMilap

            5,33971943




            5,33971943












            • thanks,it worked.but now let's say i want to update 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:44











            • For that see this. stackoverflow.com/questions/3432/multiple-updates-in-mysql and tizag.com/sqlTutorial/sqlupdate.php

              – Milap
              Mar 9 '12 at 12:57


















            • thanks,it worked.but now let's say i want to update 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:44











            • For that see this. stackoverflow.com/questions/3432/multiple-updates-in-mysql and tizag.com/sqlTutorial/sqlupdate.php

              – Milap
              Mar 9 '12 at 12:57

















            thanks,it worked.but now let's say i want to update 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:44





            thanks,it worked.but now let's say i want to update 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:44













            For that see this. stackoverflow.com/questions/3432/multiple-updates-in-mysql and tizag.com/sqlTutorial/sqlupdate.php

            – Milap
            Mar 9 '12 at 12:57






            For that see this. stackoverflow.com/questions/3432/multiple-updates-in-mysql and tizag.com/sqlTutorial/sqlupdate.php

            – Milap
            Mar 9 '12 at 12:57


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9583035%2funexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-or-t-num%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript