Could not execute query: 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 ''users' (Username, Password, FullName, Address1, Address2, Cit
this is the query
$sql = "INSERT INTO 'users'
(Username, Password, FullName, Address1, Address2, City, County, Country, Email, LastLogged, Limit)
VALUES
('$Username', PASSWORD('$Password'), '$FullName', '$Address1', '$Address2', '$City', '$County', '$Country', '$Email', '$datereg', '$lim')";
These are the names of the columns in my table named users
Username, Password, FullName, Address1, Address2, City, County, Country, Email, LastLogged, Limit
PineSolPirate
03-16-2007, 10:58 AM
Don't quote your table name.
$sql = "INSERT INTO users
(Username, Password, FullName, Address1, Address2, City, County, Country, Email, Las...
Marcus Maximus
03-16-2007, 11:00 AM
didn't work unquoted and Still doesn't work unquoted
Marcus Maximus
03-16-2007, 12:06 PM
Heres all the code
connection
#connect to MySQL
$conn = @mysql_connect("localhost", "#","#")
or die("Could not Connect");
#select the specified database
$rs = @mysql_select_db("#", $conn)
or die("Could not select specified");
<hr>
<?include("register.inc");?>
</body>
</html>
<?}
#################################
function checkuser($Username)
{
if($Username == ""){
echo("<font color=RED>Username must be filled in<br></font>");
return false;
}
else
return true;
}
function checkexists($Username)
{
$sqll = "select Username from users where Username = '".addslashes($Username)."'";
include("connection.php");
#execute the query
$qrr = mysql_query($sqll, $conn)
or die ("Could not execute query: ".mysql_error());
#get number of rows that get usernames and passwords
$num = mysql_num_rows($qrr);
#if there is a match the login is authenticated
if($num >= 1){
echo("<font color=RED>Username: $Username already exists on the database please select another<br></font>");
return false;
}
else
return true;
}
function checkpass($Password, $ConfirmP)
{
if($Password == "" || $ConfirmP == ""){
echo("<font color=RED>Password and Confirm Password must be filled in<br></font>");
return false;
}
else
return true;
if($Password != $ConfirmP){
echo("<font color=RED>Password must match Confirm Password<br></font>");
return false;
}
else
return true;
}
function checkname($Fullname)
{
if($Fullname == ""){
echo("<font color=RED>Fullname must be filled in<br></font>");
return false;
}
else
return true;
}
function checkemail($Email)
{
if($Email == ""){
echo("<font color=RED>Email must be filled in<br></font>");
return false;
}
else
return true;
}
function checkEmailexists($Email)
{
$sqll = "select Email from users where Email = '".addslashes($Email)."'";
include("connection.php");
#execute the query
$qrr = mysql_query($sqll, $conn)
or die ("Could not execute query: ".mysql_error());
#get number of rows that get usernames and passwords
$num = mysql_num_rows($qrr);
#if there is a match the login is authenticated
if($num >= 1){
echo("<font color=RED>Email Address: $Email already exists on the database please select another<br></font>");
return false;
}
else
return true;
}?>
hlaiken
03-16-2007, 02:52 PM
The table name "users" should definitely NOT be quoted.
I'm a little rusty on my SQL syntax, but you may be having some issues with the SQL PASSWORD() function. First of all, it is my understanding that that function is not necessarily intended for encrypting passwords for web applications. Unless you plan on using the data in the database between different web languages, I would suggest that you encrypt the password through PHP. This brings me to my next suspicion (again it's been a while) that you may not be able to use the PASSWORD() function within the VALUES bracket.
What I typically do when I throw SQL errors is to run the query in QUANTUM DB (an Eclipse IDE plugin) to verify the query syntax. (Or you can try the queries out in myPHPAdmin or something like that...)
Anyway, just some suggestions. When you solve the problem, please post back to let us know what the solution was.
Marcus Maximus
03-16-2007, 03:10 PM
Don't know why but it works when i take out the limit value
On the database it is set as
Limit int(20) NOT NULL
$sql = "INSERT INTO users
(Username, Password, FullName, Address1, Address2, City, County, Country, Email, LastLogged)
VALUES
('$Username', PASSWORD('$Password'), '$FullName', '$Address1', '$Address2', '$City', '$County', '$Country', '$Email', '$datereg')";
Any suggestions why
polorboy
03-16-2007, 03:17 PM
Limit does have a meaning all its own in MySQL. You usually set something like "SELECT * FROM table_name WHERE column_name = 'column_value' LIMIT 1", the LIMIT 1 will only return one row from the table containing the column value you set. It might be getting confused with what you mean by LIMIT and what it means by LIMIT.
Marcus Maximus
03-16-2007, 06:12 PM
cheers i never new limit was a key word in mysql
webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved.