2014-02-25 27 views
0

我有這2個PHP文件,我不知道爲什麼,但我得到了一個錯誤:指數沒有找到

SCREAM: Error suppression ignored for (!) Notice: Undefined index: content in D:\wamp\www\admin\add-script.php on line 11

這是附加的script.php

<?php 
    $con = mysqli_connect($host,$user,$password) or trigger_error("SQL", E_USER_ERROR); 
    $db = mysqli_select_db($con,$db) or trigger_error("SQL", E_USER_ERROR); 

    if (isset($_POST['send'])) { 
     $title = $_POST['title']; 
     $category = $_POST['category']; 
     $tags = $_POST['tags']; 
     $image = $_POST['image']; 
     $content = $_POST['content']; 
     $time = time(); 
     $sql = "INSERT INTO articles (article_id, article_title, article_content, article_timestamp, article_tags, article_image, article_category) VALUES ('', '$title','$content','$time','$tags','$image','$category')"; 

     if (!mysqli_query($con,$sql)) 
     { 
      die('Error: ' . mysqli_error($con)); 
     } 

     ('Location: index.php'); 
     mysqli_close($con); 
    } 
?> 

這是add.php

<?php 
    session_start(); 

    if (isset($_SESSION['logged_in'])) { 
     include_once ("header.php"); 
     include_once ("add-script.php"); 
?> 
    <tr> 
     <td> 
      <form method="post" id="add" name="add" > 
       <div id="left-col"> 
        <h1>Add Article</h1> 
        <input type="text" name="title" placeholder="Title" /> 
        <textarea name="content" rows="30" id="markItUp content" cols="106" placeholder="Content"> </textarea> 
        <input type="text" name="tags" placeholder="Tags" /> 
        <input type="text" name="image" placeholder="Image Name" /> 
       </div> 
       <div id="right-col"> 
        <?php 
         $result = mysql_query("SELECT * FROM category"); 
         while($list = mysql_fetch_assoc($result)){ 
        ?> 
        <input type="radio" name = "category" value = "<?php echo $list['category_id']; ?>"> 
        <label><?php echo $list['category_name']; ?></label> 
        <?php 
         } 
        ?> 
        <input type="submit" name="send" value="Send!" style="margin-bottom:0px;"/> 
       </div> 
      </form> 
     </td> 
<?php  
    include_once ("footer.php"); 
    } 
    else { 
     header('Location: index.php'); 
    } 
?> 
+0

開始通過確保您的HTML是有效的:'DIV ID =「右山坳」>' – Madbreaks

+0

對不起......現在到PHP的東西......爲什麼我得到這個錯誤? – user3128955

+1

您的查詢全面開放SQL注入。你應該使用準備好的語句。 – Mike

回答

0

首先,你不能使用空格像元素的ID值:id="markItUp content" 更改您的ID:s到不帶空格的小寫字母:id="markitup_content"

你的錯誤,告訴有一個在您的文章參數指標「內容」沒有價值:

$content = $_POST['content']; 
+0

我用這樣的id,這樣我就可以將2個id分配給那個 – user3128955

+0

,我不知道它爲什麼會發生這種情況 – user3128955

+0

WTF ..你不能在html中使用兩個id:s ..你爲什麼還要需要嗎?我放棄,如果你的知識是這樣的水平.. – Hardy