Jump to content

philip315

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

philip315's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oh my God. So sorry! I was expecting a message in my inbox saying that you wrote. I didnt know that you wrote to me so I did not respond. I have since looked at what you say, but I have worked it out another way. I am not using the array. I cant wrap my head around array. Instead of one variable to equal my three checkboxes $choice, I now have just labeled each checkbox a completely different name, so now it is just like any other input function. Now I can make three separate input fields on MySql for data input. If some one picks A, B , C or all three it doesnt matter because each field has nothing to do with each other field. This is a very decent solution to my query and I think I am happy with it. Thank you for all your help and sorry again for not responding last week.
  2. What I seem to be having a problem with now is actually getting the data onto mySQL. Originally I had three variables called $formcheck1,$formcheck2, and $formcheck3. When I looked at the code you gave me I saw that the variables where changed to $choice. When I make the variable $choice First of all it only gives one data field not three which might make things harder in the future in terms of Sql searches.... and the other thing is that when I add $choice into the data to be entered into mySQl only the last letter checked gets added to the database. So if someone checks A and C, I will see C on the database.
  3. Ok I dont have the code you gave me working yet but looking at it it seems as if taht code would be $choice. Now $choice would be either A, B or C right? What I was looking for was to be able to pick more than one letter such as A and B. I have 3 checkboxes so I took them into php by $formcheck1=$_POST['formcheck']['value']; $formcheck2=$_POST['formcheck']['value']; $formcheck3=$_POST['formcheck']['value']; I wasnt sure whether to place 'value' as 'name' but it doesnt matter because neither works. Dont I have to bring the formcheck[] array into the php page with the above code first before I use the code you gave me, and then the code you gave... isnt that just for either A or B or C and not for A and B (one example)?
  4. I finished making an entire php and it will not go to my SQL document. The problem is on line 1. Line 1 would be <?php . Anyway I will include the php here. Do you know what the problem is? <?php //This gets all the other information from the form $Fname=$_POST['Fname']; $Lname=$_POST['Lname']; $Compname=$_POST['Compname']; $emailad=$_POST['emailad']; $urlname=$_POST['urlname']; $address=$_POST['address']; $address2=$_POST['address2']; $address3=$_POST['address3']; $phone=$_POST['phone']; $phone2=$_POST['phone2']; $phonename=$_POST['phonename']; $listingtype=$_POST['listingtype']; $formcheck1=$_POST['formcheck']['name']; $formcheck2=$_POST['formcheck']['name']; $formcheck3=$_POST['formcheck']['name']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['photo']['name']); $pic3=($_FILES['photo']['name']); $pic4=($_FILES['photo']['name']); $description=$_POST['atDescription']; // Connects to your Database mysql_connect ("", "", "") or die(mysql_error()) ; mysql_select_db("") or die(mysql_error()) ; //Writes the photos to the server and store the names in $picname[] foreach ($_FILES["photo"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["photo"]["tmp_name"][$key]; $name = $_FILES["photo"]["name"][$key]; move_uploaded_file($tmp_name, "upload/$name"); $picname[] = $name; } else { //Gives and error if its not echo "bldf"; } } // setup empty names so that the variable will exist $pic = ""; $pic2 = ""; $pic3 = ""; $pic3 = ""; // overwrite the empty pic names if they exist if (count($picname) > 0) { //at least 1 pic $pic = $picname[0]; } if (count($picname) > 1) { //at least 2 pics $pic2 = $picname[1]; } if (count($picname) > 2) { //at least 3 pics $pic3 = $picname[2]; } if (count($picname) > 3) { //at least 4 pics $pic4 = $picname[3]; } // don't care if there's more than 4 //Writes the information to the database $sql = ("INSERT INTO bestform (Fname,Lname,Compname,emailad,urlname,address,address2,address3,phone,phone2,phonename,listingtype,formcheck_1,formcheck_2,formcheck_3,photo_1,photo_2,photo_3,photo_4,atDescription,) VALUES ('$Fname', '$Lname', '$Compname', '$emailad', '$urlname', '$address', '$address2', '$address3', '$phone', '$phone2', '$phonename', '$listingtype', '$formcheck1', '$formcheck2', '$formcheck3', '$pic', '$pic2', '$pic3', '$pic4', '$description')") ; //Writes the information to the database mysql_query($sql) or die(mysql_error()); // and catch any error echo date("m/d/y : H:i:s", time()) ?>
  5. Hi all, I have a code which works just fine for adding one picture to my database but when I change the form to add mutliples i get an error because my code is set for multiple pictures as an array. Error says this is a string code. Does anyone know the code for array? $target = "upload/"; $target = $target . basename( $_FILES['photo']['name']); Error message says Warning: basename() expects parameter 1 to be string, array given in /home/content/19/6550319/html/listingsss.php on line 7 Thanks, Philip
  6. I have not heard from anyone in a couple of days and I am still having problems getting multiple pictures transferred to my server. I have been testing over the past couple of days and I renamed the "photos" from different names to one name so that the php can read it as an array. See below. I will write more after I post code: $price=$_POST['price']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['photo']['name']); $pic3=($_FILES['photo']['name']); $pic4=($_FILES['photo']['name']); $description=$_POST['atDescription']; $condition=$_POST['condition']; $gig=$_POST['giga']; $yesg=$_POST['yesg']; $fname=$_POST['firstName']; $lname=$_POST['lastName']; $email=$_POST['email']; I did the above so that this following code will work. I will write another bit after the code: //Writes the photos to the server and store the names in $picname[] foreach ($_FILES["photo"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["photo"]["tmp_name"][$key]; $name = $_FILES["photo"]["name"][$key]; move_uploaded_file($tmp_name, "upload/$name"); $picname[] = $name; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your files."; } } // setup empty names so that the variable will exist $pic = ""; $pic2 = ""; $pic3 = ""; $pic3 = ""; // overwrite the empty pic names if they exist if (count($picname) > 0) { //at least 1 pic $pic = $picname[0]; } if (count($picname) > 1) { //at least 2 pics $pic2 = $picname[1]; } if (count($picname) > 2) { //at least 3 pics $pic3 = $picname[2]; } if (count($picname) > 3) { //at least 4 pics $pic4 = $picname[3]; } // don't care if there's more than 4 Now I get an error message. I will give you the error message now and place the two line code that the error message is associated with below. Here is the error message: Warning: basename() expects parameter 1 to be string, array given in /home/content/19/6550319/html/listingpoopysss.php on line 6 Sorry, there was a problem uploading your files.Sorry, there was a problem uploading your files. Now below is lines 5 - 6 associated with the above error message: //This is the directory where images will be saved $target = "upload/"; $target = $target . basename( $_FILES['photo']['name']); Can you help me deciphor
  7. Okay I added the brackets back in and I added the code you gave me to the top of the page. With the code as it is I do not get the photos but I get the data to mySQL. The result gives this message: $_FILES array: Array ( [photo] => Array ( [name] => 009.jpg [type] => image/pjpeg [tmp_name] => /tmp/phpcMumuD [error] => 0 => 2239300 ) [phototwo] => Array ( [name] => [type] => [tmp_name] => [error] => 4 => 0 ) [photothree] => Array ( [name] => [type] => [tmp_name] => [error] => 4 => 0 ) [photofour] => Array ( [name] => [type] => [tmp_name] => [error] => 4 => 0 ) ) Warning: Invalid argument supplied for foreach() in /home/content/19/6550319/html/listingpoopysss.php on line 44 price is 29. description is ytryty condition is Excellent gig is 16 yesg is Yes fname is tyt lname is tyty email is tytyt INSERT INTO artdod (price,photo,phototwo,photothree,photofour,atDescription,`condition`,giga,yesg,firstName,lastName,email) VALUES ('29.', '', '', '', '', 'ytryty', 'Excellent', '16', 'Yes', 'tyt', 'tyty', 'tytyt') 03/20/11 : 18:44:13
  8. Thank you for letting me know that condition should be `condition`. You also said that the foreach part of the code has no closing bracket //Writes the photos to the server and store the names in $picname[] foreach ($_FILES["photos"]["error"] as $key => $error) if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["photos"]["tmp_name"][$key]; $name = $_FILES["photos"]["name"][$key]; move_uploaded_file($tmp_name, "upload/$name"); $picname[] = $name; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your files."; } I think the opening bracket was right in front of the word {if. I took it out to make opening and closing brackets equal. This did not work. Here is my warning message: Warning: Invalid argument supplied for foreach() in /home/content/19/6550319/html/listingpoopysss.php on line 46 Problem is that I was given this code which is related to the code after it to work out the fact that the data was not going to mySQL. I understand only that this code represents an array, but I am not clear as to how it sets up a name for my pictures (whether it be empty or a picture file that someone actually uploads to the php) and I really dont understand where to put the brackets yet.
  9. Hi: As for line 91 I tried taking out the extra bracket and also adding in an extra opening bracket before ("Insert into...to make it even. My error respnse was syntax error. Here is the exact words of the error: INSERT INTO artdod (price,photo,phototwo,photothree,photofour,atDescription,condition,giga,yesg,firstName,lastName,email) VALUES ('32.', '', '', '', '', 'jhgjhgj', 'Excellent', '16', 'Yes', 'hj', 'hj', 'hjhj') 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 'condition,giga,yesg,firstName,lastName,email) VALUES ('32.', '', '', '', '', '' at line 1
  10. I have been trying to figure this out for more than a week but my form does not parse the information to send it to mysql. When I try to send it I get this error: Parse error: syntax error, unexpected ')' in /home/content/19/6550319/html/listingpoopys.php on line 91 Can anyone maybe try the code out and figure out what is not right? Here is the form. Underneath will be the php <form method="post" action="something.php" enctype="multipart/form-data"> <label>Asking Price </label> <input type="text" name="price" /> <br /> <br /> <div style="text-align: left;"> </div> <label>Photo 1 <span class="small">(required)</span> </label> <input type="hidden" name="size" value="350000" /> <input type="file" name="photo" /> <label>Photo 2 (Optional) <span class="small">no larger than 320px x 240px </span> </label> <input type="hidden" name="size" value="77000" /> <input type="file" name="phototwo" /> <label>Photo 3 (Optional) <span class="small">no larger than 320px x 240px </span> </label> <input type="hidden" name="size" value="77000" /> <input type="file" name="photothree" /> <label>Photo 4 (Optional) <span class="small">no larger than 320px x 240px </span> </label> <input type="hidden" name="size" value="77000" /> <input type="file" name="photofour" /> <label> description <span class="small">Ad Copy</span> </label> <textarea name="atDescription" rows="10" cols="35" onfocus="this.value=''; this.onfocus=null;">What you enter here will show up on the description area</textarea> <p>What is the condition?</p> <select name="condition"> <option value="Excellent">Excellent</option> <option value="Very Good">Very Good</option> <option value="Good">Good</option> <option value="Fair">Fair</option> </select> <p>How many GB?</p> <select name="giga"> <option value="16">16</option> <option value="32">32</option> <option value="64">64</option> </select> <p>Does It Come installed?</p> <select name="yesg"> <option value="Yes">Yes</option> <option value="No">No</option> </select> <br /><br /> <h1>Personal Information</h1> <p class="style">Information below will not appear on website</p> <label>First Name </label> <input type="text" name="firstName" /> <label>Last Name </label> <input type="text" name="lastName" /> <label>email </label> <input type="text" name="email" /> <br/> <br/> <input type="submit" value="Submit form" /> </form> Here is the php: <?php //This is the directory where images will be saved $target = "upload/"; // $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $price=$_POST['price']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['phototwo']['name']); $pic3=($_FILES['photothree']['name']); $pic4=($_FILES['photofour']['name']); $description=$_POST['atDescription']; $condition=$_POST['condition']; $gig=$_POST['giga']; $yesg=$_POST['yesg']; $fname=$_POST['firstName']; $lname=$_POST['lastName']; $email=$_POST['email']; // Connects to your Database // I'll assume you are using host, user and psssword, and have just removed them for security. mysql_connect ("", "", "") or die(mysql_error()) ; // I'll assume you have the database name in here, and have just removed it for security. mysql_select_db("") or die(mysql_error()) ; $price = mysql_real_escape_string ($price); $description = mysql_real_escape_string ($description); $condition = mysql_real_escape_string ($condition); $gig = mysql_real_escape_string ($gig); $yesg = mysql_real_escape_string ($yesg); $fname = mysql_real_escape_string ($fname); $lname = mysql_real_escape_string ($lname); $email = mysql_real_escape_string ($email); //Writes the photos to the server and store the names in $picname[] foreach ($_FILES["photos"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["photos"]["tmp_name"][$key]; $name = $_FILES["photos"]["name"][$key]; move_uploaded_file($tmp_name, "upload/$name"); $picname[] = $name; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your files."; } // setup empty names so that the variable will exist $pic = ""; $pic2 = ""; $pic3 = ""; $pic3 = ""; // overwrite the empty pic names if they exist if (count($picname) > 0) { //at least 1 pic $pic = $picname[0]; } if (count($picname) > 1) { //at least 2 pics $pic2 = $picname[1]; } if (count($picname) > 2) { //at least 3 pics $pic3 = $picname[2]; } if (count($picname) > 3) { //at least 4 pics $pic4 = $picname[3]; } // don't care if there's more than 4 // print variables to screen for debugging echo "price is ".$price."<br/>"; echo "description is ".$description."<br/>"; echo "condition is ".$condition."<br/>"; echo "gig is ".$gig."<br/>"; echo "yesg is ".$yesg."<br/>"; echo "fname is ".$fname."<br/>"; echo "lname is ".$lname."<br/>"; echo "email is ".$email."<br/>"; // remove or comment out when debugging complete //Writes the information to the database $sql = "INSERT INTO artdod (price,photo,phototwo,photothree,photofour,atDescription,condition,giga,yesg,firstName,lastName,email) VALUES ('$price', '$pic', '$pic2', '$pic3', '$pic4', '$description', '$condition', '$gig', '$yesg', '$fname', '$lname', '$email')") ; //Print the sql to screen after all the variable substitutions. echo $sql."<br/>"; // remove or comment out when debugging complete //Writes the information to the database mysql_query($sql) or die(mysql_error()); // and catch any error echo date("m/d/y : H:i:s", time()) ?>
  11. Yes the javascript now works! Thank you, and I will apply the code to the php now and change the valur to "1". Thanks again.
  12. I added the code onsubmit="return checkCheckBox (this)" and the javascript still doesnt work. I noticed that you gave the sign $_POST which is the php code. I have not included a variable like that to my php file before because I do not want to upload a checkbox to my SQL database, but as a test I added the code $check=$_POST['agree'] onto my php file just to pull it up but I did not send it to my SQL. Anyway the problem can be fixed with the form file I think, isnt that correct? Here is the code <html> <head> <SCRIPT language=JavaScript> <!-- //Accept terms & conditions script (by InsightEye www.insighteye.com) //Visit JavaScript Kit (http://javascriptkit.com) for this script & more. function checkCheckBox(f){ if (f.agree.checked == false ) { alert('Please check the box to continue.'); return false; }else return true; } //--> </SCRIPT> </head> <body> <form method="post" action="addMember1.php" enctype="multipart/form-data"> Please Enter the Band Members Name. </p> Band Member or Affiliates Name: </p> <input type="text" name="nameMember"/> Please Enter the Band Members Position. Example:Drums. </p> Band Position: </p> <input type="text" name="bandMember"/> Please Upload a Photo of the Member in gif or jpeg format. The file name should be named after the Members name. If the same file name is uploaded twice it will be overwritten! Maxium size of File is 35kb. </p> Photo: </p> <input type="hidden" name="size" value="350000"> <input type="file" name="photo"> Please Enter any other information about the band member here. </p> Other Member Information: </p> <textarea rows="10" cols="35" name="aboutMember"> </textarea> Please Enter any other Bands the Member has been in. </p> Other Bands: </p> <input type="text" name="otherBands" size=30 /> <br/> <!--Enter your form contents here--> <b>By submitting, I agree to <a href="http://www.atdolls.com" target="_blank">Contract</a></b><br /> I accept: <input type="checkbox" value="0" name="agree" onsubmit="return checkCheckBox(this)"> <input type="submit" value="Submit form"> </form> </body> </html> By the way there are two inputs at the bottom of the page (the form and the checkbox) I tried including the onsubmit code onto both but left it for you on the checkbox line.
  13. Thank you for the quick reply. I have tried tp remove the extra submit button and cosolidate 2 forms into two. The problem is the box is there but it doesnt follow the javascript. If I do not check the button, my files upload anyway which is not the result I want. I would like for the little window to pop up and say you must check the box before upload. If I somehow add instructions on the php form it still uploads but on the upload it says what I ask it to say like "...Need to click box first" (example text) but it gives the words I ask it to write on the same page that says right after that Your files were uploaded successfully to the directory. I cant seem to get the javascript to function properly when it is in the form.
  14. I hope I am in the right forum because my php code is on another page. Because my form has to uplaod pictures it is set to method post., and enctype="multipart/form-data". Now my checkbox button does not work inside this form because it is set to method get? I really would like this checkbox because I would like to ensure that people have read my terms and conditions. Can anyone help find a solution? Here is the code. As you can see at the bottom there is two submit buttons. I only want one to add the files to my directory and also to be attached to the terms agreement. <SCRIPT language=JavaScript> <!-- //Accept terms & conditions script (by InsightEye www.insighteye.com) //Visit JavaScript Kit (http://javascriptkit.com) for this script & more. function checkCheckBox(f){ if (f.agree.checked == false ) { alert('Please check the box to continue.'); return false; }else return true; } //--> </SCRIPT> <form method="post" action="addMember1.php" enctype="multipart/form-data"> Photo: </p> <input type="hidden" name="size" value="350000"> <input type="file" name="photo"> Please add photo here. </p> Other Member Information: </p> <textarea rows="10" cols="35" name="aboutMember"> </textarea> Please Enter any other Bands the Member has been in. </p> Other Bands: </p> <input type="text" name="otherBands" size=30 /> <br/> <br/> <input TYPE="submit" name="upload" title="Add data to the Database" value="Submit Form"/> </form> <form action="/yourscript.cgi-or-your-page.html" method="GET" onsubmit="return checkCheckBox(this)"> <!--Enter your form contents here--> <b>By submitting, I agree that all info <a href="http://www.atdolls.com" target="_blank">blah blah booby</a> d was done accurately & truthfully.</b><br /> I accept: <input type="checkbox" value="0" name="agree"> <input type="submit" value="Submit form"> <input type="button" value="Exit" onclick="document.location.href='http://www.loveforevergifts.com';"> </form>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.