Gossamer Forum
Quote Reply
SQL Update
I seem to be having problems updating a column.

I'm using:

$obj->update( { Col => Val }, { Username => $USER->{Username} } );

$USER->{Username} prints "Paul" but the update never happens.

Any ideas?

I have:

my $obj = $DB->table('Users');

Last edited by:

PaulW: Dec 3, 2001, 6:03 AM
Quote Reply
Re: [PaulW] SQL Update In reply to
Try adding

or die "Can't update: $GT::SQL::error";

after the update. You can also do:

print GT::SQL->query_stack_disp;

to print out a list of all sql queries that have been run (only works with debug >= 1).

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] SQL Update In reply to
I'll give that a go thanks.

I should have thought of that earlier.
Quote Reply
Re: [Alex] SQL Update In reply to
Yikes:

Can't update: Failed to execute query: 'UPDATE lsql2_Links SET ' Reason: You have an error in your SQL syntax near '' at line 1 at e:/apache/cgi-bin/lsql2/admin/Plugins/MyLinks_SQL/Favorites_DB.pm line 82.

I'm using:

$db->update( { Col => 1 }, { Username => 'Paul' } );
Quote Reply
Re: [PaulW] SQL Update In reply to
Hi,

Is 'Col' a valid column?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] SQL Update In reply to
Yeah sorry that was just an example, it is called Fave and yes it exists.

Username varchar(50) DEFAULT '' NOT NULL ,
Password varchar(25) binary DEFAULT '' NOT NULL ,
Email varchar(75) DEFAULT '' NOT NULL ,
Name varchar(75) ,
Validation varchar(20) ,
Status enum('Not Validated','Registered','Administrator') DEFAULT 'Registered' NOT NULL ,
ReceiveMail enum('No','Yes') DEFAULT 'Yes' NOT NULL ,
Newsletter enum('No','Yes') DEFAULT 'Yes' NOT NULL ,
Fave varchar(255) ,
PRIMARY KEY (Username),
KEY emailndx (Email)

The exact code is:

$db->update( { Fave => 1 }, { Username => 'Paul' } ) or die "Can't update: $GT::SQL::error";

Last edited by:

PaulW: Dec 3, 2001, 2:08 PM