Jump to content


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About BIGB185

  • Rank
  1. 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>
  2. Thank you, benanamen. I have no idea why I didn't see that. lol
  3. I'm having an issue with a small bit of code I'm writing for a class. Below is the code I have and at line 30, dreamweaver gives me the error "syntax error, unexpected $end" <!DOCTYPE html> <html lang="en-US"> <head> <title>Homework 2 - Simple PHP page</title> </head> <body> <?php if($_POST['firstName'] == NULL || $_POST['quantity'] == NULL || $_POST['gender'] == NULL || $_POST['sport'] == NULL) { echo "<h1>Please return to the form and fill out completely</h1>"; } else { ?> <?php echo "<h2>Welcome ".$_POST["firstName"]."</h2>"; if($_POST['gender']=='male' &$_POST['sport']=='gymnastics') { echo " Real men don't like gymnastics!<br/>"; } else if($_POST['gender']=='female' &$_POST['sport']=='football') { echo "Women are too delicate for a rough sport like football!<br/>"; } $cost = $_POST['quantity'] * 4.95 * 1.08 + 5.99; ?> *LINE 30* <p>You have ordered <?php echo $_POST['quantity'] . " " . $_POST['sport'] . " mugs at a cost of $" . number_format($cost, 2); ?>. Thank you.</p> <p> } </body> </html> I can't seem to figure out what I've done wrong, any help would be appreciated, thank you.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.