0

我正在做一个小项目,现在我面临保存问题。当我在文本编辑器上键入内容并单击保存按钮(用于保存在数据库中)时,它什么也不回复。

这是过程代码:

case "Publish":
    $fileName=$_FILES["image"]["name"];

        if($fileName)
        {
            $filePath="images/news_img/".$fileName;
            if(file_exists($filePath))
            {
                $a=gmdate("Yzhis");
                move_uploaded_file($_FILES["image"]["tmp_name"], "images/news_img/".$a.$_FILES["image"]["name"]);
                $fileName=$a.$_FILES["image"]["name"];

            }
            else
            {
                move_uploaded_file($_FILES["image"]["tmp_name"], "images/news_img/".$_FILES["image"]["name"]);

            }
        }
        if($arttitle=="" || $date=="" || $category=="" || $status=="" )
        {
            $_SESSION['error_msg']="You Must Fill All The Required fileds";
            $go="add_articles.php";
        }
        else
        {
        /*for username check*/
            $checksql=mysql_query("select * from articles where arttitle='$arttitle'");
            $checkdata=mysql_fetch_array($checksql);

            if($checkdata['arttitle']!=$arttitle)
            {
                $inssql=mysql_query("INSERT INTO articles VALUES(NULL,'$arttitle','$date','$category','$status','$fileName','$articale',0)");
            }
            else
            {
                $_SESSION['username_msg']="Articale Name Already Exists.";
            }
        }
        $go="add_articles.php";

    break;

    case"Edit":
    $updatesql=mysql_query("UPDATE articles SET 
arttitle='$arttitle',date='$date',category='$category',status='$status',articale='$articale' where aid = '$hiddenid'");
    $_SESSION['success_msg']="Update Successful!";
        $go="add_articles.php";
    break;
4

1 回答 1

0

改变

$checkdata=mysql_fetch_array($checksql);

$checkdata = mysql_fetch_array($checksql,MYSQL_BOTH);

您正在使用字段名称进行比较,因此您必须更改 fetch 数组

$checksql=mysql_query("select * from articles where arttitle='".$arttitle."'"); 


$inssql=mysql_query("INSERT INTO articles VALUES(NULL,'".$arttitle."','".$date."','".$category."','".$status."','".$fileName."','".$articale."',0)");
于 2012-11-07T12:01:55.153 回答