httpd/integration/php-mariadb/mysql.php
2021-02-17 15:26:45 +01:00

19 lines
645 B
PHP

<?php
$mysqli = new mysqli('localhost', 'tester', '', 'php_mysql_test');
if ($mysqli->connect_errno) {
echo "Error: Failed to make a MySQL connection, here is why: \n";
echo "Errno: " . $mysqli->connect_errno . "\n";
echo "Error: " . $mysqli->connect_error . "\n";
exit;
}
$sql = "SELECT * from foobar";
if (!$result = $mysqli->query($sql)) {
echo "Error: Our query failed to execute and here is why: \n";
echo "Query: " . $sql . "\n";
echo "Errno: " . $mysqli->errno . "\n";
echo "Error: " . $mysqli->error . "\n";
exit;
}
$row = $result->fetch_assoc();
printf("%s is %d\n", $row['name'], $row['value']);
?>