Forum Moderators: coopster & phranque

Message Too Old, No Replies

Upadate my database syntax

update syntax

         

shaan1980

12:27 am on Feb 28, 2004 (gmt 0)

10+ Year Member



hi guys i want to update my database with the path to a file on my unix system as well as other things in my database
i am having some trouble witht he syntax
help here is the part of the syntax that i am having a trouble with

if ($filedes="agenda")
{

$path="\'$agendadir/$filedes/$newfilename'";
$date="\'$day-$month-$year\'";

@update=[$path,$date];

my $sth=$dbh->prepare('UPDATE meeting SET AGENDA=? WHERE MEETING_DATE=?') or die "Couldn't prepare stateme\
nt: " . $dbh->errstr;

for (@update)
{
eval
{
$sth->bind_param(1,$_->[0],SQL_VARCHAR);
$sth->bind_param(2,$_->[1],SQL_DATE);
}
$sth->execute()or die "Couldn't execute statement: " . $sth->errstr;
$dbh->commit();

}

SeanW

2:45 am on Feb 28, 2004 (gmt 0)

10+ Year Member



What doesn't work? Nothing looks obviously wrong to me, though I'd shorten it to

[perl]
my $sth=$dbh->prepare('UPDATE meeting SET AGENDA=? WHERE MEETING_DATE=?') or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->execute(@update)or die "Couldn't execute statement: " . $sth->errstr;
[/perl]

On second glance, you're adding explicit quotes to your strings and then using bind_params()... You shouldn't need that. Just define them normally, ie

[perl]
$date="$day-$month-$year";
[/perl]

Sean

shaan1980

5:57 pm on Feb 28, 2004 (gmt 0)

10+ Year Member



hi guys that still didn't clear my problem
the page keeps giving an internal server error it doesn't even go on to print out any print statements i placed
my code is pasted below
help me out please thanks
everything before this works fine

$path="$agendadir/$filedes/$newfilename";

print"Iam working till here ";

$date="$day-$month-$year";
my $sth=$dbh->prepare('UPDATE meeting SET AGENDA=? WHERE MEETING_DATE=?') or die "Couldn't prepare statement: " . $dbh->errstr;
print"help";

@update=[$path,$date];
$sth->bind-param(1,$path,SQL_VARCHAR);
$sth->bind-param(2,$date,SQL_DATE);

$sth->execute(@update)or die "Couldn't execute statement: " . $sth->errstr;
print"why is this not working";
$sth->finish();

SeanW

6:26 pm on Feb 28, 2004 (gmt 0)

10+ Year Member



Is this a CGI? In that case, look in your error log. Are you pushing out a content-type?

Sean

shaan1980

6:29 pm on Feb 28, 2004 (gmt 0)

10+ Year Member



yeah this is CGi
i am pushing out content type html in other parts of the program but everything works until this subroutine
i hased out everything above and took out one hash at a time to see where the problem starts
the problem is in the '
prepare statement itself but I am not sure what that error could be