I'm getting the following error when I click the "AD RECORD" button:
INSERT failed: INSERT INTO user_master VALUES('cha' , 'rstein' , 'bar' , 'foo') Column count doesn't match value count at row 1
from the following code:
if (isset($_POST['delete']) && isset($_POST['first']))
{
$first = get_post('first');
$query = "DELETE FROM user_master WHERE first='$first'";
if(!mysql_query($query, $db_server))
echo "DELETE failed: $query<br />" .
mysql_error() . "<br /><br />";
}
if (isset($_POST['first']) && isset($_POST['last']) && isset($_POST['user_name']) && isset($_POST['email']))
{
$first = get_post('first');
$last = get_post('last');
$email = get_post('email');
$user_name = get_post('user_name');
$query = "INSERT INTO user_master VALUES" . "('$first' , '$last' , '$user_name' , '$email')";
if(!mysql_query($query, $db_server)) echo "INSERT failed: $query <br />" . mysql_error() . "<br /><br />";
}
echo <<<END
<form action = "willingLog.html" method="post"><pre>
First <input type="text" name="first" />
Last <input type="text" name="last" />
Email <input type="text" name="email" />
Username <input type="text" name="user_name" />
<input type="submit" value="AD RECORD" />
</pre></form>
END;
Your database table has more columns then you are inserting into so you're getting error. (You're probably not representing your userID field which probably is your primary key). You need to specify which fields the data is for in your query:
$query = "INSERT INTO user_master (first_name, last_name, user_name, email) VALUES" . "('$first' , '$last' , '$user_name' , '$email')";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With