O'Reilly Forums: Example 10-8 - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Example 10-8 Cannot get code to work

#1 User is offline   SkipWhite 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 22-April 11

Posted 22 April 2011 - 12:47 PM

My attached screen shot did not come through, so I'm repeating the post: Using your code I cannot get Example 10-8 to work - I am using Firefox 4 and a copy of the results is below

thanks - Skip

Result:
" . mysql_error() . "

"; } if (isset($_POST['author']) && isset($_POST['title']) && isset($_POST['category']) && isset($_POST['year']) && isset($_POST['isbn'])) { $author = get_post('author'); $title = get_post('title'); $category = get_post('category'); $year = get_post('year'); $isbn = get_post('isbn'); $query = "INSERT INTO classics VALUES" . "('$author', '$title', '$category', '$year', '$isbn')"; if (!mysql_query($query, $db_server)) echo "INSERT failed: $query
" . mysql_error() . "

"; } echo <<<_END

Author
Title
Category
Year
ISBN


_END; $query = "SELECT * FROM classics"; $result = mysql_query($query); if (!$result) die ("Database access failed: " . mysql_error()); $rows = mysql_num_rows($result); for ($j = 0 ; $j < $rows ; ++$j) { $row = mysql_fetch_row($result); echo <<<_END

Author $row[0]
Title $row[1]
Category $row[2]
Year $row[3]
ISBN $row[4]

_END; } mysql_close($db_server); function get_post($var) { return mysql_real_escape_string($_POST[$var]); } ?>
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users