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 4 of 4
  1. #1
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Why has this error occured?

    ...
    $email = $_POST['e-mail'];
    ...
    query = "delete from testdb.newsletters where email="$email";
    ...
    PHP Parse error: syntax error, unexpected T_VARIABLE
    Why has this error occurred? I am so sure the error revolves around the way I've used '"$email"' and the error can be fixed with two more or less bytes lol.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    It has occurred because you're structure of the (attempted) variable is incorrect. That should be:
    PHP Code:
    $query "DELETE FROM testdb.newsletters WHERE email = '$email'"
    Case of query commands is purely for readability; it is not required in SQL.

  • Users who have thanked Fou-Lu for this post:

    Democrazy (09-10-2011)

  • #3
    Banned
    Join Date
    Sep 2011
    Posts
    140
    Thanks
    17
    Thanked 0 Times in 0 Posts
    "$email" should have been '$email'.

    Solved.

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    For an explanation about how to use quotation marks in php see the link about quotes in my signature below.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!


  •  

    Posting Permissions

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