Re: Odd "INSERT" Problems with PostgreSQL - Do YOU know?

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "Diana Cionoiu" <diana(at)softwaresolutions(dot)ro>, "Jason" <jason(at)op480(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Odd "INSERT" Problems with PostgreSQL - Do YOU know?
Date: 2001-05-24 10:07:05
Message-ID: 006501c0e439$4ad33b80$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: "Diana Cionoiu" <diana(at)softwaresolutions(dot)ro>

> >Here's my sql statement:
> >$sql = "insert into pricing (prod_id, size_id, price) values ($prod_id,
> >$size_id, 0.00)";
> >
> >here's an example of what it generates before it inserts:
> >insert into pricing (prod_id, size_id, price) values (148, 48, 0.00)
>
> The problem is from php, please do this
> print $prod_id;
> and see what it give you
> in php you must have someting like.
> $mumu = pg_exec ($conn, "insert into mumulica (mumu1,mumu2) values('" .
> $mumu1 . "','" . $mumu2 . "')");

Absolutely correct for strings, although in your example you could use:

pg_exec($conn, "insert into mumulica (mumu1,mumu2) values
('$mumu1','$mumu2')")

bearing in mind the need to escape ' marks. But - Jason's using numbers so
he should be fine.

Jason - sounds like you're checking return values, so we can be reasonably
sure the insert occurred. You're not inside a transaction block that gets
rolled back are you?

Might be scripts failing half-way through because of connection problems
too.

I'd be tempted to print $sql to a log-file so you can see what you think you
inserted and compare it to Postgres. You can also turn the logging level up
in PG to see individual queries, but that can be a little overwhelming.

- Richard Huxton

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-05-24 11:40:53 Re: Odd "INSERT" Problems with PostgreSQL - Do YOU know?
Previous Message Sergey E. Volkov 2001-05-24 09:39:54 Re: Return cursor