andylai Posted May 29, 2007 Share Posted May 29, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/53420-file-upload-problems/ Share on other sites More sharing options...
Trium918 Posted May 29, 2007 Share Posted May 29, 2007 What is the problem that you are having? Quote Link to comment https://forums.phpfreaks.com/topic/53420-file-upload-problems/#findComment-263960 Share on other sites More sharing options...
andylai Posted May 29, 2007 Author Share Posted May 29, 2007 I want the text file upload and the record will have the name of the uploaded file. When I call out that ID, it will know which text file to load in html. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/53420-file-upload-problems/#findComment-264007 Share on other sites More sharing options...
Trium918 Posted May 29, 2007 Share Posted May 29, 2007 I understand what you are wanting the script to do, but what is going wrong? What is the script doing? Are you getting any errors? Quote Link to comment https://forums.phpfreaks.com/topic/53420-file-upload-problems/#findComment-264068 Share on other sites More sharing options...
andylai Posted May 29, 2007 Author Share Posted May 29, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/53420-file-upload-problems/#findComment-264085 Share on other sites More sharing options...
andylai Posted May 29, 2007 Author Share Posted May 29, 2007 I found what it is. Now it will do the insert (title, active_code and union_code) but it won't upload the text file and record the file name on database. Quote Link to comment https://forums.phpfreaks.com/topic/53420-file-upload-problems/#findComment-264099 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.