Try one of these instead:
$alumni->fetchAll(
$table->select()->where('alumni_Email = ?', $alumniEmail)
);
OR, just quote the value
$row = $alumni->fetchAll(
'alumni_Email = ' . $dbAdapter->quote($alumniEmail)
);
The problem is your $alumniEmail is not getting passed to the query as a
qouted value.
-ralph
Erdal YAZICIOGLU wrote:
> Hello all
>
>
>
> I am trying to create a registration form with ZF1.8. After user enters
> his email, I want to check whether that email address is already
> registered or not. But everytime I am having a MySQL synax error.
>
>
>
> The code is
>
> if($form->isValid($formData))
>
> {
>
> $alumniName = $form->getValue('alumni_Name');
>
> $alumniLastName = $form>getValue('alumni_LastName');
>
> $alumniEmail = $form->getValue('alumni_Email');
>
> $alumniPassword = $form->getValue('password');
>
> $alumniGraduateDate =
> $form->getValue('alumni_GraduateDate');
>
> $alumniMemory= $form->getValue('alumni_Memory');
>
> $alumni = new Model_DbTable_Alumni();
>
> $row = $alumni->fetchAll(' alumni_Email = ' .
> $alumniEmail);
>
> if(count($row>0))
>
> {
>
> throw new Exception('This email is already
> registered');
>
> }
>
> else {
>
>
> $alumni->registerAlumni($alumniName,$alumniLastName,$alumniEmail,$alumniPassword,$alumniGraduateDate,$alumniMemory);
>
> }
>
>
>
>
>
> }
>
> else {
>
> $form->populate($formData);
>
>
>
> }
>
>
>
> The error I am having is
>
> *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 '@gmail.com)
> LIMIT 1' at line 1
>
>
>
> I have lots queries running the same way. Is there any problem in the
> code that you can see but I can not..
>
>
>
> Regards
>
> E
>
没有评论:
发表评论