How I can validate input on form before upload file?

PHPMYSQL, Upload box in html, need a bit of help?

  • Ok, so I am quite 'new' as MYsql is concerned, I arent that great at php, I am trying I have this. <hr color="#FF0000" width="700" size="2"> <center> <form enctype="multipart/form-data" action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="104857600" /> Choose a file to upload: <input name="uploadedfile" type="file" /> <input type="submit" value="Upload File" /> </form> </center> <hr color="#FF0000" width="700" size="2"> <?php $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploade… $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } $dnname = $_POST["name"]; $con = mysql_connect("localhost","root","majick… if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("warezzf", $con); $result=mysql_query("INSERT INTO 'uploads' (name) VALUES ($dnname')"); mysql_close($con); ?> I want the upload file name to be inserted into the 'uploads' database on the 'name' option. Please correct me as I get There was an error uploading the file, please try again!

  • Answer:

    I don't know all of your code, but it loos like there is a mistake here: $result=mysql_query("INSERT INTO 'uploads' (name) VALUES ($dnname')"); Corrected: $result=mysql_query("INSERT INTO uploads (name) VALUES ('$dnname')");

Jonathon M at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Try f5.

600pm

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.