Jump to content

[SOLVED] Unknown column '06JU06E1' in 'where clause'


Clinton

Recommended Posts

I've googled the problem but everybody else's solutions is working for mine. Not sure what's wrong.

 

Error: Unknown column '06JU06E1' in 'where clause' (06JU06E1 is $datecode)

 

$sumadd = mysql_query("SELECT datecode,SUM(signin),SUM(signout) FROM transactionlog WHERE datecode = $datecode GROUP BY `datecode`") or die(mysql_error());


$num = mysql_num_rows($sumadd);

if(!$num)

{

echo "No entries have been found for this datecode";

}
else

{

while($row = mysql_fetch_array($sumadd)){

$totaladd = $row['SUM(signin)'];
$totalsubtract = $row['SUM(signout)'];

$grandtotal = ($totaladd - $totalsubtract);



echo "<center>Amount in Magazine = <font color=purple>$grandtotal</font> </center>";

}

}

By the way, hunna, instead of the messy $row['SUM(signin)'], you should alias the functions in the query so it's easier.

 

$sumadd = mysql_query("SELECT datecode,SUM(signin) as in,SUM(signout) as out FROM transactionlog WHERE datecode = '$datecode' GROUP BY `datecode`") or die(mysql_error());

 

Then $row['in'] and $row['out'] will hold the correct values.

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.