Jump to content
Larry Ullman's Book Forums

Getting Started: Chapter 2


Recommended Posts

I am trying to print the employees as a way of verifying my setup including Apache, phpMyAdmin, MySQL, etc.

I downloaded the code from the website and reviewed the errata sheet for any errors.

I used phpMyAdmin (5.2.17) to set up the database, load the data using the scripts downloaded from the website, etc, so I feel this part of the effort is satisfactory. Set up user and password and changed mysql.inc.php (pg 18) accordingly.

The only difference is, because IIS and Wamp Server is on my computer (I will uninstall these products today.). I have been starting phpMyadmin with "http://localhost:8080/phpmyadmin/ because of these other products. I have changed 'config.inc.php' to reflect 'localhost:8080'. So I feel that I have done the setup sucessfully.

I use Aptana Studio 3 as my editor and Xampp 1.7.7 to start MySQL 5.1 and phpMyAdmin.

When I execute 'dept_form.html' from Aptana using either Firefox or IE8 browers, the initial screen appears, etc. Once I hit 'Submit" the following message appears across the screen:

 

Department Employees

 

"0) { // Get the employees from the database... // Include the database connection script: require_once('mysql.inc.php'); // Query the database: $q = "SELECT * FROM employees WHERE department_id=$did ORDER BY last_name, first_name"; $r = mysql_query($q, $dbc); // Check that some results were returned: if (mysql_num_rows($r) > 0) { // Retrieve the results: while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) { echo "

{$row['last_name']}, {$row['first_name']}

Email: {$row['email']}

Phone Extension: {$row['phone_ext']}

\n"; } // End of WHILE loop. } else { // No employees. echo '

There are no employees listed for the given department.

'; } mysql_close($dbc); } else { // Invalid department ID! echo '

Please select a valid department from the drop-down menu in order to view its employees.

'; } ?>"

 

Which is the code from 'dept_results.php' line 11 (approx) after 'if (mysql_num_rows($r) ....".

 

Any suggestions? Thx John

Link to comment
Share on other sites

That's because you're not loading the HTML form through a URL, which means you're not running the PHP script through a URL, so the PHP code is not being executed.

 

To be clear, the book does assume basic comfort with PHP and MySQL.

Link to comment
Share on other sites

  • 2 weeks later...
 Share

×
×
  • Create New...