0

OK will try to be as detailed as possible I am working on a site where users select 3 bingo cards and then the number of cards are passed into a MySQL database I have the form working and each card checkbox is labeled like this in html code

            <input type="checkbox" name="whatcard[]" value="39" onclick="return toggle(this);"><br><img border="0" src="images/cards/hhcard39.gif" width="117" height="150" ></b></i></font></td>
    <td width="11%" height="19" align="center"></td>
    <td width="11%" height="19" align="center"><font face="Lucida Console" size="2"><b><i>CARD
      40 </i></b><i><b>

but when I try using php to process it so that it will go into my table with headings playernick card1 card2 card3 random current date
(random is used for another part of this work to be done later)

Using this Php code

        $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db(DB_NAME, $link);

if (!$db_selected) {
    die('can\'t use ' . DB_NAME . ': ' . mysql_error());    
}


$checkBox = implode(',', $_POST['WhatCard']);

if(isset($_POST['submit']))
{       
    $query="INSERT INTO earlyreg VALUES (playernick,'" . $checkBox . "',.,curdate())";     

    mysql_query($query) or die (mysql_error() );

    echo "Complete";

}

?>

I get 2 errors which are

Notice Undefined index: WhatCard in C:\xampp\htdocs\holiday\PickDB.php on line 23

Warning: implode(): Invalid arguments passed in C:\xampp\htdocs\holiday\PickDB.php on line 23 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 'curdate())' at line 1 and have tried looking for alternative ways of doing this any help pointing me where to look is much appreciated

  • I have not asked this question before and have searched and didnt have this code edited till today if I am incorrect showing me where might the duplicate be I would greatly appreciate – John Marshall Dec 23 '15 at 21:03

1 Answers1

0

$_POST['WhatCard'] has 2 capitals, however your form element is lowercase, $_POST['whatcard'] should work.

Albert Bos
  • 2,012
  • 1
  • 15
  • 26
  • that fixed the index which I really appreciate but still getting the error with the 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 'curdate()')' at line 1 but will search and find out where I went wrong on that – John Marshall Dec 23 '15 at 21:04