BIGB185 Posted October 18, 2019 Share Posted October 18, 2019 (edited) I'm working on the following assignment and keep coming up with error messages. "Warning: require(mysqli_connect_registrar.php): failed to open stream: No such file or directory in /home/students/r/b.richards/public_html/cis231/labs/sectionresults.php on line 3 Fatal error: require(): Failed opening required 'mysqli_connect_registrar.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/students/r/b.richards/public_html/cis231/labs/sectionresults.php on line 3" I've included the code I have and any help would be appreciated. Thank you. Assignment Directions: Introduction This lab will demonstrate how to create a dynamic form that is created from database contents. And then that form will be used to pull results from the database, based on the user's selection. STEP 1 - Create the Database Connection File In your labs directory, define a mysql_connect.php file for the registrar database (with the student | student credentials). STEP 2 - Create the Form Define the form as sectionsearch.php. Create a dynamic form with a drop-down menu listing available courses by title. (Note: the courseID will be the value that is posted to the results page.) Step 3 - Create the Results page Define the results page as sectionresults.php. Present the results of the query for sections (unless there are none—then show an appropriate message). If there are results, use an HTML table (dynamically-generated) to display available sections with the following information: Faculty last name Room number Class meeting day(s) Start time End time The information should be sorted by the faculty member's last name. Note: You will need to consult the structure of the database tables to determine which fields need to be drawn from which tables and how to join the appropriate tables needed for the query. Sectionsearch.php code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Section Search</title> </head> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Search for Courses</title> <link href="cis231.css" rel="stylesheet" type="text/css"> </head> <body> <form id="form1" name="form1" method="post" action="sectionresults.php"> <h1>Search for courses</h1> <p>Courses <select name="courseID" id="courseID"> <option value="100">Java for Dummies</option> <option value="101">Advanced Web Servers </option> <option value="102">Empire Management</option> <option value="103">Stone Age History </option> <option value="104">The Presidency</option> <option value="105">Evolutionary Theory</option> <option value="106">Global Warming</option> <option value="107">Philosophy of Humor</option> <option value="108">American History</option> <option value="109">Horror Tales</option> <option value="110">Introduction to the Internet</option> <option value="111">Principles of Information Systems</option> <option value="112">Contemporary American Poetry</option> <option value="113">Introduction to Spanish</option> <option value="114">Business Spanish</option> <option value="115">Business Math 2</option> <option value="116">Italian Literature</option> <option value="117">Italian Literature</option> <option value="118">Italian Literature</option> <option value="119">Quantum Physics</option> <option value="120">Business Ethics</option> <option value="121">Introduction to Sociology </option> <option value="122">Redundancy 101</option> </select> </p> <p> <input type="submit" name="submit" id="submit" value="Search for courses"> <input type="reset" name="reset" id="reset" value="Restart Search"> </p> </form> </body> </html> mysql_connect.php code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Lab 7</title> </head> <?php //Set database connection information define('DB_HOST', 'localhost'); //Or could be a different server define('DB_USER', 'username'); //MySQL credentials define('DB_PASSWORD', 'password'); //MySQL credentials define('DB_NAME', 'registrar'); //Specific database //Database connection $dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die('Connection error'); //Set the encoding mysqli_set_charset($dbc, 'utf8'); //Or whatever PHP script encoding and database collation you are using ?> <body> </body> </html> sectionresults.php code: <?php //Connect to the database require('mysqli_connect_registrar.php'); $cat = ""; if (isset($_POST['courseID'])) { $cat = $_POST['courseID']; $q = "SELECT lastame, FROM faculty WHERE registrar = $cat ORDER BY lastname ASC"; $r = @mysqli_query($dbc, $q); $numRows = mysqli_num_rows($r); } ?> !doctype html> <html> <head> <meta charset="utf-8"> <title>Search Results</title> </head> <body> <?php if ($cat == "") //No posted data { ?> <h2 class="centered">No class selected.</h2> <p class="centered">Please return to make a <a href="sectionsearch.php">class selection</a>.</p> <?php } elseif ($numRows == 0) //No classes according to category selection { ?> <h2 class="centered">No classes in your category.</h2> <p class="centered">Please return to make a different <a href="sectionsearch.php">class selection</a>.</p> <?php //Free recordset mysqli_free_result($r); } else //There are results { ?> <div class="centered"> <table border="1"> <thead> <tr> <th>Last Name</th> <th>Room Number</th> <th>Meeting Days</th> <th>Class Start Time</th> <th>Class End Time</th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($r)) { ?> <tr> <td><?php echo $row['lastname']; ?></td> <td><?php echo $row['room_num']; ?></td> <td><?php echo $row['days']; ?></td> <td><?php echo $row[starttime]; ?></td> <td><?php echo $row[endtime]; ?></td> </tr> <?php } //Free recordset mysqli_free_result($r); ?> </tbody> </table> <?php } ?> </body> </html> Edited October 18, 2019 by BIGB185 Quote Link to comment Share on other sites More sharing options...
Barand Posted October 18, 2019 Share Posted October 18, 2019 (edited) 1 hour ago, BIGB185 said: mysql_connect.php code: 1 hour ago, BIGB185 said: require('mysqli_connect_registrar.php'); Are you sure you know the name of the file? (Use the code <> button in the toolbar when posting code) EDIT: Stop using "@" to suppress errors - you want to know when things have gone wrong Edited October 18, 2019 by Barand Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.