Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 68D419FB2DB for ; Tue, 3 Oct 2006 01:08:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 43708-02 for ; Tue, 3 Oct 2006 04:08:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from bay0-omc2-s8.bay0.hotmail.com (bay0-omc2-s8.bay0.hotmail.com [65.54.246.144]) by postgresql.org (Postfix) with ESMTP id 9579F9FB293 for ; Tue, 3 Oct 2006 01:08:10 -0300 (ADT) Received: from hotmail.com ([64.4.38.20]) by bay0-omc2-s8.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 2 Oct 2006 21:08:08 -0700 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 2 Oct 2006 21:08:08 -0700 Message-ID: Received: from 64.4.38.200 by by116fd.bay116.hotmail.msn.com with HTTP; Tue, 03 Oct 2006 04:08:07 GMT X-Originating-IP: [58.169.176.169] X-Originating-Email: [wilko_ben@hotmail.com] X-Sender: wilko_ben@hotmail.com From: "ben wilko" To: pgsql-php@postgresql.org Subject: Select Where using character varying ?? Date: Tue, 03 Oct 2006 14:08:07 +1000 Mime-Version: 1.0 Content-Type: text/html; format=flowed X-OriginalArrivalTime: 03 Oct 2006 04:08:08.0474 (UTC) FILETIME=[88BB57A0:01C6E6A1] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.909 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, HTML_MESSAGE, MIME_HTML_ONLY, MSGID_FROM_MTA_HEADER, SPF_PASS X-Spam-Level: * X-Archive-Number: 200610/1 X-Sequence-Number: 3601
Hi Guys
 
I am printing names into a combo box and posting the variable. I try and use the name ($Sem) in an SQL statement; WHERE name = $Sem; but I get an error which is displayed near the end of this message. Are we able compare php string to postgresql character varying??  not sure how else to do the selection
 
 
$conn = pg_Connect("host=localhost dbname=#### user=#### password=####");
   if (!$conn) {echo "An database connection error occurred.\n"; exit;}
 
 
// e.g. $Sem = "seminar one";
 
$Sem = $_POST['Seminars'];
 
 
$Sem_No = pg_Exec($conn,"SELECT seminar_id FROM seminar WHERE name = $Sem");
 if (!$SemNo) {echo "A query error occurred in retreiving the selected seminar's ID <br>"; /*exit;*/}
$Sem_No = pg_Result($Sem_No, 0);
 
// Error Message
 
Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: syntax error at or near "one" at character 54 in /home/bdwilko/public_html/jet/form/insertP.php on line 56
A query error occurred in retreiving the selected seminar's ID
 
 
Table:  seminar
Column     Type Not Null Default Actions Comment
seminar_id integer NOT NULL nextval('seminar_seminar_id_seq'::regclass) AlterDrop
name                          character varying AlterDrop
address                       character varying AlterDrop
date                           date                  AlterDrop
description                  character varying AlterDrop
notes                         character varying AlterDrop