SQL查询可在测试服务器上运行,但不能实时运行...可能有什么区别? [英] SQL query works on testing server but not live... what could be the difference?

查看:77
本文介绍了SQL查询可在测试服务器上运行,但不能实时运行...可能有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已解决: 我在本地服务器上编写并测试了PHP脚本. (没什么花样,在同一数据库中只有2个连续的SQL插入,但是在不同的表中).

SOLVED: I wrote and tested a PHP script on the local server. (Nothing fancy, just 2 consecutive SQL inserts in the same database, but different tables).

两台服务器均运行PHP5& MYSQL 5.

Both servers run PHP5 & MYSQL 5.

在本地服务器上,两个查询均已正确处理.

On the local server, both queries are processed correctly.

在实时服务器上,仅第一个查询有效,但第二个查询无效,我不知道为什么.

On the live server, only the first query works, but not the second and I can't figure out why.

这是代码:

    $sql_login = "INSERT INTO logintbl 
              (...) 
           VALUES (...)";
   $result_login = mysqli_query($this->connect, $sql_login);

   # Fill contact details
   $sql_contactD = "INSERT INTO contactDetails
                    (...)
         VALUES (...)";
   $result_contactD = mysqli_query($this->connect, $sql_contactD);

在我的本地服务器上,两个查询都返回true,并将数据添加到数据库中.

On my local server, both queries return true and the data are added in the database.

在我的实时服务器上,第一个查询可以正常工作,但是第二个查询失败,没有任何错误消息.

On my live server, the first query works as expected, but the second query fails without any error message.

当然,两台服务器上的表结构相同.这两个表都在同一个数据库中,并且用户对该数据库具有足够的权限.

Of course, the table structures are identical on both servers. Both tables are in the same database and the user has sufficient rights on the database.

关于可能出什么问题的任何线索吗?

Any clue on what could be wrong?

权限:是的,用户对两个表都具有足够的权限.

Edit 1: Permissions: Yes, the user has adequate permissions on both tables.

我感觉很愚蠢,但是在James建议检查mysqli_error()的建议下,我发现生产服务器在表名方面区分大小写,这与我的测试服务器不同,并且它转换了原始服务器.我的表格名称(contactDetails)改成小写(contactdetails).

Edit 2: I am feeling very silly, but following James' advice of checking mysqli_error(), I found out that the production server was case sensitive in regards to table names, unlike my testing server, AND that it converted the original name of my table (contactDetails) to lowercase (contactdetails).

感谢大家的帮助.

推荐答案

回答我自己的问题,因为它似乎是正确关闭它的唯一方法:

Answering my own question because it looks like the only way to close it properly:

我感觉很傻,但是跟随 詹姆斯的检查建议 mysqli_error(),我发现 生产服务器区分大小写 关于表名,不像我 测试服务器,并将其转换为 我桌子的原名 (contactDetails)小写 (contactdetails).

I am feeling very silly, but following James' advice of checking mysqli_error(), I found out that the production server was case sensitive in regards to table names, unlike my testing server, AND that it converted the original name of my table (contactDetails) to lowercase (contactdetails).

这篇关于SQL查询可在测试服务器上运行,但不能实时运行...可能有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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