Jump to content

[SOLVED] shot in the dark...


galvin

Recommended Posts

I don't know if anyone can answer this without seeing the entire code, but I'll take a chance.  This code below keeps producing the message "The picks were NOT submitted. Column count doesn't match value count at row 1"

 

But I clearly am inserting FOUR values ('1', '{$_POST['pick1']}', '{$_SESSION['userid']}', '{$_POST['week']}' ) into the FOUR specified fields (pick#, teamid, userid, week).

 

I did the echos as testing and each time, all three ARE showing a value.  So that makes me think something must be wrong with my "pick#" value, but that is simply the number 1 (the first entry in the $insertsArr[]).  Is something wrong my syntax? or maybe am I using quotes wrong?

 

Any help would be appreciated...

 

if (isset($_POST['submit']) && $_POST['submit'] == "Submit Pick #1" ) { 

    //print_r($HTTP_POST_VARS);
$atLeastOnePick = '';
$insertsArr = array();

	if($_POST['pick1'] && $_POST['week']){
		$atLeastOnePick = 1;
		$insertsArr[] = "('1', '{$_POST['pick1']}', '{$_SESSION['userid']}', '{$_POST['week']}' )";
	}


		if($atLeastOnePick){
			$query = "INSERT INTO picks2009 (
					pick#, teamid, userid, week
				) VALUES " . implode(', ', $insertsArr) ;

			$result = mysql_query($query, $connection);
					if ($result) {
						$message = "<p class=\"success\" >The picks were successfully submitted.  </p>";
						$pick1editmode="yes";
					} else {
						$message = "The picks were NOT submitted.";
						$message .= "<br />" . mysql_error();
						echo "teamid=" . $_POST['pick1'];
						echo "userid=" . $_SESSION['userid'];
						echo "week" . $_POST['week'];
					}
		} else {
		$badsubmit = '<p class="error">Error: Please be sure the WEEK NUMBER is selected (and at least one pick is made)!';
		}

Link to comment
https://forums.phpfreaks.com/topic/140101-solved-shot-in-the-dark/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.