Jump to content

PHP and MSSQL


everstudios

Recommended Posts

Hello Everyone,

I'm having trouble Inserting a variable into a 'money' feild.

i am passing a variable allong called $total.

WHen it comes time to insert into my database, i use

[code]
$result = mssql_query(" INSERT INTO $Table_Activity
(
SEQN,
ID,
ACTIVITY_TYPE,
Product_code,
TRANSACTION_DATE,
DESCRIPTION,
NOTE,
UF_1,
UF_2,
EFFECTIVE_DATE,
THRU_DATE,
AMOUNT,
ACTION_CODES)

VALUES (
'$seqn',
'$id',
'ADS',
'$newarray[$insertcount], WEB',
'$inserttoday',
'$category',
'$class_city. $class_ad',
'$class_city',
'$cardtype',
'$inserttomorrow',
'$insertnextmonth',
'$total',
'$words')");
[/code]

when i do that, i get an error because the AMOUNT feild is a Money Type and my variable is not.

My Question is how do i convert my $total variable into something that the money feild will accept. I tried reading up on the CONVERT funtion for SQL, but not getting far wtih it. Is there an easy way to do this?
Link to comment
https://forums.phpfreaks.com/topic/3781-php-and-mssql/
Share on other sites

Thanks for replying, the code you gave me converted the number into a currency but the SQL insert code is still not accepting it for a Money field. Do you have any other ideas. The error i am getting is:

Warning: mssql_query(): message: Disallowed implicit conversion from data type varchar to data type money, table 'camft.dbo.Activity', column 'AMOUNT'. Use the CONVERT function to run this query. (severity 16) in C:\Inetpub\vhosts\camftads.com\httpdocs\mssql\7.php on line 578

So i need to use the convert funtion in SQL, but i don;t know how to use that in the code i gave above. Thanks
Link to comment
https://forums.phpfreaks.com/topic/3781-php-and-mssql/#findComment-13168
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.