Sorry, I pasted the wrong code. This is the PHP Code for the UPDATE not INSERT:
$sql = "UPDATE prod_opt
SET xref_prod_id = '$prod_id',
code = '$item_code',
title = '$option_format',
isbn = '$isbn',
list_price = $list_price,
our_price = $our_price,
spec_price = $special_price,
spec_start_date = $special_start_date,
spec_end_date = $special_end_date,
quantity = $qty,
clearance = '$clearance',
priority = $priority
WHERE id = '$id'";
$result = pg_exec($dbh, $sql);
Sean
Actually, this does not work, it generates the SQL fine, but I get a Parse error when trying to insert it. I am doing something very similar, did I mess up somewhere.
Here is the PHP:
if ($special_start_date == '')
{$special_start_date = 'null';}
else {$special_start_date = "'$special_start_date'";}if ($special_end_date == '')
{$special_end_date = 'null';}
else {$special_end_date = "'$special_end_date'";}$sql = "INSERT INTO prod_opt (
xref_prod_id,
code,
title,
isbn,
list_price,
our_price,
spec_price,
spec_start_date,
spec_end_date,
quantity,
clearance,
priority)
VALUES (
'".$prod_id."',
'".$item_code."',
'".$option_format."',
'".$isbn."',
".$list_price.",
".$our_price.",
".$special_price.",
".$special_start_date.",
".$special_end_date.",
".$qty.",
'".$clearance."',
".$priority.")";
$result = pg_exec($dbh, $sql);This is the error I get: Warning: PostgreSQL query failed: ERROR: parser: parse error at or near "10"
This is the SQL generated: UPDATE prod_opt SET xref_prod_id = '4', code = '2', title = 'test', isbn = '2', list_price = 2, our_price = 2, spec_price = 2, spec_start_date = '10/01/02', spec_end_date = '10/01/02', quantity = 2, clearance = 't', priority = 2 WHERE id = '2'
-Sean
Eckhard Hoeffner
wrote: * Keary Suska[01 10 02 19:37]:
>on 10/1/02 10:54 AM, dcmkx10@xxxxxxxxx purportedly said:
>
>I am trying to insert a date into a date field, but also sometimes I need to
>insert a null value. Inserting the null value seems to require not using
>quotes around null, but if I try to enter a date without quotes around it,
>it thinks it is a number.
>
>Here is the error I get: Warning: PostgreSQL query failed: ERROR: column
>"spec_start_date" is of type 'date' but _expression_ is of type 'integer' You
>will need to rewrite or cast the _expression_
>
>If I surround the date with single quotes it should be fine, but I can't do
>that when I want to insert a null value. I know that I can do an "IF
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!