I'm using "PHP and MySQL Web Development" published by SAM's. I believe the story_submit.php file for the Content Mangement script in Chapter 26 has a syntax problem. I'm getting errors. I'm very new to MySQL & PHP and would appreciate some help. The form has a field for uploading an optional .html file. That's what $html represents. The $story variable is the story ID. If there is no story ID then it is a new story rather than a story to modified. Here's the code:
<?php // story_action.php // add / modify story record include "include_fns.php"; $conn = db_connect(); $time = time(); if ( ($html) && (dirname($html_type) == "text") ) { $fp = fopen($html, "r"); $story_text = addslashes(fread($fp, filesize($html))); fclose($fp); } if ($story) { // It's an update $sql = "update stories set headline = '$headline', story_text = '$story_text', page = '$page', modified = $time where id = $story"; } else { // It's a new story $sql = "insert into stories (headline, story_text, page, writer, created, modified) values ('$headline', '$story_text', '$page', '$auth_user', $time, $time)"; } $result = mysql_query($sql, $conn); if (!$result) { print "There was a database error when executing <PRE>$sql</PRE>"; print mysql_error(); exit; } if ( ($picture) && ($picture != "none") ) { if (!$story) $story = mysql_insert_id(); $type = basename($picture_type); switch ($type) { case "jpeg": case "pjpeg": $filename = "pictures/$story.jpg"; copy ($picture, $filename); $sql = "update stories set picture = '$filename' where id = $story"; $result = mysql_query($sql, $conn); break; default: print "Invalid picture format: $picture_type"; } } header("Location: $destination"); ?> Thanks, ~Steve Downs -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]