Jump to content

Recommended Posts

Hi,

 

I try to create a record that contain job title, 2 options of radio button and a text file.  The text file will associate with the record and will loading on html.  here is my code.

Thanks.

Andy

 

<?php
include ("db.php"); //error checking mysql_query_ec included
extract ($_REQUEST);
$error="";
$message="";
if (isset($action)){
  
  if ($action == "Add") {    
    if (empty($job_title)) {
    $error = $error. "Please enter a file name<br>";
    }
    $result = mysql_query_ec("SELECT * FROM hrdb WHERE title='$job_title'");
    if (mysql_num_rows($result) !=0) {
      echo "The position already exists in the database. Please enter another. <BR>";
     
    } elseif (empty($error)) {
      mysql_query_ec("insert into hrdb (title,union,active,des_path) value ('$job_title','$union','$act','$uploadfile')");
      //$message="File $filename added to the list.";
      echo $message;
    }
  } 
  
} 
?>
<div align = "center">
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="GET">
  <?php
  echo $messgae;
  ?>
  
  <h1>Add job</h1>
  <br>
  
   
      <TABLE>
<TR>
<TD>Job Title: </TD>
<TD><input type="text" name="job_title"></TD>
</TR>
<TR>
<TD>Union:</TD>
<TD><INPUT type="radio" name="union" value="Y"> Yes
<INPUT type="radio" name="union" value="N" CHECKED> No</TD>
</TR>
<TR>
<TD>Active:</TD>
<TD><INPUT type="radio" name="act" value="Y"> Yes
<INPUT type="radio" name="act" value="N" CHECKED> No</TD>
</TR>
<TR>
<TD>Job Description:</TD>
<TD><input type="hidden" name="MAX_FILE_SIZE" value="51200">
<input type="file" name="fileupload"></TD>


</TR>

</TABLE>
      
      <input type="submit" name="action" value="Add">
      <hr>
      <?php if (!empty($error)) {echo "<p align='center'><font color ='red'>$error</font></p>";} ?>
    </form>
</div>
<BR>
<BR>
<div align = "center">
  <h1> Delete file to a list </h1>
    <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="GET">
      File Name:
      <input type="text" name="filename">
      <input type="submit" name="action" value="Delete">
      <hr>
    </form>
</div>

Link to comment
https://forums.phpfreaks.com/topic/53420-file-upload-problems/
Share on other sites

insert into hrdb (title,union,active,des_path) value ('Network Admin','N','Y','')You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union,active,des_path) value ('Network Admin','N','Y','')' at line 1

 

here is the error I got.

Link to comment
https://forums.phpfreaks.com/topic/53420-file-upload-problems/#findComment-264085
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.