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
    New Coder
    Join Date
    Jun 2003
    Location
    USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SELECT table FROM field

    The problem I am having is that I want a system where if I type in my client's name, it will find them in my database. My code is:

    PHP Code:
    $result mysql_query("SELECT * FROM clients WHERE Name = $name",$db); 
    which is fine, the trouble comes into play when I put a space in the "Name" field in my database. (ex I want "Joe Smith" instead of "JoeSmith")

    So when I put a space in the name, the code won't read the database entry, but if I leave no spaces it works fine.

    Can anyone help me? Thank in advance.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    spaces or not shouldn't make a difference. As long as both values (value in db and value of $name is the same)
    Maybe print the value for $name to look if you have the complete name inthere
    (with print $name; )

  • #3
    New Coder
    Join Date
    Jun 2003
    Location
    USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks,


    I figured out the problem. I put single quotations around $name and it worked correctly.

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i overlooked that


  •  

    Posting Permissions

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