Jump to content

Upload and add to db error query is empy


jesushax

Recommended Posts

hi below is my code

 

<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_header.php');

switch(@$_GET["action"]) {
Case "insert":

$path1= $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/".$HTTP_POST_FILES['ufile']['name'][1];
$path3= $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/".$HTTP_POST_FILES['ufile']['name'][2];


copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);

$NewsTitle = mysql_real_escape_string($_POST["txtNewsTitle"]);
$NewsShort = mysql_real_escape_string($_POST["txtNewsShort"]);
$NewsImage1 = mysql_real_escape_string($HTTP_POST_FILES['ufile']['name'][0]);
$NewsImage2 = mysql_real_escape_string($HTTP_POST_FILES['ufile']['name'][1]);
$NewsAttach = mysql_real_escape_string($HTTP_POST_FILES['ufile']['name'][2]);
$NewsFull = mysql_real_escape_string($_POST["txtNewsFull"]);
$NewsDate = date("d/m/y");


mysql_query("INSERT INTO tblNews(NewsTitle, NewsShort, NewsImage1, NewsAttachment, NewsFull, NewsImage2, NewsDateAdded, NewsArchive) Values ( '" & $NewsTitle & "', '" & $NewsShort & "', '" & $NewsImage1 & "', '" & $NewsAttach & "', '" & $NewsFull & "', '" & $NewsImage2 & "', '" & $NewsDate & "','0') ") or die(mysql_error());
break;
default:
?>
<form action="?action=insert" enctype="multipart/form-data" method="POST">
<table width="100%">
<tr>
  <td  style="width:80%;"><span style="width:20%;">News Title: </span></td>
</tr>
<tr> 
<td style="width:80%;"> 
<input type="text" size="45" name="txtNewsTitle" /></td>
</tr>
<tr>
  <td> </td>
</tr>
<tr>
  <td>News Brief :</td>
</tr>
<tr>
  <td><textarea name="txtNewsShort" cols="70" rows="12" id="txtNewsShort"></textarea></td>
  </tr>
<tr>
   <td > </td>
</tr>
<tr>
  <td><strong>Images:</strong></td>
</tr>
<tr>
  <td>Image 1:  <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
  </tr>
<tr>
  <td>Image 2:  <input name="ufile[]" type="file" id="ufile[]" size="25" /> </td>
</tr>
<tr>
  <td > </td>
</tr>
<tr>
   <td><strong>Attachments:</strong></td>
</tr>
<tr>
  <td>Attachment 1 <input name="ufile[]" type="file" id="ufile[]" size="25" /> </td>
</tr>
<tr>
  <td> </td>
</tr>
<tr>
  <td >News Full :</td>
</tr>
<tr>
  <td ><textarea name="txtNewsFull" cols="70" rows="12" id="txtNewsFull"></textarea></td>
  </tr>
<tr>
  <td > </td>
</tr>
<tr> 
<td  style="height:32px;"><div style=" text-align:center">
<input type="submit" value="Add News"/>
  <input type="reset" name="reset" value="reset" />
</div></td>
</tr>
</table>
</form>
<?
break;
}
?>

 

upon choosing an image to upload i just just 1

 

the image i uploaded then

 

its meant to execute my sql

 

which i just get in return

 

Query Is Empty

 

anyone know whats wrong here?

 

Thank

Link to comment
https://forums.phpfreaks.com/topic/93082-upload-and-add-to-db-error-query-is-empy/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.