1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Column count doesn't match value count at row 1

Discussion in 'MySQL' started by JSellnau_TSCC, Jun 21, 2011.

  1. #1
    This is the code I am working with:
    $sql = "SELECT address, city, state, zip, rent, dateavailable, available, description, leaseterms, unit, rooms, photodescription1, photodescription2, photodescription3, photoupload1, photoupload2, photoupload3 FROM `$areaname` WHERE id = $id";
    
    $result = mysql_query($sql);
    
    echo mysql_error();
    
    $line = mysql_fetch_array($result);
    
    
    
    $sql = "INSERT INTO `$areaname` (address, city, state, zip, rent, dateavailable, available, description, leaseterms, unit, rooms, photodescription1, photodescription2, photodescription3, photoupload1, photoupload2, photoupload3) VALUES (" . "'" . $line['address'] . "', '" . $line['city'] . "', '" . $line['state'] . "', '" .  $line['zip'] . "', '" . $line['rent'] . "', '" . $line['dateavailable'] . "', '" . $line['available'] . "', '" . $line['description'] . "', '" . $line['leaseterms'] . "', '" . $line['filename'] . "', '" . $line['unit'] . "', '" . $line['rooms'] . "', '" . $line['photodescription1'] . "', '" . $line['photodescription2'] . "', '" . $line['photodescription3'] . "', '" . $line['photoupload1'] . "', '" . $line['photoupload2'] . "', '" . $line['photoupload3'] . "')";
    
    Code (markup):
    And this is the error I am getting
    Unknown column 'photoupload1' in 'field list'
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/58/5459158/html/manage2/copylisting.php on line 17
    Column count doesn't match value count at row 1 
    Code (markup):
    I know the column exist in the table and I don't have problems with other parts of the code that uses the same table and columns.

    Any ideas?
     
    JSellnau_TSCC, Jun 21, 2011 IP
  2. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not saying this is the solution, but try a mysql_fetch_assoc($result) instead of array. See what that does for you.
     
    ntomsheck, Jun 23, 2011 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Post the output of
    DESC table_name;
    Code (markup):
     
    mwasif, Jun 24, 2011 IP