<html > <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Girfa : My SQLi Insert Tutorial</title>
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "dbname";
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "dbname";
// Create connection
$mysqli = new mysqli($servername, $username, $password, $dbname);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* create a prepared statement */
$stmt = $mysqli->stmt_init();
if ($stmt->prepare("insert into stu (roll,name,city) values(?,?,?)")) {
/* bind parameters for markers */
$stmt->bind_param("iss", $r, $n, $c);
/* execute query */
$r = 101;
$n = "karishma";
$c = "kadipur";
$stmt->execute();
echo "Saved";
$stmt->close();
}
/* close connection */
$mysqli->close();
?>
</body>
</html>
Next Topic
No comments:
Post a Comment