Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2003
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is this valid code?

    Im trying to get it to make my query based on varibles passed in a form, however im getting a parse error with this code. Can you use the $_GET method inside a query like this? What did i do wrong?


    PHP Code:
    $query1 "INSERT into customer(cust_name, case_id, notebook_model, notebook_serial, capture, error_msg) VALUES 
    ("
    $_GET['customer']", "$_GET['case_id']", "$_GET['notebook_model']", "$_GET['notebook_serial']", "$_GET['capture']", "$_GET['error_msg']")"


    Parse error: parse error, unexpected T_VARIABLE in c:\inetpub\wwwroot\hdd-form.php on line 20



    thanks guys!
    Last edited by mymilkexpired; 09-18-2003 at 05:35 PM.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    ('$_GET[customer]''$_GET[case_id]''$_GET[notebook_model]''$_GET[notebook_serial]''$_GET[capture]''$_GET[error_msg]'

  • #3
    New Coder
    Join Date
    May 2003
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! i couldnt figure out what i had done wrong :/

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,106
    Thanks
    11
    Thanked 101 Times in 99 Posts
    nitpicking I know but that should be ...

    PHP Code:
    <?
    ('{$_GET['customer']}''{$_GET['case_id']}''{$_GET['notebook_model']}''{$_GET['notebook_serial']}''{$_GET['capture']}''{$_GET['error_msg']}')
    ?>
    or

    ('" . $_GET['customer'] . "' , '" . $_GET['case_id'] //etc for older PHP versions
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    New Coder
    Join Date
    May 2003
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You know its funny you say that, i was searching my arse off trying to figure out what i was doing wrong and i came across something that was on PHP.net under the $foo[bar]; tutorial for arrays and they showed the example you did with the {}

    At least now i know the correct way... thanks again

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just to confuse the hell out of you,

    PHP Code:
    $query1 "INSERT into customer(cust_name, ...) VALUES ('$_GET[customer]', ...)"
    should work as Nightfire showed already, your initial problem was incorrect nesting of quotes. Single quotes within double quotes aren't a problem though.
    De gustibus non est disputandum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •