<?php session_start();
$conn = new mysqli("localhost", "****", "****", "root_project");
if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }
$_SESSION['a'] = $conn->real_escape_string($_SESSION['a']);
$sql="UPDATE loantrans SET bookeep = 'y' WHERE loanID ='".$_SESSION['a']."'";
if ($conn->query($sql)) {
$message = "The form was sent successfully.";
echo "<script type='text/javascript'>alert('$message');</script>";
} else {
$err= "Error: " . $sql . "<br>" . $conn->error;
$err2= "There was a problem with sending the form."."<br>".
"Please contact us"."<br>"."<br>".$err;
echo "<script type='text/javascript'>alert('$err2');</script>";
}
$conn->close(); ?>
Я все еще готов помочь тебе. Предполагая, что вы начинаете с нуля …:
$conn = new mysqli("localhost", "username", "some_password", "database");
if ($conn->connect_error)
die("Connection failed: ".$conn->connect_error);
$_SESSION['a'] = $conn->real_escape_string($_SESSION['a']);
$sql = "UPDATE loantrans SET bookeep = 'y' WHERE loanID = '".$_SESSION['a']."' AND bookeep = 'n'";
if ($conn->query($sql))
echo "Record updated successfully";
else
echo "Error updating record: " . $conn->error;
$conn->close();
Но остерегайтесь Инъекции SQL. Я думаю, что я избежал специальных строк прямо сейчас. Удачи.
Других решений пока нет …