0

First Question on Stack OverFlow, here it goes:

I've been working on the SQL statement list below and it works great when I change nothing and stick into MySQL workbench but when I try to use it with MySQLi, nothing happens, like no errors or anything just blank. I've done echos everywhere to pinpoint where this is happening. It works great when I remove the GROUP BY part so I know it's talking to the DB. Am I missing something?

I would include a screenshot but the webpage is just blank.

$sql = "SELECT ConsumerItem.itemName, ConsumerItemMod.currentLocation, ConsumerItem.itemType, ConsumerItem.itemQuantity, ConsumerItemMod.dateModified, ConsumerItem.itemID
            FROM ConsumerItemMod
            INNER JOIN ConsumerItem ON ConsumerItemMod.itemID = ConsumerItem.itemID
            AND ConsumerItemMod.userAccountNumber = '2' and ConsumerItemMod.currentLocation = '1'
            GROUP BY ConsumerItem.itemID";

if($result = mysqli_query($INconn, $sql)){
    if(mysqli_num_rows($result) == 0){
}else {
while($row = mysqli_fetch_array($result)){
            echo $row['itemName'];
        }
  • Your query is invalid (though it might actually run on your MySQL, depending on settings). You should add sample input data and the expected output. – Tim Biegeleisen Mar 29 '21 at 07:57
  • I am closing this question as a duplicate which is relevant to the question title. While in order to get the actual error, refer to [this answer](https://stackoverflow.com/a/22662582/285587) – Your Common Sense Mar 29 '21 at 08:01
  • In short, this query is working not that great because ConsumerItem columns are undetermined and actually returned at random – Your Common Sense Mar 29 '21 at 08:12

0 Answers0