jackh Posted December 15, 2016 Share Posted December 15, 2016 Hi all, I'm trying to execute a query which uses the value from my session which is set when the user logs in. When I try to view the query, it displays nothing. SQL statement // get value of session $username = $_SESSION['username']; // executeable query $sql = ("SELECT * FROM custstock WHERE username = '$username'"); // query $row = mysqli_query($custdb, $sql) or die(mysqli_error($custdb)); The code for my table; <table width="100%" border="1" cellpadding="1" cellspacing="1" class="carInfo"> <tr> <th>ID</th> <th>Vehicle ID</th> <?php while($custveh = mysqli_fetch_assoc($row)){ echo "<tr>"; echo "<td>".$custveh['id']."</td>"; echo "<td>".$custveh['vehID']."</td>"; echo "</tr>"; } ?> </table> Any suggestions would be great, thanks! Jack Link to comment Share on other sites More sharing options...
Ingolme Posted December 15, 2016 Share Posted December 15, 2016 Have you determined that $_SESSION['username'] exists and has a value? Link to comment Share on other sites More sharing options...
jackh Posted December 15, 2016 Author Share Posted December 15, 2016 Yeah, the session is set from the login screen along with the users name which I echo on each page and works fine. Link to comment Share on other sites More sharing options...
Ingolme Posted December 15, 2016 Share Posted December 15, 2016 Print out the value of $sql to see what it's doing 1 Link to comment Share on other sites More sharing options...
jackh Posted December 15, 2016 Author Share Posted December 15, 2016 Print out the value of $sql to see what it's doing I echoed the value and still wasn't working - had a look at my query and it was because I used a capital in the name! So simple. Thanks for your help Foxy Mod! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now