<?php
$mysqli = mysqli_connect("hostname", "user", "pass", "database");
if(mysqli_connect_errno()) {
die("Could not connect: ".mysqli_connect_error());
}
/*
CREATE TABLE books(name VARCHAR(255),
isbn VARCHAR(10),
price FLOAT)
*/
$bookname = "PHP";
$bookisbn = "11111111111";
$bookprice = 49.95;
$stmt = mysqli_prepare($mysqli, "INSERT INTO books VALUES(?, ?, ?)");
mysqli_bind_param($stmt, "ssd", $bookname, $bookisbn, $bookprice);
mysqli_execute($stmt);
mysqli_stmt_close($stmt);
mysqli_close($mysqli);
?>
|