<?php$link = mysqli_connect("hostname", "username", "password");if(!$link){ $error = ?????? die("Could not connect to the database: $error");}?>
<?php$query = "INSERT INTO mytable (myinteger, mydouble, myblob, myvarchar) VALUES (?, ?, ?, ?)";$statement = mysqli_prepare($link, $query);if(!$statement){ die(mysqli_error($link));}/* The variables being bound to by MySQLi don't need to exist prior to binding */mysqli_bind_param($statement, "idbs", $myinteger, $mydouble, $myblob, $myvarchar);/* ???????????? */ /* execute the query, using the variables as defined. */if(!mysqli_execute($statement)){ die(mysqli_error($link));}?>
<?php$query = "SELECT first, last, phone FROM contacts WHERE first LIKE 'John%'";$statement = mysqli_prepare($link, $query);mysqli_execute($statement);/* ???? */while(($result = mysqli_stmt_fetch($statement))){ print "Name: $first $last\n"; print "Phone: $phone\n\n";}?>