I’ve tried using this tutorial but it doesn’t work:
I’ve copied and pasted 100% of the code so there should be no problems. Though after running a test i get the error message saying couldn’t enter data:
It doesn’t look that way to me.
Compare the INSERT lines.
Please note that although that tutorial may be OK (and that is debatable) as it is for beginning localhost learning purposes, it is something that is not suitable for use on a live site.
I wouldn’t even consider it suitable for that - both the HTML and PHP need to be thrown away and redone properly before use. Both are good examples of how NOT to code.
And I agree, depending on what is supposedly being taught learning something that will need to be unlearned is of highly questionable value.
About the only value I can see with the tutorial is that it can provide “low hanging fruit” evidence that the database can be successfully connected to.
It does not connect that’s the thing, I ran it and it came back with an error it’s why I’ve posted this topic in the first place.
If you know of any tutorials i could follow which is similar to this, is coded a hell of alot better and actually works please post.
Well the code for connecting to the database is the only part of what you posted that is coded correctly - so if it isn’t connecting then the problem must lie elsewhere (such as the user or password not matching)
Well i can login to phpmyadmin with the same U&P from what the tutorial said it’ll be the same U&P for phpmyadmin and the connection.php, unless that tutorial is wrong? (Note that i’ve removed the password from the above example)
That is after all the junk code that you have between the connection call. You should first check if the connection is actually working and then replace that junk code with proper validation for the inputs and then a proper database call using prepare/bind/execute in place of query.
Even if you are just going to continue testing the junk code we still need to know whether the connection actually worked and what the query actually looks like (as you didn’t post the query code properly above).
From reading the reply’s above I’ve removed the php code from my webserver, and I’ve tested SQL commands within phpmyadmin and data does submit into the database. So atleast I know for sure phpmyadmin works. Though if you know of any good tutorials please link them, I’ll be most grateful.
Yeah as expected I got the successful connection: Success: A proper connection to MySQL was made! The my_db database is great. Host information: 127.0.0.1 via TCP/IP, I think what the problem is that the tutorial was based on an older version of php, im currently using php7.