basically this a code for uploading images and text info into a mysql
database, however, when I execute this code, an error occured as:
Undefined variable: action in \phpmySQL\add.php on line 2
what will be the problem?

if ($action == "upload") {
  // ok, let's get the uploaded data and insert it into the db now
  include "";

  if (isset($binFile) && $binFile != "none") {
    $data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
    $strDescription = addslashes(nl2br($txtDescription));
    $sql = "INSERT INTO tbl_Files ";
    $sql .= "(description, bin_data, filename, filesize, filetype) ";
    $sql .= "VALUES ('$strDescription', '$data', ";
    $sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
    $result = mysql_query($sql, $db);
    mysql_free_result($result); // it's always nice to clean up!
    echo "Thank you. The new file was successfully added to our
    echo "<a href='main.php'>Continue</a>";

} else {
<FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
 <INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="1000000">
 <INPUT TYPE="hidden" NAME="action" VALUE="upload">
   <TD>Description: </TD>
   <TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
   <TD>File: </TD>
   <TD><INPUT TYPE="file" NAME="binFile"></TD>
   <TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to