David Gerler wrote:
>>David Gerler wrote:
>>
>>>Hi all,
>>>     I have a script that runs an SQL query and sends an email
>>
>>using sendmail.
>>
>>>It works fine if called using a browser. The email is sent with
>>
>>the correct
>>
>>>content in the message.
>>>     If I run it using cron, I get the message but the content
>>
>>is not sent.
>>
>>>Meaning the body of the message is empty. I also get an email
>>
>>from cron that
>>
>>>contains and error message:
>>>-----------
>>>DBD::mysql::db do failed: You have an error in your SQL syntax
>>
>>near '' at
>>
>>>line 1 at /home/ezbid/www/cgi-bin/ua/includes/close_item.pl line 248.
>>>----------
>>>
>>>     Can anybody give me some insight as to why I get an error when cron
>>>executes the script, but when I do it in a browser it works fine.
>>>
>>>     Any help is appreciated.
>>>
>>>David Gerler
>>>Gerler Enterprises
>>>PO BOX 16357
>>>Chesapeake VA 23328
>>>http://www.GerlerEnterprises.com/
>>>
>>>Nationwide Dial-up from $12.45
>>>http://www.EasySitesForLess.com/
>>>
>>>
>>>
>>>
>>
>>I ( we ) would need to see the script(s) that cron is calling to help
>>out. However, I get that DBD error all the time :-) .. are you sure your
>>sql statement is correct?
>>
>>Thanatos
>>
> 
> The script runs when called from a browser so I was thinking that it had to
> do with the differences in how apache and cron worked or something like
> that, so I didn't include the code. I will include the code below:
> 
> This is the sql statement from line 248:
> $db->do("UPDATE Members SET won=won + 1 WHERE usernum=$biddernum");
> 
> This is the job I set in cronjobs:
> * * * * *   /home/ezbid/www/cgi-bin/ua/item.pl?item=958 > /dev/null
> 
> I'm new to SQL also, so could the spaces around the "+" be the problem?
> 
> Dave
> 
> 
> 

Thanks Dave,

 From the looks of the SQL statement, won is an integer and you want to 
add one to it. When I do that I get the current value of won from the db 
, assign the value to a variable ( like $won ) and then do a ("update 
Memebers SET won='" . ( $won + 1 ) . "' WHERE ..." ).

Also, is $biddernum defined and does it contain a value? Is it possible 
that it could contain special characters, like a ' or "? If so, the you 
can use $new_biddernum = $db->quote( $biddernum ) so that the special 
chars are taken care of for you.

For an explaination of $db->quote, do a man DBI and search for quote.

Does any of that help?
Thanatos



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to