I have been fighting with this for half an hour now and can not figure it out. i have used SET instead of values and anything else i can think of. Here’s the sql Code.
try
{
$queryCheck = 'SELECT * FROM users WHERE email=:email';
$s = $dbconnect->prepare($queryCheck);
$s->bindValue(':email', $email);
$emailAllreadyInUse = $s->rowCount();
}
catch(PDOException $e)
{
$error = 'Error adding your account: ' . $e->getMessage();
exit();
}
if ($emailAllreadyInUse > 0)
{
echo 'That email is allready in use. Please Use a different email';
}
else {
try
{
$query = 'INSERT INTO users (
`email`,
`password`,
`nameFirst`,
`nameLast`,
`farmName`,
`joinDate`,
`groupNum`
) VALUES (
:email,
:password,
:nameFirst,
:nameLast,
:farmName,
:date,
:groupNum
)';
$s = $dbconnect->prepare($sql);
// Bind the Values
$values = array('email' => $email, 'password' => $password, 'nameFirst' => $nameFirst, 'nameLast' => $nameLast, 'farmName' => $farmName, 'date' => $date, 'groupNum' => $groupNum);
$s->execute($values);
}
catch(PDOException $e)
{
echo '<p class=\\"DB_Error\\">There was an error adding your account please try again latter</p>';
}
echo '<p class=\\"username\\">You can now log in with the email '.$email.' and your chosen password';
}
The only thing i think it may be is the checking to see if the email already exists. Not sure. I am sure some one well be able to pick what ever is. Unless GroupNum is causing the issue with mysql?
Well a there is no error given. So even if the error echo code was there it would be of no help. As PHP is displaying the code that makes it seem like everything went trhough
Ok so i ran it using mysql in php and it gave me this error However in PDO i did not receive any error
here’s the error
Error: (1064) 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 '@gmail.com, a456ad5fa2f1d5g6f45h4sde3b0c44298fc1c149afbf4c8996fb92427ae4' at line 10
and here’s the (gimped up pdo is so much better then mysql commands) version of the query
standard sql calls for single quotes, but mysql allows the use of doublequotes to delimit strings (which otherwise would be used to delimit identifiers such as column names)