MySQLi查询未将数据提交到我的数据库 [英] MySQLi Query not submitting data to my database

查看:81
本文介绍了MySQLi查询未将数据提交到我的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试提交的MySQLi查询出现问题,但是没有报告错误,并且绝对没有任何反应.我已经尝试了多种方法进行修复,但一无所获.

I'm having an issue with a query of MySQLi I'm trying to submit, but no errors are being reported, and absolutely nothing is happening. I've tried multiple methods for a fix, and nothing.

代码:

$IP = $_SERVER['REMOTE_ADDR'];
$ISP = GetISP($IP);
$Referrer = DetermineReferrer();
$Browser = GetBrowser();
$OS = GetOS();
$Time = Date("F/j/Y, g:i a");

If($IP){
    mysqli_query($Connection, "INSERT INTO tracker (ip, isp, referrer, browser, os, time)
                               VALUES ('mysqli_real_escape_string($IP)',    
                                       'mysqli_real_escape_string($ISP)',
                                       'mysqli_real_escape_string($Referrer)',
                                       'mysqli_real_escape_string($Browser)',
                                       'mysqli_real_escape_string($OS)',
                                       'mysqli_real_escape_string($Time)')");
}

mysqli_close($Connection);
?>

If($IP)实际上是一个临时测试;那就是我要检查数据库中是否已经有IP的地方,如果可能的话,您可以带我去那里吗?

The If($IP) was actually a temporary test; that's where I'll be checking if an IP is already in the database, which if possible could you lead me on a track for that?

我很感谢所有反馈,无论是正面还是负面的反馈,都还是有帮助的.

I appreciate all feedback, whether negative or positive, it can still be helpful.

我将提供连接脚本,尽管这不应该是问题,因为会显示错误

I'm going to supply the connect script, although it shouldn't be the problem as an error would display

<?php
Define('Host', 'localhost');
Define('Username', 'username');
Define('Password', 'password');
Define('Database', 'database name');

$Connection = mysqli_connect(Host, Username, Password, Database);
?>

出于好奇,在进行研究时,我看到了一些有关使用SET而不是VALUES的信息.可能与此有关吗?

Out of curiosity, while researching I seen something about using SET instead of VALUES. Could that have anything to do with this?

推荐答案

如果要使用函数调用来构造字符串,则需要使用串联.

You need to use concatenation if you're going to use function calls to construct your string.

mysqli_query($Connection, "INSERT INTO tracker (ip, isp, referrer, browser, os, time)
                           VALUES ('".mysqli_real_escape_string($Connection,$IP)."',    
                                   '".mysqli_real_escape_string($Connection,$ISP)."',
                                   '".mysqli_real_escape_string($Connection,$Referrer)."',
                                   '".mysqli_real_escape_string($Connection,$Browser)."',
                                   '".mysqli_real_escape_string($Connection,$OS)."',
                                   '".mysqli_real_escape_string($Connection,$Time)."')");

这篇关于MySQLi查询未将数据提交到我的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆