Can someone help me with this PHP code please. I am getting this error : Warning
ID: 3859429 • Letter: C
Question
Can someone help me with this PHP code please. I am getting this error : Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C: mpphtdocshello.php on line 38
The PHP code is :
<?php
session_start();
if($_GET){
$author = $_GET['author'];
$title = $_GET['title'];
$select = $_GET['select'];
$con= mysqli_connect("localhost", "root","password", "mysql");
if($con)
{
mysqli_select_db($connect, "mysql");
$query = $db->real_query("SELECT * FROM bookstore WHERE author='" . $author . "' or Title='" . $title . "' ");
$query2 =$db->real_query( "SELECT * FROM bookstore WHERE Year = '" . $select ."' ");
$result = mysqli_query($connect, $query);
$result2 = mysqli_query($connect, $query2);
while($row = mysqli_fetch_array($result)){
echo $row['ISBN'] . "<br/>" . $row['Title'] . "<br/>" . $row['Author'] . "<br/>" . $row['Publisher'] . "<br/>" . $row['Year'] . "<br/>";
}
while($row2 = mysqli_fetch_array($result2)){
echo $row2['ISBN'] . "<br/>" . $row2['Title'] . "<br/>" . $row2['Author'] . "<br/>" . $row2['Publisher'] . "<br/>" . $row2['Year'] . "<br/>";
}
} else {
die(mysqli_connect_errno());
}
mysqli_free_result($result);
mysqli_close($connect);
}
?>
Explanation / Answer
Answer:
In the init file make the below change and run the program , here we are instead of again setting the root password, we are going to insert a record into the mysql.user table
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.