Home arrow Web Standards arrow Page 3 - Configuring Servers and Databases with Chrome

Configuring Servers and Databases with Chrome

In this second part of a four-part article that explains how to prepare XUL Internet applications for a commercial setting, you'll learn how to configure servers and build a database. This article is excerpted from chapter four of Programming Firefox, written by Kenneth C. Feldt (O'Reilly, 2007; ISBN: 0596102437). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
June 12, 2008
  1. · Configuring Servers and Databases with Chrome
  2. · The server-side response
  3. · When Things Go Wrong
  4. · Adding a Database
  5. · Creating account tables

print this article

Configuring Servers and Databases with Chrome - When Things Go Wrong
(Page 3 of 5 )

If things don’t work out, we can take a few steps to quickly isolate the cause of the problem. We can use either JavaScript alert or dump commands to see what we are sending and what we are retrieving. We can also use simplified PHP scripts to return a known value to make certain the script is doing what we think.

Assuming we want todump information to the screen, we could make the following changes to thedoServerRequestfunction in our newssearch.js code:

  theServerRequest.onreadystatechange = retrieveServerResponse;
dump("About to send " + theString + "\n");

And we could report the entire string returned in ourretrieveServerResponsefunction:

  if (theServerRequest.status == 200) { // request terminated OK
dump("Received from server: " + theServerRequest.responseText + "\n");
     if (theServerRequest.responseText == "true") { // all OK

We can also stub out our login check in doCommand.php just to return the parameters we received from the client:

  /* echo check_user($uName,$uPass); */
  echo 'Script has received: '."$cmd".','."$uName".','."$uPass";

We have removed the call to check_user in favor of a change to echo a string that concatenates (using the . operator in PHP) a simple message with the values for command, username, and password.

When we launch Firefox from the command line with the–consoleoption, we will see our sent and retrieved strings displayed on the console:

  About to send http://localhost/doCommand.php?&command=
  Received from server: Script has received: login,SomeUser,SomePass

For developers just beginning to work with PHP, includingechostatements to use the browser to display variable values is often the best way to identify many of the most common PHP coding errors. Displaying variable values is one sure way to quickly identify problems related to misuse of the single quote (used to form strings with special characters), double quote (used to assemble strings that include the
evaluation of variables), and terminating semicolons. Echoing variables is also a good tool to find misspelled variable names and the occasionally misplaced$variable prefix.

We change our command parser to remove thedebug echostatement and uncomment the call tocheck_userthat will now be used with a database of valid user identifiers.

blog comments powered by Disqus

- Mozilla Popcorn Maker 1.0 Makes Videos More...
- Completing a Configuration for Chrome and a ...
- Getting Connected with Firefox and Chrome
- Configuring Servers and Databases with Chrome
- Configuring Firefox for Chrome and a Server
- Designing the Elements of a Web Page
- Matching div heights with CSS and JavaScript
- Forms
- Get Down With Markup
- If I Said You Had a Beautiful Body...
- Web Standards in Dreamweaver Part 3
- Web Standards in Dreamweaver, Part 2
- Web Forms
- Making Lists Using XHTML
- Web Standards in Dreamweaver, Part 1

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials