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

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条回答 默认 最新

相关推荐 更多相似问题