将 Geo Ip 放入数据库 问题 PHP
嘿,我知道这个标题真的很糟糕......我不知道还能说什么。无论如何,我有一个网站,我想跟踪他们的 ip 和地理地址 ip,并从 CSS-Tricks 中找到了这个片段, http://css-tricks.com/snippets/php/get-geo-ip-information/ 我得到了这个工作,返回的是 Array ( [domain] => dslb-094-219-040-096.pools.arcor-ip.net [country] => DE - 德国 [state] = > 黑森州 [城镇] => 弗尔斯海姆)
我制作了一张表,想要剖析该数组,并将城市放入一个 mysql 行,将国家/地区放入另一行,将域放入另一行。谁能帮我制作一个 mysql 插入,将所有这些不同的数据插入到每个相应的 mysql 行中?
感谢您的帮助...我最近才开始学习 php,所以我仍然是一个初学者。
Hey, I know the title is really bad...I didn't know what else to say. Well anyways, I have a website that I want to track their ip and geo address ip, and found this snippet from CSS-Tricks, http://css-tricks.com/snippets/php/get-geo-ip-information/
I got that working, and the return was Array ( [domain] => dslb-094-219-040-096.pools.arcor-ip.net [country] => DE - Germany [state] => Hessen [town] => Fl�rsheim )
.
I have made a table and want to disect that array and put city into one mysql row, country into another one, and domain into another one. Can anyone help me make a mysql insert that inserts all of these different datas into each corresponding mysql row?
Thanks for all help...I have just recently started learning php, so I am still quite of a beginner.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于 geoCheckIP 已经返回一个数组(了解更多),您可以这样做如下所示:
您将读取每个值,如下所示:
MySQL 插入类似于:
有关 mysql_real_escape_string 的更多信息
有关 php 和 mysql 的更多信息
Since the geoCheckIP already returns an array (read more), you can do as follow:
And you would read each value like:
And a MySQL insert for this would be something like:
More on mysql_real_escape_string
More on php and mysql