مرحبا
ارجو مساعدتي في حل مشكلة الخطا في السطر 2 من ملف :add.php
يمكن تحميل الاكواد من هنا
هذا بيانات تكون جدول قاعدة البيانات phpmyadmin:
CREATE TABLE `news` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR( 99 ) NOT NULL , `text` VARCHAR( 255 ) NOT NULL , `catimage` VARCHAR( 99 ) NOT NULL , `path` VARCHAR( 99 ) NOT NULL ) ENGINE = MYISAM ;
والخطا في هذا الملف : add.php
<?php
IF ($action=="add"){
if ($_SERVER["REQUEST_METHOD"]=="POST")
{
$title = addslashes($_POST['title']);
$title = trim($_POST['title']);
$text = addslashes($_POST['message']);
$text = trim($text);
$file_name = $HTTP_POST_FILES['image']['name'];
$random_digit=rand(0000,9999);
$new_file_name=$random_digit.$file_name;
if ($title =="" || $text =="" || $file_name =="") {
echo "<BR><BR><BR><center><a href='javascript:history.back()'>One of the empty data</a><BR><BR><BR>";
}else{
include("config.php");
$path= "upload/".$new_file_name;
if($image !=none)
{
if(copy($HTTP_POST_FILES['image']['tmp_name'], $path))
{
$catimage = $new_file_name;
$query = @mysql_query ("INSERT INTO news (title,text,catimage,path) VALUES ('$title','$text','$catimage','$path')") or die ("error query");
if($query){
echo "<BR>";
echo "<CENTER><B>News has been added successfully";
echo "<META HTTP-EQUIV='Refresh' CONTENT='1;URL=news.php'>";
echo "<BR>";
}else{
echo "<BR>Sorry no information is entered into the table";
EXIT;
}
}
}
}
}
}else{
echo'<br>
<form method="POST" enctype="multipart/form-data" action="news.php?action=add" dir="rtl">
<div align="center">
<table border="1" cellspacing="1" width="450" dir="rtl" id="table1" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">
<tr>
<td class="bigfont" width="100" align="center"><span lang="ar-sa">
Title</span></td>
<td>
<input type="text" name="title" id="title" size="20">
</td>
</tr>
<tr>
<td class="bigfont" width="100" align="center"><span lang="ar-sa">
News</span></td>
<td>
<textarea rows="9" name="message" id="message" cols="29"></textarea></td>
</tr>
<tr>
<td class="bigfont" width="100" align="center">Image with the news</td>
<td>
<input type="file" name="image" id="image" size="20">
</td>
</tr>
</table>
</div>
<p align="center"><BR>
<?php
mysql_free_result($news);
?><title>add news</title>
<input type="submit" value="Send" name="B1">
<input type="reset" value="Clear" name="B2">
</p>
</form>';
}ارجو المساعدة