Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Query succeeds but no information
    text
    copied!<p>Okay so my code works pretty well so far, it all goes through, my only problem is that when I try and print the unordered list and it's contents I get nothing. When I view my source code I have <code>&lt;ul&gt; &lt;/ul&gt;</code>. There's a space, so surely something is happening.</p> <p>This is my code, I have commented it slightly but what's happening is obvious:</p> <pre><code>$uname = mysqli_real_escape_string($link, $_SESSION['Username']); //Get username ready $sql = mysqli_query($link, "SELECT * FROM users WHERE Username = '" . $uname . "'"); //SQL Query result if(!$sql) { echo "Error retrieving User ID. Please try again. MySQL Error: " . mysqli_error($link); } elseif($row = mysqli_fetch_assoc($sql)) { $uid = $row['UserID']; //Obtain UserID } else { echo "Error: " . mysqli_error($link) . "&lt;br /&gt;" . $uname . " / " . $sql . " / " . $uid; } mysqli_free_result($sql); $sql = mysqli_query($link, "SELECT * FROM auditions"); //Get everything from the auditions table if(!$sql) { echo "Error retrieving auditions. Please try again later. Error: " . mysqli_error($link); } elseif($row = mysqli_fetch_assoc($sql)) { if(mysqli_num_rows($sql)==0) { echo "Sorry, there are currently no open auditions. Please try back at a later date."; } else { echo "&lt;ul&gt;"; while($row = mysqli_fetch_assoc($sql)) { echo "&lt;li&gt;&lt;a href='auditions.php?id=" . $row['AudID'] . "'&gt;" . $row['AudName'] . "&lt;/a&gt;&lt;/li&gt;"; } echo "&lt;/ul&gt;"; } } else { echo "Error: " . mysqli_error($link); } </code></pre> <p>Where am I going wrong? The only thing it doesn't do is actually pick up any results and I've put some data into the table so there are entries! Otherwise it would say there aren't any. I've reversed this so it shows the message if there aren't 0 entries and that works. What am I doing wrong guys?</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload