sql error

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

Post Reply
mattmcb
Forum Commoner
Posts: 27
Joined: Sun Jan 25, 2004 3:34 pm

sql error

Post by mattmcb »

I'm getting the following error...

Column count doesn't match value count at row 1

here is the code for the form html:

Code: Select all

<select name="venture_name">
        <option value="1">Joint Venture</option>
        <option value="2">Link Exchange</option>
        <option value="3">Customer Exchange</option>
        <option value="4">Banner Exchange</option>
        <option value="5">Advertising Exchange</option>
        <option value="6">Offer to Advertise</option>
        <option value="7">Offer to Accept Ads</option>
        <option value="8">Feature / Technology / Code Exchange</option>
        <option value="9">Service / Product Exchange</option>
        <option value="10">Resource Exchange</option>
        </select>
here is the code for the php:

Code: Select all

$venture_name = $_POST&#1111;'venture_name'];
$result = mysql_query("SELECT venture_id FROM venture_master WHERE venture_type = '$venture_name' ", $linkid)
	or die("Query failed: " . mysql_error());
while ($row = mysql_fetch_row($result))
&#123;    
    $venture_id =  $row&#1111;'venture_id']; 
&#125;
Please help!
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

I don't see an error immediately.

What kind of field is venture_type in your database?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

I dont' think the error is from this code of yours...

Code: Select all

venture_name = $_POST&#1111;'venture_name']; 
$result = mysql_query("SELECT venture_id FROM venture_master WHERE venture_type = '$venture_name' ", $linkid) 
   or die("Query failed: " . mysql_error()); 
while ($row = mysql_fetch_row($result)) 
&#123;    
    $venture_id =  $row&#1111;'venture_id']; 
&#125;
The MySQL error is letting you know that you have tried to insert data into a database with something like INSERT INTO `myTable` VALUES('one','two','three') but the number of values you are setting in the query doesn't match the number of columns in the table.

If you have an auto_id column for example you still need to include it in your VALUES but set it as a blank value ie.. VALUES('','one','two','three') (the first value is the auto increment column)
Post Reply