douwen3836 2012-03-29 20:52
浏览 44
已采纳

表单不会使用PHP将文件上传到文本上传到SQL表

I want to get this image uploading script right, but for whatever reason it doesn't like the description input. It was working perfectly before I added the description input and I can't think of what might be wrong because it looks fine. My code doesn't like the description input in the form, what is wrong? Thanks for the help!

HTML Form

<h1>Image Gallery</h1>  
 <form enctype="multipart/form-data" action="upload.php" method="POST">
 Please choose a file: <input name="uploaded" type="file" /><br />
 Description: <textarea maxlength="255" name="description" id="description"></textarea><br />
 <input type="submit" value="Upload" />
</form> 

PHP Code (There is code before this but it doesn't matter)

$userid = mysql_real_escape_string($_SESSION['UserID']);  
$imageid = mysql_real_escape_string($i);  
$image = mysql_real_escape_string($rename); 
$description = mysql_real_escape_string($_POST['description']); 
$registerquery = mysql_query("INSERT INTO imageupload (UserID, ImageID, Image, Description) VALUES('".$userid."', '".$imageid."', '".$image."', '".$description."')");  
 if($registerquery) {  
  header( 'Location: manage.php' ) ;
 }  
 else {  
  echo "<h1>Error</h1>";  
  echo "<p>Sorry, an error occured. Please go back and try again.</p>";  
 }   
  • 写回答

4条回答 默认 最新

  • dsfphczao23473056 2012-03-29 20:58
    关注

    What datatype is the column for description?

    Replace your current query with:

    $description = mysql_real_escape_string(strip_tags(stripslashes($_POST['description']))); 
    $register = "INSERT INTO imageupload (UserID, ImageID, Image, Description) VALUES('$userid', '$imageid', '$image', '$description')";
    
    $registerquery = mysql_query($register) or die (mysql_error()); 
    
    
     if($registerquery) {  
      header( 'Location: manage.php' ) ;
     }  
    
     else {  
      echo "<h1>Error</h1>";  
      echo "<p>Sorry, an error occured. Please go back and try again.</p>";  
     }   
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度