INSERT queries

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Your on the right track. It looks like your form is returning a multidimensional array. Try removing the [] from the entries field in the form and test it again.
enigm4_
Forum Newbie
Posts: 17
Joined: Sun Mar 12, 2006 12:40 am

Post by enigm4_ »

Problem now gives me:

Warning: Invalid argument supplied for foreach() in /home/dxqmyhvh/public_html/reakt/inner.php(43) : eval()'d code on line 49
string(36) "T-Shirts (available in red or black)"

So it's only grabbing the last selection from the box instad of all of them.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

if(isset($_POST['submit'])) {
  $Entries = $_POST['entries'];
  $Count = count($Entries);

  while ($Count >= 0) {
    $Count--;
    echo $Entries[$Count];
  }

  $story=$_POST['story'];

  //Inset everything into the database
  $compentry=mysql_query("INSERT INTO tblCompetitionSubmissions (compUserID, compStory, compEntries, compEntryDate) VALUES ('$userid', '$story', '$comps', NOW())");

  //Check whether or not the inset worked:
  if($compentry) {
    //If it worked, echo a success
    echo "<div class=\"information\"><h4>Success!</h4><p>Thankyou, your submission has been received.  We will let you know if you win!</p></div>";
  } else {
    //If it failed, show the error:
    echo "<div class=\"phpoutput\"><h4>Error</h4><p>Sorry, your submission could not be sent at this time.  Please try again later, or <a href=\"mailto:online@reakt.com.au\">email Chris</a> to report your problems.</p></div>";
  }
}
That might work, I didn't test it.
Post Reply