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>"; } } Link to comment https://forums.phpfreaks.com/topic/113037-solved-unknown-column-06ju06e1-in-where-clause/ 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!) Link to comment https://forums.phpfreaks.com/topic/113037-solved-unknown-column-06ju06e1-in-where-clause/#findComment-580665 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. Link to comment https://forums.phpfreaks.com/topic/113037-solved-unknown-column-06ju06e1-in-where-clause/#findComment-580666 Share on other sites More sharing options...
bluejay002 Posted July 3, 2008 Share Posted July 3, 2008 Homerun! score goes to DarkWater! Link to comment https://forums.phpfreaks.com/topic/113037-solved-unknown-column-06ju06e1-in-where-clause/#findComment-580667 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 Link to comment https://forums.phpfreaks.com/topic/113037-solved-unknown-column-06ju06e1-in-where-clause/#findComment-580668 Share on other sites More sharing options...
MasterACE14 Posted July 3, 2008 Share Posted July 3, 2008 show of DarkWater Link to comment https://forums.phpfreaks.com/topic/113037-solved-unknown-column-06ju06e1-in-where-clause/#findComment-580669 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. Link to comment https://forums.phpfreaks.com/topic/113037-solved-unknown-column-06ju06e1-in-where-clause/#findComment-580670 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. Link to comment https://forums.phpfreaks.com/topic/113037-solved-unknown-column-06ju06e1-in-where-clause/#findComment-580673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.