Remote IP in Query

From: BeBoo (macbrando2001_at_hotmail.com)
Date: 12/26/03


Date: Fri, 26 Dec 2003 09:10:24 -0500

I've been trying and trying and I got it once and I don't know how I did it.
I need to grab the person's IP address and put it in the WHERE part of the
sql query. I have the following:

 $sql = " SELECT * FROM ipandname ";
 $sql .= " WHERE IP = {$_SERVER['REMOTE_ADDR']} ";

But I get the following on the page:

Database Error: SELECT * FROM ipandname WHERE IP = 68.83.29.13 You have an
error in your SQL syntax. Check the manual that corresponds to your MySQL
server version for the right syntax to use near '.29.13' at line 1

It thinks that the IP address is a number (obviously you can't have more
than one decimal point in a number). IP is defined as a char(20). How do I
put the $_Server variable INTO the query and make sure it thinks it's just a
string? Any help at all would be appreciated.

Thanks a lot.
Brandon



Relevant Pages

  • Re: Remote IP in Query
    ... "BeBoo" wrote in message ... > sql query. ... > error in your SQL syntax. ...
    (alt.php)
  • Access: Getting the beginning date of the current week
    ... I don't want to have to hard code any dates. ... In a SQL query, I should be ... able to grab just the records whose date is between Sun and Sat of the ...
    (microsoft.public.access.queries)
  • Re: LEFT OUTER JOIN possible in DB2?
    ... the AS400 doesn't use SQL Syntax. ... Or are you using some lower level of access to the database files? ... > "Reference Information", "SQL Query ...
    (microsoft.public.sqlserver.programming)