Clinton Posted July 3, 2008 Share Posted July 3, 2008 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>"; } } Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 You need ' ' around $datecode inside the query because it's a string. (I knew the problem before I even clicked the title. Score!) Quote Link to comment Share on other sites More sharing options...
Clinton Posted July 3, 2008 Author Share Posted July 3, 2008 LoL. You're good. I don't care what the rest of the people write about you here... you are good. Quote Link to comment Share on other sites More sharing options...
bluejay002 Posted July 3, 2008 Share Posted July 3, 2008 Homerun! score goes to DarkWater! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 @hunna03: Thanks! I think. (Click Topic Solved, btw) @bluejay002: DarkWater: 1 The Rest of Planet Earth: 0 Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted July 3, 2008 Share Posted July 3, 2008 show of DarkWater Quote Link to comment Share on other sites More sharing options...
Clinton Posted July 3, 2008 Author Share Posted July 3, 2008 It was a good thing... ... and sorry... I forgot. It's early. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.