Syntax error, unexpected t_variable.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mushfiq
    New Member
    • Nov 2008
    • 5

    Syntax error, unexpected t_variable.

    hi.i have got a problem.

    error message:


    Parse error: syntax error, unexpected T_VARIABLE in c:\wamp\www\dyn amic2.php on line 12


    for the line:

    Code:
    $result=mysql_query("select company from dynamic where id="$id) or  die(mysql_error());
    if anyone help me,i will be greatful.
    Last edited by Markus; Nov 11 '08, 12:26 PM. Reason: added # tags
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    syntax error in function argument
    [PHP]// either
    mysql_query("sq l" . $var)
    // or
    mysql_query("sq l $var")[/PHP]
    don't forget to sanitize your input!

    regards

    Comment

    • nathj
      Recognized Expert Contributor
      • May 2007
      • 937

      #3
      1. Try using code tags next time
      2. Try changing the code to:
      Code:
      $result=mysql_query("select company from dynamic where id=$id") or die(mysql_error());
      I have brought the variable inside the string.

      Cheers
      nathj

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Mushfiq, to date you have named every thread you have started Dynamic Link. This explains nothing of the problem in this thread. We expect you to provide a meaningful title as it helps others who are searching the forum with the same problem.

        Please take note of this as I have already warned you for not using code tags (and you have failed to do so again).

        Read Posting Guidelines.

        Moderator.

        Comment

        • divyac11
          New Member
          • Nov 2008
          • 3

          #5
          change the code to

          $result=mysql_q uery("select company from dynamic where `id`="$id) or die(mysql_error ());

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            @divyac this will result in the same error (for exactly the same reasons) plus the quotation marks are in the wrong place

            *sigh*

            for some basics on strings read this

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              To all concerned it's called 'concatenation' .

              Comment

              Working...