Question

MySQL 8 Create a PHP program that will read in each table of the database you...

MySQL 8

Create a PHP program that will read in each table of the database you created in Assignment 8 and display the values into a good looking table.

When I run it, I'm having this error " Parse error: syntax error, unexpected '$dbName' (T_VARIABLE) in C:\xampp\htdocs\assignment9\includes\dbh.inc.php on line 6'

Here is my index.php

<?php
   include_once 'includes/dbh.inc.php';
?>

<!DOCTYPE html>
<html>
<head>
   <title></title>
</head>
<body>

<?php
   $sql = "SELECT * FROM comic_book.books;";
   $result = mysqli_query($conn, $sql);
  
   if ($resultCheck > 0) {
       while ($row = mysqli_fetch_assoc($result)) {
           echo $row['book_name'] . "<br>";
       }
   }
?>
</body>
</html>

Here is my dbh.inc.php

<?php

$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "Password"
$dbName = "comic_book";

$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Error Description :

  • In  dbh.inc.php file on line $dbPassword = "Password" semicolon (;) is missing.
  • Also in the  index.php file in the line if ($resultCheck > 0) , $result is a variable replace resultCheck with $result.

Below is the corrected files.

dbh.inc.php :

<?php

$dbServername = "localhost";

$dbUsername = "root";

$dbPassword = "Password";

$dbName = "comic_book";

$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);

?>

*********************

index.php :

<?php

   include_once 'dbh.inc.php';

?>

<!DOCTYPE html>

<html>

<head>

   <title></title>

</head>

<body>

<?php

   $sql = "SELECT * FROM comic_book.books;";

   $result = mysqli_query($conn, $sql);

  

   if ($result > 0) {

       while ($row = mysqli_fetch_assoc($result)) {

           echo $row['book_name'] . "<br>";

       }

   }

?>

</body>

</html>

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
MySQL 8 Create a PHP program that will read in each table of the database you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • My 2nd Try asking the same "PHP Programming with MySQL question. When I run my code,...

    My 2nd Try asking the same "PHP Programming with MySQL question. When I run my code, I get the following messages: Notice: Undefined index: email in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 71 Notice: Undefined index: password in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 71 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 75 The e-mail address/password combination entered is not valid. Please use your browser's BACK button to return to the form and fix the errors indicated. Please use...

  • PHP Programming with MySQL - Why do I get the following error and how do I...

    PHP Programming with MySQL - Why do I get the following error and how do I connect to my database. Looks like I might need to use mysqli instead of mysql but I dont know how to do that or what to change. I appreciate it is you fixed anything that needs to be re-written. Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php:12 Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 12 Line 12: $DBConnect =...

  • Write a PHP script that obtains a URL and its description from user and stores the...

    Write a PHP script that obtains a URL and its description from user and stores the information into a database using MySQL. Create and run a SQL script with database named URL and a table named Urltable. The first field of the table should contain an actual URL, and the second, which is named Description, should contain a description of the URL. Use www.deitel.com as the first URL, and input Cool site! as its description. The second URL should be...

  • How can I connect the html forms to php --> mysql database <!DOCTYPE html> <html lang="en">...

    How can I connect the html forms to php --> mysql database <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h2> <center> Average: </h2> <h3> <center> Rate the following: </h2> <h3> <center> Rating Criteria: <br> Developing (0-5), Competent (6-10), Accomplished (10-15); </h3> <center> Judge Name: <input type="text" id="judge"> <br> <br> <center> 1. Articulate requirements and design of the project: <input type="text" id="num1"> <br> <br> 2. Plan the solution and implement the project: <input type="text" id="num2"> <br> <br> 3....

  • PHP Programming In this project, you will create a Web page that allows visitors to your...

    PHP Programming In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a database. Create a new document in your text editor and type the <!DOCTYPE> declaration, <html> element, document head, and <body> element. Use the strict DTD and “Guest Book” as the content of the <title> element. Add the following text and elements to the document body: <h2>Enter your name to sign our guest book</h2>...

  • <html> <!--This is the form for an instructor to upload a file having the grade of...

    <html> <!--This is the form for an instructor to upload a file having the grade of students in a class--> <body> <h2>Upload Student Grade</h2> <form action="1.php" method="POST" enctype="multipart/form-data">    Instructor's First Name:<input type="text" name="first"><br><br>    Instructor's Last Name: <input type="text" name="last"><br><br>      Instructor's Department Name:<input type="text" name="department"><br><br>          Upload student grade: <input type="file" name="image" /><br><br> <input type="submit"/> </form>    </body> </html> //***************************************************Q1****************************************************************************      /*(((( Q1)))). (18 points) Add the code below that *   uploads the file containing the students'...

  • LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but,...

    LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but, I keep getting an error that I coded "Wrong username and password!" ***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY ISSUES login.html <!DOCTYPE html> <html> <head> <title>login popup</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> body { background-color: white; } </style> </head> <body> <center> <h1 style="text-align: center;"> Login </h1> <form>             Login ID:...

  • This is a website picture The html and css code is as follow And my problem is as follow use the php and mysql Northwind Customer Database Search List Records All Records CustomerName v CustomerName...

    This is a website picture The html and css code is as follow And my problem is as follow use the php and mysql Northwind Customer Database Search List Records All Records CustomerName v CustomerName ContactName Address City PostalCode Search O ASC DESC List All Records Insert Record Country List City CustomerName ContactName Address City PostalCode Country List City Find by IID Find Insert 1 <! DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http:L 3-<head> 4 Kmeta http-equiv-"Content-Type" content-"text/html; charset-utf-8" />...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT