657
بناء مشاريع PHP و MySQL عملية
الجزء V
26
$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
else {
}
set headline = '$headline',
story_text = '$story_text', page=$page',
modified = $time
where id= $story";
// 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) {
}
echo "There was a database error when executing <PRE>$sql</PRE>"; echo mysql_error();
exit;
if ($picture) && ($picture != "none") ) {
if (!$story)
$story =
mysql_insert_id();
$type = basename($picture_type);
switch ($type) {
case "jpeg":
case "pjpeg":
default:
}
}
$filename = "pictures/$story.jpg"; copy ($picture, $filename);
$sql = "update stories
set picture = '$filename'
where id= $story";
$result = mysql_query($sql, $conn);
break;
echo "Invalid picture format: $picture_type";
header("Location: $destination");
?>
ص٦٤١