pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
wouldn't insert
8+ messages / 4 participants
[nested] [flat]

* wouldn't insert
@ 2004-07-09 02:39 Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-09 19:08 ` Re: wouldn't insert brew@theMode.com
  2004-07-11 23:42 ` Re: wouldn't insert Chris <chris@interspire.com>
  0 siblings, 2 replies; 8+ messages in thread

From: Elijah O. Alcantara @ 2004-07-09 02:39 UTC (permalink / raw)
  To: pgsql-php

Hi again,

Can someone help me out on this? the function I quoted below is supposed
to restore the values from table temp_contactinfo to contactinfo. But
it's not inserting to the contactinfo table... 

There are no errors whatsoever, must be something wrong with the logic
somewhere... 



> function restore_contactinfo($connectGovPH, $ctrl_no) {
> 
> $query_clear = "delete from contactinfo where ctrl_no = '$ctrl_no'";
> pg_Exec($connectGovPH,$query_clear);
> 
> $query = "select * from temp_contactinfo where ctrl_no = '$ctrl_no'";
> $result = pg_Exec($connectGovPH,$query);
> $num = pg_NumRows($result);
> 
> 
> for($i=0;$i<$num;$i++) {
>         $row = pg_Fetch_Object($result,$i);
>         $category = $row->category;
>         $contact_no = $row->contact_no;
>         $contact_name = $row->contact_name;
>         $organization_name = $row->organization_name;
>         $address = $row->address;
>         $telephone = $row->telephone;
>         $fax = $row->fax;
>         $email = $row->email; 
> 
>         $query2 = "INSERT INTO contactinfo
> VALUES('$ctrl_no','$category','$contact_no','$contact_name','$organization_name','$address','$telephone','$fax','$email')";
>         pg_Exec($connectGovPH,$query2);
>         
>         $query3 = "DELETE FROM temp_contactinfo WHERE ctrl_no =
> '$ctrl_no' AND category = '$category' AND contact_no = '$contact_no'";
>         pg_Exec($connectGovPH,$query3);
> 	}
> } 

I've searched and searched but couldn't find anything wrong with the
code =( 


Elijah




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

* Re: wouldn't insert
  2004-07-09 02:39 wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
@ 2004-07-09 19:08 ` brew@theMode.com
  2004-07-12 01:45   ` Re: wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  1 sibling, 1 reply; 8+ messages in thread

From: brew@theMode.com @ 2004-07-09 19:08 UTC (permalink / raw)
  To: Elijah O. Alcantara <elijah@asti.dost.gov.ph>; +Cc: pgsql-php


Elijah.....

> There are no errors whatsoever, must be something wrong with the logic
> somewhere...

What I do when I can't find errors is break down the code into
smaller steps and add error checking.

Make the connection and check the return value.

Put together the sql statement and print it.

Query the database and check the return value.

and so forth.....

Check php.net to see some examples of error checking.

On another note, if I'm only working with only one db I just connect once
near the start of the script and then use that connection for the
subsequent calls.

brew

 ==========================================================================
                  Strange Brew   (brew@theMode.com)
     Check out my Musician's Online Database Exchange (The MODE Pages)
                        http://www.TheMode.com
 ==========================================================================




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

* Re: wouldn't insert
  2004-07-09 02:39 wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-09 19:08 ` Re: wouldn't insert brew@theMode.com
@ 2004-07-12 01:45   ` Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-12 01:53     ` Re: wouldn't insert Chris <chris@interspire.com>
  2004-07-12 02:16     ` Re: wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-12 02:18     ` Re: wouldn't insert Scott Marlowe <smarlowe@qwest.net>
  0 siblings, 3 replies; 8+ messages in thread

From: Elijah O. Alcantara @ 2004-07-12 01:45 UTC (permalink / raw)
  To: pgsql-php

I tried using error_log() but never got any emails... 

error_log("This is query2 inserting $ctrl_no $category $contact_no
$organization_name $address $telephone $fax $email", 1,
"elijah@asti.dost.gov.ph");

looks like it never went in the for loop, somethings wrong... 

Thanks for the advice, 
Elijah

On Sat, 2004-07-10 at 03:08, brew@theMode.com wrote:
> Elijah.....
> 
> > There are no errors whatsoever, must be something wrong with the logic
> > somewhere...
> 
> What I do when I can't find errors is break down the code into
> smaller steps and add error checking.
> 
> Make the connection and check the return value.
> 
> Put together the sql statement and print it.
> 
> Query the database and check the return value.
> 
> and so forth.....
> 
> Check php.net to see some examples of error checking.
> 
> On another note, if I'm only working with only one db I just connect once
> near the start of the script and then use that connection for the
> subsequent calls.
> 
> brew
> 
>  ==========================================================================
>                   Strange Brew   (brew@theMode.com)
>      Check out my Musician's Online Database Exchange (The MODE Pages)
>                         http://www.TheMode.com
>  ==========================================================================
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match




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

* Re: wouldn't insert
  2004-07-09 02:39 wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-09 19:08 ` Re: wouldn't insert brew@theMode.com
  2004-07-12 01:45   ` Re: wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
@ 2004-07-12 01:53     ` Chris <chris@interspire.com>
  2004-07-12 02:08       ` Re: wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2 siblings, 1 reply; 8+ messages in thread

From: Chris @ 2004-07-12 01:53 UTC (permalink / raw)
  To: 'Elijah O. Alcantara' <elijah@asti.dost.gov.ph>; pgsql-php

error_log won't email you will it? It'll put it into the apache error
log (by default) or the file you specify in your php.ini file, or if you
have it in your script,

ini_set('log_error',......)

And don't separate the query, just error_log it like

error_log($query2);

Chris.


-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Elijah O. Alcantara
Sent: Monday, July 12, 2004 11:46 AM
To: pgsql-php@postgresql.org
Subject: Re: [PHP] wouldn't insert


I tried using error_log() but never got any emails... 

error_log("This is query2 inserting $ctrl_no $category $contact_no
$organization_name $address $telephone $fax $email", 1,
"elijah@asti.dost.gov.ph");

looks like it never went in the for loop, somethings wrong... 

Thanks for the advice, 
Elijah

On Sat, 2004-07-10 at 03:08, brew@theMode.com wrote:
> Elijah.....
> 
> > There are no errors whatsoever, must be something wrong with the 
> > logic somewhere...
> 
> What I do when I can't find errors is break down the code into smaller

> steps and add error checking.
> 
> Make the connection and check the return value.
> 
> Put together the sql statement and print it.
> 
> Query the database and check the return value.
> 
> and so forth.....
> 
> Check php.net to see some examples of error checking.
> 
> On another note, if I'm only working with only one db I just connect 
> once near the start of the script and then use that connection for the

> subsequent calls.
> 
> brew
> 
>
========================================================================
==
>                   Strange Brew   (brew@theMode.com)
>      Check out my Musician's Online Database Exchange (The MODE Pages)
>                         http://www.TheMode.com  
> ======================================================================
> ====
> 
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if
your
>       joining column's datatypes do not match


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html




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

* Re: wouldn't insert
  2004-07-09 02:39 wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-09 19:08 ` Re: wouldn't insert brew@theMode.com
  2004-07-12 01:45   ` Re: wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-12 01:53     ` Re: wouldn't insert Chris <chris@interspire.com>
@ 2004-07-12 02:08       ` Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  0 siblings, 0 replies; 8+ messages in thread

From: Elijah O. Alcantara @ 2004-07-12 02:08 UTC (permalink / raw)
  To: pgsql-php

I moved the error_log outside the loop and I got log message, now it
looks like the script doesn't pass through the for loop. 

I wonder how can it not pass through the for loop ?? it's strange... I
didn't put any 'break' in there for sure ... 

Elijah

On Mon, 2004-07-12 at 09:53, Chris wrote:
> error_log won't email you will it? It'll put it into the apache error
> log (by default) or the file you specify in your php.ini file, or if you
> have it in your script,
> 
> ini_set('log_error',......)
> 
> And don't separate the query, just error_log it like
> 
> error_log($query2);
> 
> Chris.
> 
> 
> -----Original Message-----
> From: pgsql-php-owner@postgresql.org
> [mailto:pgsql-php-owner@postgresql.org] On Behalf Of Elijah O. Alcantara
> Sent: Monday, July 12, 2004 11:46 AM
> To: pgsql-php@postgresql.org
> Subject: Re: [PHP] wouldn't insert
> 
> 
> I tried using error_log() but never got any emails... 
> 
> error_log("This is query2 inserting $ctrl_no $category $contact_no
> $organization_name $address $telephone $fax $email", 1,
> "elijah@asti.dost.gov.ph");
> 
> looks like it never went in the for loop, somethings wrong... 
> 
> Thanks for the advice, 
> Elijah
> 
> On Sat, 2004-07-10 at 03:08, brew@theMode.com wrote:
> > Elijah.....
> > 
> > > There are no errors whatsoever, must be something wrong with the 
> > > logic somewhere...
> > 
> > What I do when I can't find errors is break down the code into smaller
> 
> > steps and add error checking.
> > 
> > Make the connection and check the return value.
> > 
> > Put together the sql statement and print it.
> > 
> > Query the database and check the return value.
> > 
> > and so forth.....
> > 
> > Check php.net to see some examples of error checking.
> > 
> > On another note, if I'm only working with only one db I just connect 
> > once near the start of the script and then use that connection for the
> 
> > subsequent calls.
> > 
> > brew
> > 
> >
> ========================================================================
> ==
> >                   Strange Brew   (brew@theMode.com)
> >      Check out my Musician's Online Database Exchange (The MODE Pages)
> >                         http://www.TheMode.com  
> > ======================================================================
> > ====
> > 
> > 
> > ---------------------------(end of 
> > broadcast)---------------------------
> > TIP 9: the planner will ignore your desire to choose an index scan if
> your
> >       joining column's datatypes do not match
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faqs/FAQ.html
> 




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

* Re: wouldn't insert
  2004-07-09 02:39 wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-09 19:08 ` Re: wouldn't insert brew@theMode.com
  2004-07-12 01:45   ` Re: wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
@ 2004-07-12 02:16     ` Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2 siblings, 0 replies; 8+ messages in thread

From: Elijah O. Alcantara @ 2004-07-12 02:16 UTC (permalink / raw)
  To: pgsql-php

Bingo! no wonder it can't push through the loop, there wasn't any
results in the first place at the first query. Error_log()'s very useful
=)

Thanks,
Elijah

On Mon, 2004-07-12 at 09:45, Elijah O. Alcantara wrote:
> I tried using error_log() but never got any emails... 
> 
> error_log("This is query2 inserting $ctrl_no $category $contact_no
> $organization_name $address $telephone $fax $email", 1,
> "elijah@asti.dost.gov.ph");
> 
> looks like it never went in the for loop, somethings wrong... 
> 
> Thanks for the advice, 
> Elijah
> 
> On Sat, 2004-07-10 at 03:08, brew@theMode.com wrote:
> > Elijah.....
> > 
> > > There are no errors whatsoever, must be something wrong with the logic
> > > somewhere...
> > 
> > What I do when I can't find errors is break down the code into
> > smaller steps and add error checking.
> > 
> > Make the connection and check the return value.
> > 
> > Put together the sql statement and print it.
> > 
> > Query the database and check the return value.
> > 
> > and so forth.....
> > 
> > Check php.net to see some examples of error checking.
> > 
> > On another note, if I'm only working with only one db I just connect once
> > near the start of the script and then use that connection for the
> > subsequent calls.
> > 
> > brew
> > 
> >  ==========================================================================
> >                   Strange Brew   (brew@theMode.com)
> >      Check out my Musician's Online Database Exchange (The MODE Pages)
> >                         http://www.TheMode.com
> >  ==========================================================================
> > 
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 9: the planner will ignore your desire to choose an index scan if your
> >       joining column's datatypes do not match
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faqs/FAQ.html




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

* Re: wouldn't insert
  2004-07-09 02:39 wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
  2004-07-09 19:08 ` Re: wouldn't insert brew@theMode.com
  2004-07-12 01:45   ` Re: wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
@ 2004-07-12 02:18     ` Scott Marlowe <smarlowe@qwest.net>
  2 siblings, 0 replies; 8+ messages in thread

From: Scott Marlowe @ 2004-07-12 02:18 UTC (permalink / raw)
  To: Elijah O. Alcantara <elijah@asti.dost.gov.ph>; +Cc: pgsql-php

This subject came up tangentially in the -hackers list. You should look
at using the following functions:

http://www.php.net/manual/en/function.pg-result-error.php
http://www.php.net/manual/en/function.pg-result-status.php

supported since 4.2.0 came out a little over two years ago.  Very nice
way to catch and handle errors.

On Sun, 2004-07-11 at 19:45, Elijah O. Alcantara wrote:
> I tried using error_log() but never got any emails... 
> 
> error_log("This is query2 inserting $ctrl_no $category $contact_no
> $organization_name $address $telephone $fax $email", 1,
> "elijah@asti.dost.gov.ph");
> 
> looks like it never went in the for loop, somethings wrong... 
> 
> Thanks for the advice, 
> Elijah
> 
> On Sat, 2004-07-10 at 03:08, brew@theMode.com wrote:
> > Elijah.....
> > 
> > > There are no errors whatsoever, must be something wrong with the logic
> > > somewhere...
> > 
> > What I do when I can't find errors is break down the code into
> > smaller steps and add error checking.
> > 
> > Make the connection and check the return value.
> > 
> > Put together the sql statement and print it.
> > 
> > Query the database and check the return value.
> > 
> > and so forth.....
> > 
> > Check php.net to see some examples of error checking.
> > 
> > On another note, if I'm only working with only one db I just connect once
> > near the start of the script and then use that connection for the
> > subsequent calls.
> > 
> > brew
> > 
> >  ==========================================================================
> >                   Strange Brew   (brew@theMode.com)
> >      Check out my Musician's Online Database Exchange (The MODE Pages)
> >                         http://www.TheMode.com
> >  ==========================================================================
> > 
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 9: the planner will ignore your desire to choose an index scan if your
> >       joining column's datatypes do not match
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faqs/FAQ.html
> 




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

* Re: wouldn't insert
  2004-07-09 02:39 wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
@ 2004-07-11 23:42 ` Chris <chris@interspire.com>
  1 sibling, 0 replies; 8+ messages in thread

From: Chris @ 2004-07-11 23:42 UTC (permalink / raw)
  To: 'Elijah O. Alcantara' <elijah@asti.dost.gov.ph>; pgsql-php

Hey,

echo out $query2 before it runs, try a few in psql and it should tell
you what the error is....

Chris.

-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Elijah O. Alcantara
Sent: Friday, July 09, 2004 12:39 PM
To: pgsql-php@postgresql.org
Subject: [PHP] wouldn't insert


Hi again,

Can someone help me out on this? the function I quoted below is supposed
to restore the values from table temp_contactinfo to contactinfo. But
it's not inserting to the contactinfo table... 

There are no errors whatsoever, must be something wrong with the logic
somewhere... 



> function restore_contactinfo($connectGovPH, $ctrl_no) {
> 
> $query_clear = "delete from contactinfo where ctrl_no = '$ctrl_no'"; 
> pg_Exec($connectGovPH,$query_clear);
> 
> $query = "select * from temp_contactinfo where ctrl_no = '$ctrl_no'"; 
> $result = pg_Exec($connectGovPH,$query); $num = pg_NumRows($result);
> 
> 
> for($i=0;$i<$num;$i++) {
>         $row = pg_Fetch_Object($result,$i);
>         $category = $row->category;
>         $contact_no = $row->contact_no;
>         $contact_name = $row->contact_name;
>         $organization_name = $row->organization_name;
>         $address = $row->address;
>         $telephone = $row->telephone;
>         $fax = $row->fax;
>         $email = $row->email;
> 
>         $query2 = "INSERT INTO contactinfo 
>
VALUES('$ctrl_no','$category','$contact_no','$contact_name','$organizati
on_name','$address','$telephone','$fax','$email')";
>         pg_Exec($connectGovPH,$query2);
>         
>         $query3 = "DELETE FROM temp_contactinfo WHERE ctrl_no = 
> '$ctrl_no' AND category = '$category' AND contact_no = '$contact_no'";
>         pg_Exec($connectGovPH,$query3);
> 	}
> }

I've searched and searched but couldn't find anything wrong with the
code =( 


Elijah


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if
your
      joining column's datatypes do not match




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


end of thread, other threads:[~2004-07-12 02:18 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-09 02:39 wouldn't insert Elijah O. Alcantara <elijah@asti.dost.gov.ph>
2004-07-09 19:08 ` brew@theMode.com
2004-07-12 01:45   ` Elijah O. Alcantara <elijah@asti.dost.gov.ph>
2004-07-12 01:53     ` Chris <chris@interspire.com>
2004-07-12 02:08       ` Elijah O. Alcantara <elijah@asti.dost.gov.ph>
2004-07-12 02:16     ` Elijah O. Alcantara <elijah@asti.dost.gov.ph>
2004-07-12 02:18     ` Scott Marlowe <smarlowe@qwest.net>
2004-07-11 23:42 ` Chris <chris@interspire.com>

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