Search the Community
Showing results for tags 'die'.
-
Hi, I am having an Issue inputting data into my database with this code. I tested the connection, which works fine, but when I try to submit the form I get the "die("lid query: " . mysql_error());". Any Ideas? <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form action="thispage.php" method="POST"> <input type="text" name="name" placeholder="Check-in Name"> <input type="submit" value='submit'></form> <?php if (isset($_POST['submit'])) { $name = $_POST['name']; $host ="localhost"; $username = "username"; $password = "password"; $dbname = "database"; $con = mysql_connect($host, $username, $password, $dbname); //Check Connection if (!$con) { die("Could not connect: " . mysql_error()); } //Select your database mysql_select_db("database",$con); //Check to make sure the database is there if (!$mysql_select_db) { die ('Can't use the db : ' . mysql_error()); } //Run query $insert = mysql_query("insert into Users(name) values ('$name')"); } //Check Query if (!$insert) { die("lid query: " . mysql_error()); } echo "Data inserted"; mysql_close($con); ?> </body> </html>