AJAX and PHP

Building Responsive Web Applications

(version 0.1, May 02, 2006)

 

Dear reader,

Thank you for buying AJAX and PHP: Building Responsive Web Applications!

We hope you'll find this book helpful for your web development projects. For additional resources related to this book, visit the book's mini-site at http://ajaxphp.packtpub.com, or Cristian Darie's AJAX PHP resource page.

If you have any problems with the book, don't hesitate to contact Packt Publishing or the book's authors - we'll do our best to get back to you with a helpful answer!

Happy reading!

Cristian Darie

 

Code Download Release Notes

Please see Appendix A for environment preparation instructions. Let me know if you think I should include additional details here.

Errata

Chapter 1

The code for this quickstart example isn't bulletproof. Known problems are:

- escaping isn't perfect, try typing "yoda < cristian" and you'll see what I mean
- the code doesn't automatically use the best XMLHttpRequest version available, or the native Internet Explorer 7 object (this is fixed in the following chapters using a bit more complex instantiation sequence)

Chapter 2

No errata has been recorded yet.

Chapter 3

No errata has been recordedyet.

Chapter 4

No errata has been recorded yet.

Chapter 5

The ideal way to make sure all characters get correctly transferred from the server to the client is by using the htmlspecialchars function to prepare the fields, and enclose them into CDATA sections. Make this change in chat.class.php:

public function retrieveNewMessages($id=0)
{
  ...
  ...
  // loop through all the fetched messages to build the result message
  while ($row = $result->fetch_array(MYSQLI_ASSOC))
  {
    $id = $row['chat_id'];
    $color = htmlspecialchars ($row['color']);
    $userName = htmlspecialchars ($row['user_name']);
    $time = htmlspecialchars \\\\\\\($row['posted_on'])
    $message = htmlspecialchars ($row['message']);
    $response .= '<id>' . $id . '</id>' . 
                 '<color><![CDATA[' . $color . ']]></color>' . 
                 '<time>' . $time . '</time>' .
                 '<name><![CDATA[' . $userName . ']]></name>' .
                 '<message><![CDATA[' . $message . ']]></message>';
  }
  ...
  ... 
}

 

(the time doesn't need to be enclosed in CDATA tags because it's generated on the server and we don't expect it to receive bad values)

Chapter 6

No errata has been recorded yet.

Chapter 7

No errata has been recorded yet.

Chapter 8

No errata has been recorded yet.

Chapter 9

No errata has been recorded yet.

Chapter 10

No errata has been recorded yet.

Appendix A

No errata has been recorded yet.