The project_pdf table with inserted pdf and project name. Let’s try out the form and PHP code to verify the upload works. However, for the purpose of this blog post as a learning experience, I echo out any exceptions that may arise in the catch block. Errors should be written to a log file instead. Note: It is generally not a good practice to echo any sort of database error information to the browser. $stmt -> bindParam ( ':pdf_doc', $pdf_blob, PDO :: PARAM_LOB ) Įcho 'Could not save information to the database' Įcho 'Database Error '. $stmt -> bindParam ( ':project_name', $project_name ) $insert_sql = "INSERT INTO `project_pdf` (`project_name`, `pdf_doc`) The first if / else block verifies that the ‘submit’ button from the form has been clicked and that the ‘pdf_file’ field has an attachment using the PHP functions isset ( ) and empty ( ) (the converse of truth by negating with the not ! operator for the empty ( ) function): If ( $stmt -> execute ( ) = FALSE ) Verify the button is clicked and a file is attached $stmt -> bindParam ( ':pdf_doc', $pdf_blob, PDO :: PARAM_LOB ) $stmt -> bindParam ( ':project_name', $project_name ) With new content being added regularly, continue learning MySQL at any level. You have access to exclusive content unpublished anywhere else with this membership. Discover premium articles, in-depth guides, instructional videos, and much more by joining the “MySQL Learning Tier” membership.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |