Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey there,

first time posting, very new to programming so please explain in simple terms.. I am having troubles getting my database to connect to my site.. this is a school assignment i am trying to finish but finding it hard as programming isn't my specialty. When i try to login using accounts i have made using xampp -myphpadmin i get this error

Fatal error: Uncaught mysqli_sql_exception: Unknown column 'lpa_client_username' in 'where clause' in D:\xampp\htdocs\LPA\websystem\LPA\login.php:63 Stack trace: #0 D:\xampp\htdocs\LPA\websystem\LPA\login.php(63): mysqli_stmt_prepare(Object(mysqli_stmt), 'SELECT * FROM l...') #1 {main} thrown in D:\xampp\htdocs\LPA\websystem\LPA\login.php on line 63


what am i doing wrong and is there any easy way to fix this? this is driving my nuts trying to work it out haha

thanks for your time

What I have tried:

i have tried googling the answer, changed username and passwords in myphpadmin, looked at line 63 which says
if (!mysqli_stmt_prepare($stmt, $query)) {
.. makes no sense to me..

cheers
Posted
Updated 24-Oct-22 18:16pm

1 solution

When you get an error message, read it carefully - it contains a lot of information that can help you!
Fatal error: Uncaught mysqli_sql_exception: Unknown column 'lpa_client_username' in 'where clause' in D:\xampp\htdocs\LPA\websystem\LPA\login.php:63
There is a lot of info there:
Fatal error: Uncaught mysqli_sql_exception: 
This can be ignored - it's telling you that it's a fatal error and it can't continue after meeting it instead of a warning which it probably can continue with.
Unknown column 'lpa_client_username' in 'where clause' in D:\xampp\htdocs\LPA\websystem\LPA\login.php:63
There is lots here:
Unknown column
What the problem was
'lpa_client_username'
What column it can't find
in 'where clause'
What part of the the SQL statement was it referred to in
in D:\xampp\htdocs\LPA\websystem\LPA\login.php:
Source code file it found the problem in
63
Line in the file.
The rest of the message you can ignore for a simple problem like this.

So you need to do two things:
1) Go to line 63 of login.php, and find out exactly what SQL command you sent - that'll probably be set on that line, or a few lines above it. What column(s) does your SQL command WHERE clause use? What table(s) does it reference?
2) Go to your database and look at the table definition: what columns does it contain?

Probably, you mistyped the column name, either in your PHP code, or in your database!

We can't fix that for you: we have no access to yoru code, or your data!

This is a syntax error: you should expect to get them every day, probably many times a day while you are coding - we all do regardless of how much experience we have! Sometimes, we misspell a variable, or a keyword; sometimes we forget to close a string or a code block. Sometimes the cat walks over your keyboard and types something really weird. Sometimes we just forget how many parameters a method call needs.

We all make mistakes.

And because we all do it, we all have to fix syntax errors - and it's a lot quicker to learn how and fix them yourself than to wait for someone else to fix them for you! So invest a little time in learning how to read error messages, and how to interpret your code as written in the light of what the compiler is telling you is wrong - it really is trying to be helpful!

So read this: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^] - it should help you next time you get a similar problem!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900