2012/7/17 Rob Dixon <rob.di...@gmx.com>

> On 18/07/2012 00:18, Tessio F. wrote:
>
>> Hello,
>> I have an database with a two column primary key:
>>
>> create database contacts(
>> username char(20) not null,
>> contact char(20) not null,
>> primary key (username, contact)
>> );
>>
>> I'm trying to delete a row with the command:
>> (connect to db..)
>> my $sth = $dbh->prepare("DELETE FROM contacts
>>                           WHERE username=? AND contact=?");
>>
>> $sth->execute($name, $contact);
>>
>> But it is not working. To make thing worse, I'm not receiving  any error
>> message either. What is wrong with my code?
>> Thanks for your time!
>>
>
> Hi Tessio
>
> It's almost certainly because your $name and $contact variables don't
> exactly match the username and contact values in the row you want to
> delete.
>
> It isn't an error for the WHERE clause to match no records - you simply
> get a zero value returned from the execute call to say that no rows were
> affected.
>
> Check the values carefully again. If necessary use values that you have
> read from the database as values for the placeholders instead of
> hard-coding the strings.
>
> HTH,
>
> Rob
>
>
Thanks.. The values passed to $sth->execute()  where wrong indeed. The code
works great now!

Reply via email to