0

so I'm making a website and one of my pages needs me to use php which I am very new to, I used XAMPP to make the page and it was working but once I uploaded it, the page stopped working since mysqli_query() keeps returning false.

Yes, I checked my connection to my database and I also tested my mysql queries on phpmyadmin and they work completely fine.

        <div class="dbOUTPUT">
            <ul>
                <?php
                    $sql = "SELECT * FROM `moon`;";
                    $result = mysqli_query($conn, $sql);
                    if($result){
                        if(mysqli_num_rows($result) > 0){
                            $i = 1;
                            while($rows = mysqli_fetch_assoc($result)){
                                echo "<li><form action='DBConnection/deleteIntoMoon.php' method=POST>";
                                echo "<div class='listItem'>{$rows['locations']}";
                                echo "<button type='submit' name='submit' value='{$i}'>X</button>";
                                echo "</div></form></li>";
                                $i++;
                            }
                        }else{echo 'error in mysql';}
                     }
                ?>
            </ul>
        </div>

This code results in the following: "error in mysql" from the else statement.

I know this isn't the most efficient code but any help would be appreciated:)

  • change to $sql = "SELECT * FROM moon"; and see the result (please also check whether the table name is moon. In particular the capital / small letters) – Ken Lee Dec 31 '20 at 12:39
  • 2
    If you're seeing **error in mysql**, it implies that it's the mysqli_num_rows check that's failing. Are there definitely rows in the table? – iainn Dec 31 '20 at 12:39

0 Answers0