SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Sep 2008
    Location
    Dubai
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query with ip address produces error

    I'm doing a hit counter. I used VARCHAR as database field type. Inserting new record is not a problem but when I query to retrieve record, error occurs.

    The error is wrong syntax.

    Here is my query.

    HTML Code:
    "SELECT page_visited FROM hit_counter WHERE ip = {$ip}"
    $ip= 118.68.189.173

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    All string type values must be enclosed in single quotes in SQL.

    SELECT page_visited FROM hit_counter WHERE ip = '$ip'

  3. #3
    SitePoint Guru
    Join Date
    Sep 2008
    Location
    Dubai
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That will fix that. Thanks Dan!


Bookmarks

Posting Permissions

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