Error with MySQL Query
        Posted  
        
            by 
                Ken
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Ken
        
        
        
        Published on 2011-01-09T02:39:16Z
        Indexed on 
            2011/01/09
            3:53 UTC
        
        
        Read the original article
        Hit count: 294
        
Okay, I must be an idiot, because this is my 3rd question for today. Here's my code:
date_default_timezone_set("America/Los_Angeles");
include("mainmenu.php");
$con = mysql_connect("localhost", "root", "********");
 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()");
$query = ("INSERT INTO `users`.`data` (`id`, `usrname`, `fname`, `lname`, `email`, `password`) 
VALUES (NULL, '$usrname', '$fname', '$lname', '$email', 'password'))");
mysql_query('$query') or die(mysql_error());
mysql_close($con);
echo("Thank you for registering!");
I always get the error returned as: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$query' at line 1. Help a newbie. I'm about to stab my monitor.
© Stack Overflow or respective owner