PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
echo $Deviation_ID; //FOR TEST PURPOSE
if ($stmt = $mysqli->prepare("SELECT Logfile FROM Deviation_Update_History WHERE ID = ?")) {
$stmt->bind_param('i', $Deviation_ID);
$stmt->execute();
$stmt->bind_result($Logfile);
$stmt->store_result();
$stmt->fetch();
if (mysqli_num_rows($result) > 0) {
$Logfile="1"; //Just for test
if ($stmt = $mysqli->prepare("UPDATE Logfile SET Deviation_Update_History WHERE ID = ?")) {
$stmt->bind_param('is', $Deviation_ID, $Logfile);
$stmt->execute();
$stmt->close();
} else { //If doesnt exist
$Logfile="2"; //Just for test
if ($stmt = $mysqli->prepare("INSERT INTO Logfile(Dev_ID, Logfile) VALUES (?) WHERE ID = ?")) {
$stmt->bind_param('is', $Deviation_ID, $Logfile);
$stmt->execute();
$stmt->close();
}
}
}
}
I been staring at this for several minutes but can't find what I'm missing.
Yeah I mean't to use $stmt->num_rows but it still doesn't work..
It wont update or write anything to the database.. it just print the dev ID (first line) and then skips the rest and move on.. I don't even get any error msg?
Well I'm late to pick up the kid. I'll take a closer look at this tomorrow.. Thanks anyway
echo $Deviation_ID; //FOR TEST PURPOSE
$stmt = $mysqli->prepare("SELECT Logfile FROM Deviation_Update_History WHERE ID = ?");
if ($mysqli->errno) {
echo "ERROR: {$mysqli->error}<br>";
} else {
if ($stmt) {
...
}
}
echo $Deviation_ID; //FOR TEST PURPOSE
if ($stmt = $mysqli->prepare("SELECT Logfile FROM Deviation_Update_History WHERE ID = ?")) {
$stmt->bind_param('i', $Deviation_ID);
$stmt->execute();
$stmt->bind_result($Logfile);
$stmt->store_result();
$stmt->fetch();
if (mysqli_num_rows($result) > 0) {
$Logfile="1"; //Just for test
if ($stmt = $mysqli->prepare("UPDATE Logfile SET Deviation_Update_History WHERE ID = ?")) {
$stmt->bind_param('is', $Deviation_ID, $Logfile);
$stmt->execute();
$stmt->close();
} else { //If doesnt exist
$Logfile="2"; //Just for test
if ($stmt = $mysqli->prepare("INSERT INTO Logfile(Dev_ID, Logfile) VALUES (?) WHERE ID = ?")) {
$stmt->bind_param('is', $Deviation_ID, $Logfile);
$stmt->execute();
$stmt->close();
}
}
}
}