[Update]
Sorry guys, after posting this I noticed in the thread the $_POST was highlighted as being out because of the ', didn’t notice it on NotePad++. I’ve now fixed it by removing the ’ and its working.
Since I am here can I ask if anyone can recommend a good book, or some good tutorials for a absolute beginner for mySQLi. I keep stumbling upon old methods of doing things rather than MySQLi.
Thanks all.
First of all hello everyone, this is my first post on the site.
I am looking to learn PHP, so started off with buying a PHP book which was working and understanding well. As soon as it jumped into PHP in MySQLi I lost any sense, if anything confused me even more, syntax’s are different, then to mix it up there is a procedural way and PDO way both with different way of doing things. I’ve spent several hours on reading why some people like PDO and why some people don’t, could not find any PHP specifically teaching MySQLi, so I am hoping you can help me on this.
Below is a form I was trying to build, self practice from the book. Now whilst I could get the old version to work, I can’t get it to work in MySQLi.
When I enter $_POST[‘user’] etc I get an error and it doesn’t work, but if I enter a string ‘dave’ it works.
Can you please explain why $_POST[‘user’] worked in the old version but not in MySQLi? What should it be?
[php]
<?php include "connect.php"; $con=mysqli_connect("$dbserver","$dbuser","$dbpass","$db"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // Perform queries if ( isset($_POST['submit']) ){ mysqli_query($con,"INSERT INTO members (name,password,email) VALUES ('$_POST['name']','$_POST['name']','$_POST['name']')"); }; mysqli_close($con); ?> Username:Password:
Email:
[/php]