Jump to content

[SOLVED] Fatal error: You have an error in your SQL syntax;


Recommended Posts

I have a php function that gets whois data and stores it in a variable well when I try to put that variable in my Database i get this fatal error:

 

Fatal error: 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 's WHOIS database. ','11', '36', '19', '03','2009', 'http://mywebsitehere/'' at line 2 in

 

i can echo the the variable and the data is there. any ideas? any help would be awesome.

 

thanks,

here is my a nip of the code

$ip_info = whois_ip($whois_ip_server, '-1', 'FALSE', $visitor_ip);

mysql_select_db($database_visitors, $visitors);
$sql = "INSERT INTO visitor_list (visitor_ip, visitor_whois, visitor_min, visitor_hour, visitor_day, visitor_month, visitor_year, 
visitor_ref, visitor_page) VALUES ('$visitor_ip','$ip_info','$visitor_hour', '$visitor_minute', '$visitor_day', '$visitor_month','$visitor_year', '$visitor_ref', '$visitor_page')";
$result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);

 

INSERT INTO visitor_list (visitor_ip, visitor_whois, visitor_min, visitor_hour, visitor_day, visitor_month, visitor_year, visitor_ref, visitor_page) VALUES ('208.252.157.121','[Querying whois.arin.net] [whois.arin.net] OrgName: MCI Communications Services, Inc. d/b/a Verizon Business OrgID: MCICS Address: 22001 Loudoun County Pkwy City: Ashburn StateProv: VA PostalCode: 20147 Country: US NetRange: 208.192.0.0 - 208.255.255.255 CIDR: 208.192.0.0/10 NetName: UUNET1996B NetHandle: NET-208-192-0-0-1 Parent: NET-208-0-0-0-0 NetType: Direct Allocation NameServer: AUTH03.NS.UU.NET NameServer: AUTH00.NS.UU.NET Comment: ADDRESSES WITHIN THIS BLOCK ARE NON-PORTABLE RegDate: 1996-05-08 Updated: 2006-12-14 RTechHandle: OA12-ARIN RTechName: UUnet Technologies, Inc., Technologies RTechPhone: +1-800-900-0241 RTechEmail: help4u@verizonbusiness.com OrgAbuseHandle: ABUSE3-ARIN OrgAbuseName: abuse OrgAbusePhone: +1-800-900-0241 OrgAbuseEmail: abuse-mail@verizonbusiness.com OrgNOCHandle: OA12-ARIN OrgNOCName: UUnet Technologies, Inc., Technologies OrgNOCPhone: +1-800-900-0241 OrgNOCEmail: help4u@verizonbusiness.com OrgTechHandle: SWIPP-ARIN OrgTechName: swipper OrgTechPhone: +1-800-900-0241 OrgTechEmail: swipper@verizonbusiness.com OrgTechHandle: JHU140-ARIN OrgTechName: Huffines, Jody OrgTechPhone: +1-703-886-6093 OrgTechEmail: Jody.Huffines@verizonbusiness.com CustName: OCD Network Integration Systems Address: 1031 East 3rd Street City: Dayton StateProv: OH PostalCode: 45402 Country: US RegDate: 2001-06-07 Updated: 2003-05-30 NetRange: 208.252.156.0 - 208.252.157.255 CIDR: 208.252.156.0/23 NetName: UU-208-252-156 NetHandle: NET-208-252-156-0-1 Parent: NET-208-192-0-0-1 NetType: Reassigned Comment: RegDate: 2001-06-07 Updated: 2003-05-30 RTechHandle: OA12-ARIN RTechName: UUnet Technologies, Inc., Technologies RTechPhone: +1-800-900-0241 RTechEmail: help4u@verizonbusiness.com OrgAbuseHandle: ABUSE3-ARIN OrgAbuseName: abuse OrgAbusePhone: +1-800-900-0241 OrgAbuseEmail: abuse-mail@verizonbusiness.com OrgNOCHandle: OA12-ARIN OrgNOCName: UUnet Technologies, Inc., Technologies OrgNOCPhone: +1-800-900-0241 OrgNOCEmail: help4u@verizonbusiness.com OrgTechHandle: SWIPP-ARIN OrgTechName: swipper OrgTechPhone: +1-800-900-0241 OrgTechEmail: swipper@verizonbusiness.com OrgTechHandle: JHU140-ARIN OrgTechName: Huffines, Jody OrgTechPhone: +1-703-886-6093 OrgTechEmail: Jody.Huffines@verizonbusiness.com # ARIN WHOIS database, last updated 2009-03-18 19:10 # Enter ? for additional hints on searching ARIN's WHOIS database. ','12', '17', '19', '03','2009', 'http://www.stratacache.com/', 'http://www.stratacache.com/0!!_company.php')

in your WHOIS info, there is the string ARIN's WHOIS which the ' needs to be escaped. use this instead:

$ip_info = whois_ip($whois_ip_server, '-1', 'FALSE', $visitor_ip);

mysql_select_db($database_visitors, $visitors);
$ip_info = mysql_real_escape_string($ip_info); //Add this line
$sql = "INSERT INTO visitor_list (visitor_ip, visitor_whois, visitor_min, visitor_hour, visitor_day, visitor_month, visitor_year,
visitor_ref, visitor_page) VALUES ('$visitor_ip','$ip_info','$visitor_hour', '$visitor_minute', '$visitor_day', '$visitor_month','$visitor_year', '$visitor_ref', '$visitor_page')";
$result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.