$error = mysqli_connect_error();
$errno = mysqli_connect_errno();
print "$errno: $error\n";
exit();
}
$query = "SELECT Name, Population, Continent FROM Country WHERE Continent=? ORDER BY Name LIMIT 1";
$stmt = mysqli_stmt_init($link);
if(!mysqli_stmt_prepare($stmt, $query))
{
print "Failed to prepare statement\n";
}
else
{
mysqli_stmt_bind_param($stmt, "s", $continent);
$continent_array = array('Europe','Africa','Asia','North America');
foreach($continent_array as $continent)
{
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_array($result, MYSQLI_NUM))
{
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($link);
?>
The above examples will output:
Albania 3401200 Europe
Algeria 31471000 Africa
Afghanistan 22720000 Asia
Anguilla 8000 North America
See Also
mysqli_prepare
mysqli_stmt_result_metadata
mysqli_stmt_fetch
mysqli_fetch_array
mysqli_stmt_store_result
20.7.3.10.16. mysqli_stmt::get_warnings,
Copyright 1997-2012 the PHP Documentation Group. [2230]
•
mysqli_stmt::get_warnings
mysqli_stmt_get_warnings
Get result of SHOW WARNINGS
Description
MySQL Improved Extension (Mysqli)
foreach ($row as $r)
{
print "$r ";
}
print "\n";
mysqli_stmt_get_warnings
2460
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers