Reputation: 67
I don't know why, but my data doesn't go into my database 'users' with the table 'data'.
<html>
<body>
<?php
date_default_timezone_set("America/Los_Angeles");
include("mainmenu.php");
$con = mysql_connect("localhost", "root", "g00dfor@boy");
if(!$con){
die(mysql_error());
}
$usrname = $_POST['usrname'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$password = $_POST['password'];
$email = $_POST['email'];
mysql_select_db(`users`, $con) or die(mysql_error());
mysql_query(INSERT INTO `users`.`data` (`id`, `usrname`, `fname`, `lname`, `email`, `password`) VALUES (NULL, '$usrname', '$fname', '$lname', '$email', 'password')) or die(mysql_error());
mysql_close($con)
echo("Thank you for registering!");
?>
</body>
</html>
All i get is a blank page.
Upvotes: 0
Views: 944
Reputation: 344511
It looks like you need to enclose the query you give to mysql_query()
in double quotes1:
mysql_query("INSERT INTO ... ");
You also need to terminate your call to mysql_close()
with a semicolon, as others pointed out.
1 The same applies for mysql_select_db()
, as @marcog pointed out in the comment below.
Upvotes: 2
Reputation: 7128
because of this line
mysql_close($con)
you forgot semicolon
mysql_close($con);
Upvotes: 1