Jump to content

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)

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.