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,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 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,329
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    For an explanation about how to use quotation marks in php see the link about quotes in my signature below.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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