Using PHP "Variable" in SQL Statement

Discussion in 'MySQL' started by LindseyInteractive, Dec 27, 2011.

  1. #1
    Okay, I am trying to use a "Variable" in a SQL Statement, but I keep getting errors when I do it.

    Here is the current one, that works perfectly fine:

    But then I try to do a variable in the place of service_name="SEO Budget Package"'; and I get errors, here is what I try to do:


    I would think it would be the same thing but it gives me a :

    Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\sismedia\orders\fetch.php on line 17
     
    Solved! View solution.
    LindseyInteractive, Dec 27, 2011 IP
  2. #2
    look here:
    
    $sql="SELECT * FROM services WHERE service_name='$variable' ";
    
    PHP:
     
    gapz101, Dec 27, 2011 IP
    SISMediaGroup likes this.
  3. LindseyInteractive

    LindseyInteractive Well-Known Member

    Messages:
    2,830
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    175
    #3
    Thank you alot Gapz101.
     
    LindseyInteractive, Dec 27, 2011 IP