Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About hbphoto

  • Rank
  1. Hi, I created two input fields in my form named image and image1. The code I used to process the upload looks like this. The code here uploads the first image. I then copied and pasted this same exact code underneath and changed everything that referenced "image" to "image1". And that's about it. if (is_uploaded_file ($_FILES['image']['tmp_name']) && ($_FILES['image']['error'] == UPLOAD_ERR_OK)) { $file = $_FILES['image']; $size = ROUND($file['size']/1024); // Validate the file size: if ($size > 99999999999) { $errors['image'] = 'The uploaded file was too large.'
  2. I was able to finally solve uploading both images to the directory. I'm trying to insert the information to the table and I'm receiving the following error message: An error occurred in script 'add_image.php' on line 195: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given My connection to the database works because I have a select statement in my form to create a drop down list of my clients. I also made sure that the number of '?' marks equal the number of columns in my table. Also, I made sure that I have the same number of bind parameters fo
  3. Yes, I'm a product photographer. I want my clients to sign into the website and view their photos so they can decide which ones they want. I want them brought to a page with thumbnails and then they can click on a thumbnail and a larger photo appears. As for the size of the thumbnails, I have a size which works very well. My one concern regarding automatically generating the thumbnails is that the page may take a long time to load. If there is an efficient way of doing this, I'm all ears.
  4. Ok, great, that's exactly what I have. I guess where I'm stumped is after the form is submitted, how do I process both images through validation and moving to and from the temporary directory?
  5. With the code written as above, can I put the file from the first input into a field in the table called ORIGINAL and the file from the secon input into a field in the table called THUMB?
  6. Hello: I have a form which uploads the photo name, description, client name, original size image, and thumbnail size image. I have a table which contains the following fields: photo_id, client_id, photo_name, description, image_original, image_thumb Can someone help me figure out a more efficient way to upload two images on the same form? Here is the code for the form. <form enctype="multipart/form-data" action="add_image.php" method="post" accept-charset="utf-8"> <input type="hidden" name="MAX_FILE_SIZE" value="10485760 " /> <label><strong>Image
  7. I changed my field to UNSIGNED while using BIGINT. The result was the same. I then changed my field to CHAR. The result is now correct. I'm at a loss as to why the INT wasn't working. The example in the book is using INT.
  8. Hello: Changing the INT to BIGINT generated the same result. I'm going to try CHAR.
  9. Yes, I am doing debugging steps. First, I echo'd the results of my form submission so I'm certain that what I typed into the form is being passed through the validation process. Here is the code and the results: // Check for a phone number: // Strip out spaces, hyphens, and parentheses: $phone = str_replace(array(' ', '-', '(', ')'), '', $_POST['phone']); if (preg_match ('/^[0-9]{10}$/', $phone)) { $ph = $phone; } else { $add_client_errors['phone'] = 'Please enter your phone number!'; } echo $_POST['phone']; echo "<br />"; // creating a new line echo $phone; ech
  10. Hi, In the second example in this book, in the checkout.php, a phone number is checked as part of form submission. I'm using the same syntax for the validation as well as the form field. When I run my script, the phone number that I enter into the form, 222-333-4444, does not insert into the database table as 2223334444. Instead, the result that is being populated into my table for phone is 2147483647. I have no clue as to what is causing this. In my table, the phone field is set as INT(10) NOT NULL just as in the book. Can someone help? Here's my code starting with t
  11. I fixed the problem. Here's what I did. I createda variable $pwd which hashes the password first. Then I referenced this new variable in the bind_param statement. $pwd = get_password_hash($p); $q = "INSERT INTO client (first_name, last_name, address, city, state, zip, phone, email, pass, date_created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW() )"; $stmt = mysqli_prepare($dbc, $q); mysqli_stmt_bind_param($stmt, 'sssssiiss', $fn, $ln, $sa, $c, $st, $z, $ph, $e, $pwd); mysqli_stmt_execute($stmt); Thanks to everyone for the help!
  12. I made some modifications to my code and when I run the script I'm receiving the following error message: Fatal error: Only variables can be passed by reference in add_client.php on line 105. Here is the code: line 102: $q = "INSERT INTO client (first_name, last_name, address, city, state, zip, phone, email, pass, date_created) line 103: VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW() )"; line 104: $stmt = mysqli_prepare($dbc, $q); line 105: mysqli_stmt_bind_param($stmt, 'sssssiiss', $fn, $ln, $sa, $c, $st, $z, $ph, $e, '" . get_password_hash($p) . "'); line 106: mysqli_stmt
  13. I will give it a try. As for the date, if I use NOW() in my VALUES of the insert statement, I don't include it as a bind variable. Would that be correct? Otherwise, how do I insert a date? And, for the password, if I place a ? in the VALUES, in the bind statement how do I hash the password to be inserted?
  14. Hello: My password field in the table is set as varbinary. I removed the formmating from the code. The error message I received stated that only variables could be bound. $q = "INSERT INTO client (first_name, last_name, address, city, state, zip, phone, email, pass, date_created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, get_password_hash(?), NOW() )"; $stmt = mysqli_prepare($dbc, $q); mysqli_stmt_bind_param($stmt, 'sssssiiss', $fn, $ln, '$sa', '$c', '$st', '$z', '$ph', '$e', '$p'); mysqli_stmt_execute($stmt);
  • Create New...