There are a couple questions I have regarding the following code:
// Create a new MySQL connection, inserting a host, username, passord, and database you connecting to
$conn = new mysqli('xxx', 'xxx', 'xxx',);
if(!$conn) {
die('Connection Failed: ' . $conn->error());
}
// Create and execute a MySQL query
$sql = "SELECT artist_name FROM artists";
$result = $conn->query($sql);
// Loop through the returned data and output it
while($row = $result->fetch_assoc()) {
printf(
"Artist: %s<br />", $row['artist_name'], "<br />",
"Profile: %s<br />", $row['artist_dob'], "<br />",
"Date of Birth: %s<br />", $row['artist_profile'], "<br />",
"Password: %s<br />", $row['artist_password'], "<br />"
);
}
// Free memory associated with the query
$result->close();
// Close connection
$conn->close();
How can I assign artist_dob
, artist_profile
, and artist_password
and return it to the browser?
What does the statement $conn->error()
mean? I don't understand what the ->
sign does.