Jump to content

Column count doesn't match value count at row 1


sunilpaladugu

Recommended Posts

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

 

 

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());

}

?>

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)

 

 

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.