last day (15 days later) » 

10:12
0
A: Could someone explain why my php script isnt working?

user3647971mysqli_query method returns object, not an array. So to be able to read the results you have to fetch it first: $result = mysqli_query($mysqli, "SELECT attempts FROM users WHERE username = '".$_POST['username']."'"); $row = mysqli_fetch_assoc($result);{ //yeah. if (isset($_POST['login'])){ i...

This is the answer.
I can't comment yet, so answering was the only solution
I meant that this is a correct answer (it seems to) even if the OP should use PDO.
it just screws up my page, before: prntscr.com/hyvq2e after adding this: prntscr.com/hyvqh1
There's a leak, some unclosed { bracket
10:12
Why a while loop when you only expect one result?
using your updated code, not seeing any unclosed brackets or anything of the sort whatsoever. Changing $result->fetch_assoc() to mysqli_fetch_assoc($result) fixes the page, but not the redirection problem.
header("Location: /ase/index.php?url=locked"); how about this?
I use while because when you first write it you expect one result. But you might change it for whatever reason and it's not heavier to run with while
well, @user3647971 the link to the page isnt the problem, its something with the statement im assuming? not correctly reading the database output. my attempts column is set as an INT(1), and as i said in original post, the sql to add the attempt works fine, just never redirects after 3 attempts, it would throw an error if the page isnt found. right?
Might be a dumb question, but is the POST['login'] set? Meaning you have a field named "login" in the form you are sending to that php
<button type="submit" class="btn btn-primary pull-right" name="login">Login</button> full page is here: starting on line 67 pastebin.com/eCfH4gWf
10:12
Well there's only 2 actual cases here. if(isset($_POST['login'])) or the attempt count isn't retrieved from the database
Might be far fetched, but try to add value="1" for that button. Just a suggestion
"I use while because [...] you might change it for whatever reason [...]" – You write more complicated code than you need because down the line you might need to change it to handle a completely different use case which won't be handled by the current code anyway (your code is useless to handle more than one result)?! That's the most bizarre reasoning I've ever heard. You're well on your way to en.wikipedia.org/wiki/Inner-platform_effect with that thinking.
What is your problem it's way more readable when you have to read thousands of lines of queries and php and don't have to look for that one that doesn't have while
There you go, the system worked. Your answer improved considerably now.
You should at least explain to me how using a while while fetching query row's is going to change my thinking for the worse and make my code " slower, poorly coded and less reliable"
It's simply absolutely superfluous. It doesn't do anything. That combined with your reasoning that you may adapt it in the future to maybe do something useful is just… weird. You should always strive to write the code that does exactly what you need. You can make any code more complicated; the art is to make it precise. Any additional line of code increases the likelihood of bugs. That's not just ideological babble, it's actually reality. While this particular sample wasn't egregious, it looked symptomatic.
10:12
You haven't met employer that changes it's mind to what they want the code to do? Wow, but point taken. I'm don't code like you describe me to code. That was just an example trying to help out with the actual problem
Believe me, I have met such employers and customers. And again, your while loop didn't adapt to any future changes, you would still have needed to further adjust the code to deal with more than one result. So it didn't even accomplish the goal of future-proofing.
You just keep picking on that while loop. It's fixed as you would say
Well, you keep wanting to justify it… :P

last day (15 days later) »