Ich bin ein Anfänger und auch ein Diplom-Student ... Ich versuche, meine MySQL-Datenbank zu aktualisieren und ich habe Fehler ... Bitte helfen Sie mir ... Dies ist der Fehler:Ich versuche, meine MySQL-Datenbank zu aktualisieren
Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\SLR\Update S110 PC01.php on line 24
Could not Update data:
Dies ist mein Code:
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="slr"; // Database name
$tbl_name="s110_pc01"; // Table name
// Connect to server and select database.
$link = mysqli_connect("$host", "$username", "$password")or die("cannot connect");
mysqli_select_db($link, $db_name)or die("cannot select DB");
// Get values from form
$soft_name=$_POST['soft_name'];
$installed_date=$_POST['installed_date'];
$expiry_date=$_POST['expiry_date'];
$product_key=$_POST['product_key'];
$sql = "UPDATE SET soft_name='$_POST[soft_name]', installed_date='$_POST[installed_date]', expiry_date='$_POST[expiry_date]', product_key='$_POST[product_key]' WHERE soft_id='$_POST[soft_id]'";
$result=mysqli_query($link,$sql);
if(! $result)
{
die('Could not Update data: ' . mysqli_error());
}
echo "Successfully updated\n";
mysqli_close($con);
?>
<input type="button"value="Finish"onclick="window.location.href='Update S110 PC01 Data.php'">
</form>
</table>
</div>
</body>
</html>
Sie aus falsch lernen Quelle. Ihr Code ist zu sehr anfällig für [SQL Injection] (https://en.wikipedia.org/wiki/SQL_injection). Versuchen Sie es mit [prepaerd statements] (http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) – bansi