Maq
Administrators-
Posts
9,363 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Maq
-
Is KCFeditor a WYSIWYG? If so, you shouldn't use them they produce awful code. How are you creating this page?
-
Heh, that's pretty cool
-
Stop hi-jacking threads. If you have a question please create your own, I didn't realize you weren't the OP. To answer your question, Read more here.
-
array_combine() creates an associative array. So now you have your description and prices linked. For testing to make sure they're linked properly, this will give you an idea of how this function works: $n = array_combine($_POST['description'], $_POST['price']); print_r($n); For insertion use something like: $n = array_combine($_POST['description'], $_POST['price']); foreach($n AS $desc => $price) { $sql = "INSERT INTO table_name_here_break_down (description, price) VALUES ('$desc', '$price')" mysql_query($sql) or die (mysql_error()); echo "Query: " . $sql . " "; }
-
Awesome, it's about time something like this came out...
-
You can get the last inserted id with mysql_insert_id(). That way you can just update to the most recent row rather than create a new one.
-
Use this: $n = array_combine($_POST['description'], $_POST['price']); foreach($n AS $desc => $price) { echo "description: " . $desc . " - Price: " . $price . " "; }
-
That's not true, you can have an array of posted values.
-
What exactly are you trying to do? There may be a better solution.
-
Have you implemented our suggestions? If so, can you post your current code?
-
What OS?
-
You need to use $_POST for all your input fields from your form (i.e. $_POST['form_description']). The reason you get the success message is because you print out the success message no matter what happens after submission.
-
Just get ideas from this forum, look for repeated questions and make a snippet/tutorial for it.
-
PHP is just a hobby for me, although I am a full time software developer. I would like to get into larger freelance projects, right now I just do small side projects.
-
I hope you're joking. I mean, I don't have experience with porn sites, but I highly doubt that.
-
Why are you adding WHERE id = 1? That's your problem, ID should be an auto-increment datatype in your database. You don't need to include it in your query. If you do, you will be overwriting what you just put in, which is the problem you stated in your original post. My understanding of your problem is that every time someone finishes the quiz or w/e the results are stored in the database. That's what the INSERT will accomplish.
-
[SOLVED] having trouble inserting onto mysql
Maq replied to kendallkamikaze's topic in PHP Coding Help
Yes, that's because you have an unconditional INSERT and whenever $_POST == 'Bay'). Like samshel pointed out, you should do this in 1 query. In this example if the user chose Bay it will insert "horsecolors/Bay.jpg" if they don't chose that then it will give the Image a default (horsecolors/default.jpg). Don't forget, put 'Image' in the appropriate position in the query string. if($_POST[breed] == "none") { print "You forgot to select a breed!"; include "footer.php"; exit; } else { $color = $_POST['Color']=="Bay" ? "horsecolors/default.jpg" : "horsecolors/{$_POST['Color']}.jpg"; $sql="INSERT INTO horsedata (Image, Name, Owner, Height, Breed, Gender, Registrations, Exp, Points, Records, Speed, Scope, Power, Obedience, Sociability, Sire, Dam, Foals, Awards, Grading, Hay, Grain, Vet, Shoes, Exercise, Grooming, DOB, Endurance, Intelligence, Color, temperament, legs, back, neck, head, pedigree) VALUES ('$color', '$_POST[Name]','$id','$_POST[Height]','$_POST[breed]','$_POST[Gender]','Not Registered','0','0','none','15','15','15','15','15','The All Great One','The Phantom Mare','None yet','This horse has not won any awards','Not Graded','No','No','No','No','No','No','3','15','15','$_POST[Color]','$_POST[temperament]','$_POST[legs]','$_POST[back]','$_POST[neck]','$_POST[head]','$_POST[pedigree]' )"; mysql_query($sql) or die(mysql_error()); echo "</pre> <table class="'table'"> Congratulations Your horse has been purchased"; } ?> </ -
You were updating the same record over and over again. The reason you got an error for when you tried the INSERT is because you were using a WHERE clause. Try this instead: $sql = "INSERT INTO lesson01 (Q01, Q02, Q03) VALUES ('$ques[0]' , '$Q02', '$Q03')";
-
[SOLVED] having trouble inserting onto mysql
Maq replied to kendallkamikaze's topic in PHP Coding Help
What do you mean? That's the only thing you tell it to INSERT. Try (I cleaned up your code a bit, it's essentially the same): if($_POST[breed] == "none") { print "You forgot to select a breed!"; include "footer.php"; exit; } $sql="INSERT INTO horsedata (Name, Owner, Height, Breed, Gender, Registrations, Exp, Points, Records, Speed, Scope, Power, Obedience, Sociability, Sire, Dam, Foals, Awards, Grading, Hay, Grain, Vet, Shoes, Exercise, Grooming, DOB, Endurance, Intelligence, Color, temperament, legs, back, neck, head, pedigree) VALUES ('$_POST[Name]','$id','$_POST[Height]','$_POST[breed]','$_POST[Gender]','Not Registered','0','0','none','15','15','15','15','15','The All Great One','The Phantom Mare','None yet','This horse has not won any awards','Not Graded','No','No','No','No','No','No','3','15','15','$_POST[Color]','$_POST[temperament]','$_POST[legs]','$_POST[back]','$_POST[neck]','$_POST[head]','$_POST[pedigree]' )"; mysql_query($sql) or die(mysql_error()); echo "</pre> <table class="'table'"> Congratulations Your horse has been purchased"; if($_POST[Color] == 'Bay') { $sql="INSERT INTO horsedata (Image) VALUES ('horsecolors/Bay.jpg')"; mysql_query($sql) or die(mysql_error()); } ?> </ -
[SOLVED] having trouble inserting onto mysql
Maq replied to kendallkamikaze's topic in PHP Coding Help
You're not performing mysql_query() on the query. -
Do the same with page statistics.
-
with the query method :S Query?