Skip site navigation (1) Skip section navigation (2)

Select Where using character varying ??

From: "ben wilko" <wilko_ben(at)hotmail(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: Select Where using character varying ??
Date: 2006-10-03 04:08:07
Message-ID: BAY116-F1074C7ACE9E04AA4A018B88F1C0@phx.gbl (view raw or flat)
Thread:
Lists: pgsql-php
<html><div style='background-color:'><DIV class=RTE>Hi Guys</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>I am printing names into a combo box and posting the variable. I try and use the name ($Sem) in an SQL statement; WHERE&nbsp;name = $Sem; but I get an error which is displayed&nbsp;near the end of this message. Are we able compare php string to postgresql character varying??&nbsp; not sure how else to do the selection</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>$conn = pg_Connect("host=localhost dbname=#### user=#### password=####");<BR>&nbsp; &nbsp;if (!$conn) {echo "An database connection error occurred.\n"; exit;}</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>// e.g. $Sem = "seminar one";</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>$Sem = $_POST['Seminars'];</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>$Sem_No = pg_Exec($conn,"SELECT seminar_id FROM seminar WHERE&nbsp;name = $Sem");<BR>&nbsp;if (!$SemNo) {echo "A query error occurred in retreiving the selected seminar's ID &lt;br&gt;"; /*exit;*/}<BR>$Sem_No = pg_Result($Sem_No, 0);</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>// Error Message</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE><STRONG>Warning</STRONG>: pg_exec() [<A href="http://www.citanalyst.com/jet/form/function.pg-exec">function.pg-exec</A>]: Query failed: ERROR: syntax error at or near "one" at character 54 in <B>/home/bdwilko/public_html/jet/form/insertP.php</B> on line <B>56</B><BR>A query error occurred in retreiving the selected seminar's ID </DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>Table:&nbsp;<TD> </TD><TD><A title=Table href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/redirect.php?server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;subject=table&amp;table=seminar">seminar</A></TD></DIV>
<DIV class=RTE><TR><TH class=data><TR><TH class=data>Column</TH>&nbsp;&nbsp;&nbsp;&nbsp; <TH class=data>Type</TH> <TH class=data>Not Null</TH> <TH class=data>Default</TH> <TH class=data colspan="2">Actions</TH> <TH class=data>Comment</TH> </DIV>
<DIV class=RTE></TR><TR><TD class=data1>seminar_id</TD> <TD class=data1>integer</TD> NOT NULL nextval('seminar_seminar_id_seq'::regclass)</TD> <TD class=opbutton1><A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=properties&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=seminar_id&amp;">Alter</A></TD><TD class=opbutton1><A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=confirm_drop&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=seminar_id&amp;">Drop</A></TD><TD class=data1></TD> </DIV>
<DIV class=RTE></TR><TR><TD class=data2>name</TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <TD class=data2>character varying</TD> <A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=properties&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=name&amp;">Alter</A></TD><TD class=opbutton2><A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=confirm_drop&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=name&amp;">Drop</A></TD><TD class=data2></TD> </DIV>
<DIV class=RTE></TR><TR><TD class=data1>address</TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <TD class=data1>character varying</TD> <A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=properties&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=address&amp;">Alter</A></TD><TD class=opbutton1><A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=confirm_drop&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=address&amp;">Drop</A></TD><TD class=data1></TD> </DIV>
<DIV class=RTE></TR><TR><TD class=data2>date</TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <TD class=data2>date</TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=properties&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=date&amp;">Alter</A></TD><TD class=opbutton2><A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=confirm_drop&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=date&amp;">Drop</A></TD><TD class=data2></TD> </DIV>
<DIV class=RTE></TR><TR><TD class=data1>description</TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <TD class=data1>character varying <A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=properties&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=description&amp;">Alter</A></TD><TD class=opbutton1><A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=confirm_drop&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=description&amp;">Drop</A></TD><TD class=data1></TD> </DIV>
<DIV class=RTE></TR><TR><TD class=data2>notes</TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <TD class=data2>character varying</TD> <A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=properties&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=notes&amp;">Alter</A></TD><TD class=opbutton2><A href="https://www13.a2hosting.com:2083/3rdparty/phpPgAdmin/tblproperties.php?action=confirm_drop&amp;server=%3A5432&amp;database=bdwilko_jet&amp;schema=public&amp;table=seminar&amp;column=notes&amp;">Drop</A></TD><TD class=data2></TD></TR><TD class=data1></DIV>
<DIV class=RTE align=center></DIV>
<DIV class=RTE></TD><TD class=data1></TD><TD class=opbutton1></TD><TD class=data1></TD></TR></DIV></div></html>



Attachment: unknown_filename
Description: text/html (6.5 KB)

Responses

pgsql-php by date

Next:From: Charley TiggsDate: 2006-10-03 08:05:28
Subject: Re: Select Where using character varying ??
Previous:From: Erik JonesDate: 2006-09-14 15:10:43
Subject: Re: Having problems with user defined sessions using postgresql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group