dpiw16824 2017-04-23 10:32
浏览 102
已采纳

PHP mysqli语句execute()不起作用

I havn't found something equally on stackoverflow.com, so i post my question in the hope someone have an idea what's wrong with my code or something i'm using.

Before i begin: On my productive webspace the same code works, the problem is located at the xampp-installation for my local development-server... sigh

I have a little webapplication for my family and me to document the work at home (e.g. to empty the bin), so we can distribute money to our kids, depending on how much they done by themself (a little bonus to the pocket money they get without homework)

The code to insert a line into my db-table is:

function AddGarbEntry($DBConnection, $DBPrefix, $UserID, $GarbID)
{
    $stmt = $DBConnection->prepare("INSERT INTO t_".$DBPrefix."_entries (idUsers,idGarbType) VALUES (?,?)");
    $stmt->bind_param("ii", $UserID, $GarbID);
    $stmt->execute();
    $stmt->close();
}

The part of the script, where i call this function is:

$con = new mysqli($_SESSION["DBHost"], $_SESSION["DBUsername"], $_SESSION["DBPassword"], $_SESSION["Database"]);
AddGarbEntry($con, $DBPrefix, $_POST["user"], $_POST["garbagetype"]);
$con->close();

I've already checked the Session-Variables (They are all filled with the correct values), and the POST-Values (They are filled correct either).

In my MySQL-Log a can find the following lines:

170423 11:54:38    66 Connect   rldmla_1@localhost as anonymous on rldmla_db1
           66 Prepare   INSERT INTO t_garb_entries (idUsers,idGarbType) VALUES (? , ?)
           66 Close stmt    
           66 Quit  

So, i can see, that the prepare is working, but there is no sign, that my testserver runs the execute()-Command. The error-logs of php, apache and mysql have no entry about that.

Curiously, if i'm using a specific function of my website to update already existing lines (also prepared-statement, but an update-statement), my insert code works properly for about two times, after that it stop working until i update my table again.

I've tried the actual version of xampp (7.1.x) and the older version (7.0.15), but the problem is the same. Xampp is running as x86-version on a x64-running Windows Server 2012-Machine. I've only installed the modules Apache, PHP and MySQL.

I don't have any clue, what i'm doing wrong. Any help is appreciated.

Greetings, Ronny

  • 写回答

1条回答 默认 最新

  • doushai4890 2017-04-28 22:57
    关注

    Urks.... Now I've got the clue:

    I changed my Xampp-Installation to a linux based virtual machine, where i've installed Apache, PHP, MySQL and phpMyAdmin. After that the missing execute-line was in the MySql-Logfile.

    So, nothing to do here anymore.

    Thx @all for supporting me :)

    Greetings, Ronny

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事: