Front page | perl.dbi.users |
Postings from August 2006
Re: Problem with DBI retrieving data entered
Thread Previous
|
Thread Next
From:
Victor Churchill
Date:
August 10, 2006 16:50
Subject:
Re: Problem with DBI retrieving data entered
Message ID:
6026496c0608101650j40c1f066s779de9570bb7dbf1@mail.gmail.com
On 10/08/06, Russbucket <russbucket@nwi.net> wrote:
> DBD::mysql::st execute failed: 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 1 at insertmember.cgi line 56.
> Code:
> #Insert data
> $sth = $dbh->prepare ("INSERT INTO Moses_Lake_Lions (First_Name, Last_Name,
> Spouse, email, Home_Phone, Business_Phone, Cell_phone, Occupation_Employer,
> Status_Key) Values
> ('$First_Name', '$Last_Name', '$Spouse', '$email', '$Home_Phone', '$Business_Phone', '$Cell_phone', '$Occupation_Employer', '$Status_Key')");
>
> $rv = $sth->execute ();
>
> #Retrieve data enter for verification
> $sth = $dbh->prepare (qq {SELECT First_Name, Last_Name, Spouse, email,
> Home_Phone, Business_Phone, Cell_phone, Occupation_Employer, Status_Key FROM
> Moses_Lake_Lions WHERE Last_Name = $Last_Name}) or dienice ("Cannot prepare
> statement:", $dbh->errstr);
You need to quote the $Last_Name}) in the where clause.
Better to use $dbh->quote rather than do it directly. That also
applies to the Select.
hth
--
cheers,
victor
Victor Churchill, Bournemouth, U.K.
Thread Previous
|
Thread Next