MySQL Forums
Forum List  »  PHP

Posted by: Rimma Bogdanova
Date: October 05, 2018 10:16AM

The first code selects the database of publications and I see in the browser "Default database is publications".
The following code must to select of data from table classics - the author column and show it to the browser. But the code does not output column authot to the browser. How to fix the situation? I have php7.2.7 with the php_pdo_mysql.dll.
What I'm doing wrong?

$mysqli = new mysqli('', 'nativeuser', '123', 'publications');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
if ($result = $mysqli->query("SELECT DATABASE()")) {
$row = $result->fetch_row();
if ($result = $mysqli->query("SELECT DATABASE()")) {
$row = $result->fetch_row();
printf("Default database is %s.\n", $row[0]);
function getclassics($conn) {
$sql = 'SELECT author FROM classics';
foreach ($conn->query($sql) as $row) {
print $row['author'] . "\t"; }}

Options: ReplyQuote

Written By
October 05, 2018 10:16AM
October 05, 2018 11:59AM
October 06, 2018 02:24AM
October 06, 2018 08:49AM
October 06, 2018 12:27PM
October 06, 2018 02:01PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.