+ 2
How do i fix this
I want to know how to fix this error on this page : https://naijalife.000webhostapp.com/good.php I used this code : https://code.sololearn.com/ww724T97Rsz2/?ref=app
13 Answers
+ 3
Joseph,
<$result> is a mysqli_result instance (an object in short), so we can't just go and concatenate strings with it. Try to change line 24 to not to mix <$result> with string for output.
echo "Error in query:<br>".$mysqli->error;
+ 2
you just posted database credentials online. I would quickly change them if your db is accessible by the internet
+ 2
well the script doesnât output anything, and if i go to your page I indeed only see a white page
+ 2
Joseph,
Can you tell what error message you got when running that code on your side? without this information, it is rather hard to isolate the problem.
+ 2
Thanks
+ 2
Not a problem đ
Did it work though Joseph?
+ 2
the if else statement on line 20 and 23 doesnât make much sense.
The if statement checks if the username already exists, so far so good. However, if it doesnât exist it proceeds to print the error message that there is an error in the query?? why?
Canât you get rid of the else statement?
+ 2
Also you donât need to fetch the last id in the table. you can set the id column to primary and autoincrement and then just leave the id out of the INSERT statement.
+ 1
So do know what's wrong
+ 1
It was something like, fatal error: uncaught object of class mysqli_result not converted to string on line 24
+ 1
Be aware to read up on something called sql injection and prepared statements in the future.
if someone would have their username as "; DELETE FROM accounts; â
They could for instance delete your whole accounts table
+ 1
never mind, I see youâre using real_escape_string. That also works