<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s\n", maxdb_connect_error());
exit();
}
$city = "Rosemont";
/* create a prepared statement */
if ($stmt = maxdb_prepare($link, "SELECT state FROM hotel.city WHERE name=?")) {
/* bind parameters for markers */
maxdb_stmt_bind_param($stmt, "s", $city);
/* execute query */
maxdb_stmt_execute($stmt);
/* bind result variables */
maxdb_stmt_bind_result($stmt, $district);
/* fetch value */
maxdb_stmt_fetch($stmt);
printf("%s is in district %s\n", $city, $district);
/* close statement */
maxdb_stmt_close($stmt);
}
/* close connection */
maxdb_close($link);
?>