привет, ребята, у меня есть этот код в файле pp.php
<?php
class system{
public function register() {
if ($_POST) {
if ($_POST['password'] == $_POST['reppassword']) {
if ($_POST['email'] == $_POST['repemail']) {
$logdb = new PDO('mysql:host=localhost;dbname=kikojust', 'kikojust', '123456');
$logdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $logdb->prepare('INSERT INTO usreg
(email, password, firstname, lastname, phone, mobile, adress, city, postalcode, country)
VALUES
(:email, :pass, :fname, :lname, :phone, :mobile, :adress, :city, :code, :country');
$stmt->bindParam(":email", $_POST['email'],PDO::PARAM_STR, 20);
$stmt->bindParam(":pass", $_POST['password'],PDO::PARAM_STR, 20);
$stmt->bindParam(":fname", $_POST['firstname'],PDO::PARAM_STR, 20);
$stmt->bindParam(":lname", $_POST['lastname'],PDO::PARAM_STR, 20);
$stmt->bindParam(":phone", $_POST['phone'],PDO::PARAM_STR, 16);
$stmt->bindParam(":mobile", $_POST['mobile'],PDO::PARAM_STR, 16);
$stmt->bindParam(":adress", $_POST['adress'],PDO::PARAM_STR, 50);
$stmt->bindParam(":city", $_POST['city'],PDO::PARAM_STR, 10);
$stmt->bindParam(":code", $_POST['postalcode'],PDO::PARAM_STR, 10);
$stmt->bindParam(":country", $_POST['country'],PDO::PARAM_STR, 14);
$stmt->execute();
echo 'You have being well donne registered, go to <a href="index.php">Login</a> to enter in our site';
} else {
echo 'Go back to <a href="register.php">Register</a> and check your Email';
}
} else {
echo 'Go back to <a href="register.php">Register</a> and check your password.';
}
} else {
echo '
<html>
<head>
<title>
Register!
</title>
</head>
<body>
<form name="login" action="" method="POST">
First Name:
<input type="text" name="firstname"/>
Last Name:
<input type="text" name="lastname"/>
<br />
Password:
<input type="password" name="password"/>
Repeat Password:
<input type="password" name="reppassword"/><br />
<br />
Email:
<input type="text" name="email"/>
Repeat Email:
<input type="text" name="repemail"/><br />
<br />
Phone:
<input type="tel" name="phone"/>
Mobile:
<input type="tel" name="mobile"/><br />
<br />
Adress: <br />
<input type="text" name="adress"/><br />
City: <br />
<input type="text" name="city"/><br />
Postal Code: <br />
<input type="text" name="postalcode"/><br />
Country: <br />
<input type="text" name="country"/><br />
<button type="submit">Register</button>
</form>
</body>
</html>';
}
}
}
и у меня есть это в register2.php
<?php
require_once 'Inc/pp.php';
$login = new system;
$login->register();
и проверка прохода и проверка почты работают нормально и все выглядит нормально до той части что идет на вставку, выдает мне эту ошибку
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 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 '' at line 4' in
/home/kikojust/public_html/Inc/pp.php:26 Stack trace: #0
/home/kikojust/public_html/Inc/pp.php(26): PDOStatement->execute() #1
/home/kikojust/public_html/register2.php(4): system->register() #2 {main} thrown in
/home/kikojust/public_html/Inc/pp.php on line 26
но я не понимаю, в чем проблема, потому что предложение stmt подготовлено и привязано, но не запускается, все записи верны, как в таблице, и если я запускаю тот же sql в консоли sql, все идет хорошо, что не так мой код, ребята, вы можете мне сказать? спасибо
);"
? - person Max   schedule 12.07.2014VALUES
части вашего запроса. - person Jonathan Kuhn   schedule 12.07.2014