Fw: select * from table not showing everything

Fw: select * from table not showing everything

am 28.04.2007 22:45:11 von Richard Dunne

I am still at a loss. I deleted everything from the table using
delete from table;
I then added a row using the php method with the php webpage. I then checked the table with
select * from table;

this being the result


name | address | contact_no
------+---------+------------
| |
(1 row)

As you can see its detecting an entry in the table but it is not displaying the entry.
Can anyone advise? I am only geussing at a configuration problem?

Richard.

----- Forwarded Message ----
From: Richard Dunne
To: pgsql-php@postgresql.org
Sent: Saturday, April 28, 2007 3:09:14 PM
Subject: select * from table not showing everything


I am using a php script via an xmlhttprequest to insert data into a postgresql table from a php web page form. before submitting the form data, I had 1 entry in my table. after submitting the form data, I ran a select * from table query which declared there were 2 entries in the table, but it only displayed the original entry. Is this a know issue? If this is not the corect forum for this post, please advise.

This is the code.

php web page





ALLIED AUTO PARTS


























Choose from the following funtions






php script for inserting form data

$connect=pg_connect("dbname=DatabaseName host=localhost user=User password=password");
if (!pg_connection_busy($connect))
{
$result=pg_query($connect, "insert into customer values('$customer_name', '$customer_address', '$customer_contact_no')");
}
echo "New customer added";
?>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Fw: select * from table not showing everything

am 29.04.2007 09:40:29 von Guillaume Lelarge

Richard Dunne a =E9crit :
> I am still at a loss. I deleted everything from the table using=20
> delete from table;
> I then added a row using the php method with the php webpage. I then c=
hecked the table with=20
> select * from table;
>=20
> this being the result
>=20
>=20
> name | address | contact_no=20
> ------+---------+------------
> | |=20
> (1 row)
>=20
> As you can see its detecting an entry in the table but it is not displa=
ying the entry.
> Can anyone advise? I am only geussing at a configuration problem?
>=20

Perhaps because empty strings were send. You're not telling us your PHP=20
version. If you have 4.2.0 or later, register_globals is by default=20
disabled and $customer_name, $customer_address and $customer_contact_no=20
won't be registered. You'll need to use $_GET array to get those values.=20
Moreover, you don't escape strings.

Maybe you should try this
$query =3D "insert into customer values(";
$query .=3D "'" . pg_escape_string($_GET['customer_name']) . "', ";
$query .=3D "'" . pg_escape_string($_GET['customer_address']) . "', ";
$query .=3D "'" . pg_escape_string($_GET['customer_contact_no']) . "')=
";
$result =3D pg_query($connect, $query);
and read this
http://www.php.net/language.variables.predefined

Regards.


--=20
Guillaume.


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster