sunilpaladugu Posted March 2, 2011 Share Posted March 2, 2011 Hi all While I am using the below query I am getting the error msg like "Column count doesn't match value count at row 1" INSERT INTO datain2.student(id,name) VALUES ($query_row[id],'$query_row[name]'); and I am sure about there is no where conflict with the columns of tables Link to comment https://forums.phpfreaks.com/topic/229350-column-count-doesnt-match-value-count-at-row-1/ Share on other sites More sharing options...
Muddy_Funster Posted March 2, 2011 Share Posted March 2, 2011 is id auto incrament? have you echoed out the values from $query_row[id] and $query_row[name]? Could you post your full php code please? Link to comment https://forums.phpfreaks.com/topic/229350-column-count-doesnt-match-value-count-at-row-1/#findComment-1181735 Share on other sites More sharing options...
harristweed Posted March 2, 2011 Share Posted March 2, 2011 INSERT INTO datain2.student(id,name) VALUES ( '{$query_row['id']}', '{$query_row['name']}'); Link to comment https://forums.phpfreaks.com/topic/229350-column-count-doesnt-match-value-count-at-row-1/#findComment-1181737 Share on other sites More sharing options...
sunilpaladugu Posted March 2, 2011 Author Share Posted March 2, 2011 Dear Muddy_Funster Here is my PHP code ...... ID in this is not Auto-increment <?php include("db.php") ?> <?php $year=$_GET['Y']; $month=$_GET['M']; $day=$_GET['D']; $selddate=$year.'-'.$month.'-'.$day; echo 'Selected Date:'.$selddate.'<br>'; $curdate=date("Y-m-d"); echo 'Current Date:'.$curdate; $query_newsfeed = "SELECT id,name FROM datain1.student where insert_date='$selddate' "; $query1_exec = mysql_query ( $query_newsfeed ) or die (mysql_error()); $num=mysql_num_rows($query1_exec); echo '<br><b>'.$num.'</b><br>'; if (mysql_num_rows($query1_exec) == 0) { echo "No rows found, cannot do anything"; exit; } while ($query_row = mysql_fetch_assoc($query1_exec)) { $query2 = "INSERT INTO datain2.student(id,name) VALUES ($query_row[id],'$query_row[name]')"; echo $query2; $query2_exec = mysql_query($query2) or die (mysql_error()); } ?> Link to comment https://forums.phpfreaks.com/topic/229350-column-count-doesnt-match-value-count-at-row-1/#findComment-1181752 Share on other sites More sharing options...
gizmola Posted March 2, 2011 Share Posted March 2, 2011 You should not be calling mysql_num_rows() twice in a row. $num=mysql_num_rows($query1_exec); echo ' '.$num.' '; if (mysql_num_rows($query1_exec) == 0) Change this to: $num=mysql_num_rows($query1_exec); echo ' '.$num.' '; if ($num == 0) Link to comment https://forums.phpfreaks.com/topic/229350-column-count-doesnt-match-value-count-at-row-1/#findComment-1181756 Share on other sites More sharing options...
PFMaBiSmAd Posted March 2, 2011 Share Posted March 2, 2011 I'm going to guess that since you echoed $query2, that you probably found what was causing the problem when you looked at what the actual query was? Link to comment https://forums.phpfreaks.com/topic/229350-column-count-doesnt-match-value-count-at-row-1/#findComment-1181795 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.