Received: from hapcibeno.freestart.hu (hapcibeno.freestart.hu [213.197.64.8]) by postgresql.org (Postfix) with ESMTP id B3FB847591B for ; Thu, 18 Apr 2002 04:46:37 -0400 (EDT) Received: from line-75-75.dial.freestart.hu ([213.197.75.75] helo=jaguar) by freestart.hu with smtp (Freestart relay 2 (FS-Lin)) id 16y7g7-0008Hu-00; Thu, 18 Apr 2002 10:54:08 +0200 Message-ID: <00e901c1e6b5$dc7e0540$01fdfea9@jaguar> Reply-To: "Papp, Gyozo" From: "Papp, Gyozo" To: "Hillensbeck, Preston" , References: <040AE3A029B3D51181D000508BC75D0201387762@MERCURY> Subject: Re: what to do if a query fails Date: Thu, 18 Apr 2002 10:25:33 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Scanner: exiscan by Freestart X-Archive-Number: 200204/60 X-Sequence-Number: 1084 Hi, I summarized what to do if a query fails. It's advisable to: + var_dump() all variables ($connection, $query and all used in $query) + log your queries to see what postgres tries to do + check the table definition + use explicit column list in INSERT=20 (even so, future pg release may not support abbreviated INSERT syntax) =20=20=20 and some additional notes not related to the original topic: | $conn=3Dpg_connect("host=3D192.168.0.2 user=3Dpostgres password=3Dpostgres | dbname=3Dcheckbook"); + do not connect in to postgres as superuser! + escape and quote all user input sent to database backend!=20 (consider using addslashes(), sprintf(), etc.) For detailed information visit: http://www.php.net/manual/en/security.database.php=20 =20=20=20 ----- Original Message -----=20 From: "Hillensbeck, Preston" To: Sent: Wednesday, April 17, 2002 11:03 PM Subject: [PHP]=20 | I am currently experiencing a problem passing data from a PHP page to | PostgreSQL.=20 |=20 | I am passing different data types like numeric, and text. Let me show y= ou | some of the code I am using.... |=20 | This is the code that I am using to pass the input data to a page called | "checkbook2.php" |=20 |
|

Check Date | | Check Number | | Check Payee | | Check Amount | |

|

Check Transaction Type | |

| |
|=20 | This is the data from the checkbook2.php that talks to the PostgreSQL | Server. It is running version 7.2. |=20 | $conn=3Dpg_connect("host=3D192.168.0.2 user=3Dpostgres password=3Dpostgres | dbname=3Dcheckbook"); |=20 | @$sql=3D"INSERT INTO checking VALUES('$check_date', '$check_num', | '$check_pay', '$check_amount', '$check_trans_type');"; |=20 | $result=3Dpg_exec($conn, $sql); |=20 | check_data is type text | check_num is type int4 | check_pay is type text | check_amount is type numeric(8,2) | check_trans_type is type text |=20 | The error that comes up is ... | Warning: PostgreSQL query failed: ERROR: Bad numeric input format | 'check_trans_type' in /etc/httpd/htdocs/checkbook2.php on line 41 |=20 | Anyone know what could be going on here?? Please let me know, thanks in | advance! :) |=20 |=20 |=20 | ---------------------------(end of broadcast)--------------------------- | TIP 2: you can get off all lists at once with the unregister command | (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)