pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Looking for some assistance / guidance --
5+ messages / 3 participants
[nested] [flat]

* Looking for some assistance / guidance --
@ 2014-07-29 00:45  Jeff Silberberg <jms@dapage.net>
  0 siblings, 2 replies; 5+ messages in thread

From: Jeff Silberberg @ 2014-07-29 00:45 UTC (permalink / raw)
  To: pgsql-php

Good evening --

I have a Wordpress / HTML form that includes <select size="5" multiple
name=Keys[]"....>

The form calls a PHP CGI program and if I set it to phpinfo()  I see that
the array Keys is in the post data.  An I can do a $selectedKeys =
$_POST('Keys')  and walk through and echo out the array elements without a
problem.

My issues start when I attempt to pass the array of Keys to my PostgreSql
function with a parameter list of (web_Keys_ integer[], web_text_ text,
web_user_ text) ................

in my php I do a pg_connect, and then prepare a number of statements all of
which work but the last one.

    it is $return_cde = pg_prepare($conn, "SendKeys", 'select
web.sendKeys$1, $2, $3)');.

   and I try to execute this with

      $userKey=$_POST['Keys'];
      $userText=$_POST['msgText'] . " / " . $current_user->display_name;

      $return = pg_execute($conn, "SendKeys", array($userKey, $userText,
$current_user->display_name));

      Which returns and error --
function.pg-execute <http://dispatch.dapage.net/cgi-bin/function.pg-execute;]:
Query failed: ERROR: array value must start with "{" or dimension
information in */home/xxxxxxx/public_html/enterkey/cgi-bin/xxxxxxcgi.php*
on line *90*

      echo "User Keys " . gettype($userKey)."<br>\n";   confirms this is a
Array ..    An I have tried casting  $1::int[]  in the prepare with no
luck..

      I find a lot of hits on Google searches but no solutions..

      Hoping someone here can assist me with this issue..

=============

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Looking for some assistance / guidance --
@ 2014-07-29 01:03  Matthias Ritzkowski <matthiar@gmail.com>
  parent: Jeff Silberberg <jms@dapage.net>
  1 sibling, 1 reply; 5+ messages in thread

From: Matthias Ritzkowski @ 2014-07-29 01:03 UTC (permalink / raw)
  To: pgsql-php

Is the array maybe zero-based?

Did you try 'select web.sendKeys$0, $1, $2, $3' ....

Regards
Matthias

On 7/28/14, 8:45 PM, Jeff Silberberg wrote:
> Good evening --
>
> I have a Wordpress / HTML form that includes <select size="5" multiple 
> name=Keys[]"....>
>
> The form calls a PHP CGI program and if I set it to phpinfo()  I see 
> that the array Keys is in the post data.  An I can do a $selectedKeys 
> = $_POST('Keys')  and walk through and echo out the array elements 
> without a problem.
>
> My issues start when I attempt to pass the array of Keys to my 
> PostgreSql function with a parameter list of (web_Keys_ integer[], 
> web_text_ text, web_user_ text) ................
>
> in my php I do a pg_connect, and then prepare a number of statements 
> all of which work but the last one.
>
>     it is $return_cde = pg_prepare($conn, "SendKeys", 'select 
> web.sendKeys$1, $2, $3)');.
>
>    and I try to execute this with
>
>       $userKey=$_POST['Keys'];
>       $userText=$_POST['msgText'] . " / " . $current_user->display_name;
>
>       $return = pg_execute($conn, "SendKeys", array($userKey, 
> $userText, $current_user->display_name));
>
>       Which returns and error --
>
>
>     function.pg-execute
>     <http://dispatch.dapage.net/cgi-bin/function.pg-execute;]: Query
>     failed: ERROR: array value must start with "{" or dimension
>     information in
>     */home/xxxxxxx/public_html/enterkey/cgi-bin/xxxxxxcgi.php* on line
>     *90*
>
>
>       echo "User Keys " . gettype($userKey)."<br>\n";   confirms this 
> is a Array ..    An I have tried casting  $1::int[]  in the prepare 
> with no luck..
>
>       I find a lot of hits on Google searches but no solutions..
>
>       Hoping someone here can assist me with this issue..
>
> =============
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Looking for some assistance / guidance --
@ 2014-07-29 01:26  Jeff Silberberg <jms@dapage.net>
  parent: Matthias Ritzkowski <matthiar@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Silberberg @ 2014-07-29 01:26 UTC (permalink / raw)
  To: Matthias Ritzkowski <matthiar@gmail.com>; +Cc: pgsql-php

Nope ---

    http://php.net/manual/en/function.pg-prepare.

    If any parameters are used, they are referred to in the query as $1,
$2, etc.



On Mon, Jul 28, 2014 at 9:03 PM, Matthias Ritzkowski <matthiar@gmail.com>
wrote:

>  Is the array maybe zero-based?
>
> Did you try 'select web.sendKeys$0, $1, $2, $3' ....
>
> Regards
> Matthias
>
>
> On 7/28/14, 8:45 PM, Jeff Silberberg wrote:
>
>    Good evening --
>
>  I have a Wordpress / HTML form that includes <select size="5" multiple
> name=Keys[]"....>
>
>  The form calls a PHP CGI program and if I set it to phpinfo()  I see that
> the array Keys is in the post data.  An I can do a $selectedKeys =
> $_POST('Keys')  and walk through and echo out the array elements without a
> problem.
>
>  My issues start when I attempt to pass the array of Keys to my PostgreSql
> function with a parameter list of (web_Keys_ integer[], web_text_ text,
> web_user_ text) ................
>
>  in my php I do a pg_connect, and then prepare a number of statements all
> of which work but the last one.
>
>      it is $return_cde = pg_prepare($conn, "SendKeys", 'select
> web.sendKeys$1, $2, $3)');.
>
>     and I try to execute this with
>
>       $userKey=$_POST['Keys'];
>       $userText=$_POST['msgText'] . " / " . $current_user->display_name;
>
>       $return = pg_execute($conn, "SendKeys", array($userKey, $userText,
> $current_user->display_name));
>
>        Which returns and error --
>  function.pg-execute
> <http://dispatch.dapage.net/cgi-bin/function.pg-execute;]: Query failed:
> ERROR: array value must start with "{" or dimension information in
> */home/xxxxxxx/public_html/enterkey/cgi-bin/xxxxxxcgi.php* on line *90*
>
>       echo "User Keys " . gettype($userKey)."<br>\n";   confirms this is a
> Array ..    An I have tried casting  $1::int[]  in the prepare with no
> luck..
>
>        I find a lot of hits on Google searches but no solutions..
>
>        Hoping someone here can assist me with this issue..
>
> =============
>
>
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Looking for some assistance / guidance --
@ 2014-07-29 09:02  Michael Wallner <mike@php.net>
  parent: Jeff Silberberg <jms@dapage.net>
  1 sibling, 1 reply; 5+ messages in thread

From: Michael Wallner @ 2014-07-29 09:02 UTC (permalink / raw)
  To: Jeff Silberberg <jms@dapage.net>; pgsql-php

On 29/07/14 02:45, Jeff Silberberg wrote:

>       echo "User Keys " . gettype($userKey)."<br>\n";   confirms this is
> a Array ..    An I have tried casting  $1::int[]  in the prepare with no
> luck..
> 

You have to format it as postgresql array string, so that it can be
parsed as array by the server, e.g: '{1,2,3}'::int[]

So, assuming they keys are integers:
$userKey = "{".implode(",",array_map("intval", $userKey))."}::int[]";

-- 
Regards,
Mike


-- 
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Looking for some assistance / guidance --
@ 2014-07-29 13:09  Jeff Silberberg <jms@dapage.net>
  parent: Michael Wallner <mike@php.net>
  0 siblings, 0 replies; 5+ messages in thread

From: Jeff Silberberg @ 2014-07-29 13:09 UTC (permalink / raw)
  To: Michael Wallner <mike@php.net>; +Cc: pgsql-php

Michael,

    About three am I woke up with this same basic thought in my head..

    Will try it latter this morning, but I suspect this is the correct
answer.

    Thank you !



On Tue, Jul 29, 2014 at 5:02 AM, Michael Wallner <mike@php.net> wrote:

> On 29/07/14 02:45, Jeff Silberberg wrote:
>
> >       echo "User Keys " . gettype($userKey)."<br>\n";   confirms this is
> > a Array ..    An I have tried casting  $1::int[]  in the prepare with no
> > luck..
> >
>
> You have to format it as postgresql array string, so that it can be
> parsed as array by the server, e.g: '{1,2,3}'::int[]
>
> So, assuming they keys are integers:
> $userKey = "{".implode(",",array_map("intval", $userKey))."}::int[]";
>
> --
> Regards,
> Mike
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2014-07-29 13:09 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-07-29 00:45 Looking for some assistance / guidance -- Jeff Silberberg <jms@dapage.net>
2014-07-29 01:03 ` Matthias Ritzkowski <matthiar@gmail.com>
2014-07-29 01:26   ` Jeff Silberberg <jms@dapage.net>
2014-07-29 09:02 ` Michael Wallner <mike@php.net>
2014-07-29 13:09   ` Jeff Silberberg <jms@dapage.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox