pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedselect * from table not showing everything
4+ messages / 3 participants
[nested] [flat]
* select * from table not showing everything
@ 2007-04-28 14:09 Richard Dunne <richarddunne1971@yahoo.com>
0 siblings, 1 reply; 4+ messages in thread
From: Richard Dunne @ 2007-04-28 14:09 UTC (permalink / raw)
To: pgsql-php
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<? include("http://localhost/Databases/getCustomers.php";) ?>
<HTML>
<HEAD>
<TITLE> ALLIED AUTO PARTS </TITLE>
<meta http-equiv="content-type" content="text/xml; charset=iso-8859-1">
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<script language="JavaScript">
function Customers()
{
var url="http://localhost/Project/customers.php";;
if(window.XMLHttpRequest)
http = new XMLHttpRequest();
else if (window.ActiveXObject)
http = new ActiveXObject(Microsoft.XMLHTTP);
http.onreadystatechange = function()
{
alert(http.readyState);
if(http.readyState == 4)
{
alert(http.status)
if(http.status == 200)
{
response = http.responseText;
alert(response);
}
else
{
// + " " + http.statusText;
alert(http.status);
}
}
}
http.open("GET", url, true);
http.setRequestHeader("text");
http.send(null);
}
</script>
</HEAD>
<BODY>
<p align="center">
<form action="viewCustomer.php">
<input type="button" value="View Customers" onclick="return Customers();" />
</form>
<script type="text/javascript" language="javascript">
var numfields;
var numrows;
function viewCustomers()
{
document.write('<tr>');
for (i=0; i < numfields; i++)
{
document.write('<td>' + fieldname[i] + '</td>');
}
document.write('</tr>');
}
for (i=0; i < numrows; i++)
{
document.write('<tr>');
for (j=0; j < numfields; j++)
{
document.write('<td>' + customers[i][j] + '</td>');
}
document.write('</tr>');
}
</script>
<p>
<p>
<TABLE align="center">
<TR>
<TD align="center" colspan="6"><H3>Choose from the following funtions</H3></TD>
</TR>
<TR>
<TD><a href="ViewParts.php">View Parts</a></TD>
<TD><a href="Purchases.php">Purchases</a></TD>
<TD><a href="Sales.php">Sales</a></TD>
<TD><a href="UpdateParts.php">Add parts</a></TD>
<TD><a href="UpdateCustomer.php">Update Customer</a></TD>
<TD><a href="UpdateSupplier.php">Update Supplier</a></TD>
</TR>
</TABLE>
</BODY>
</HTML>
php script for inserting form data
<?php
$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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: select * from table not showing everything
@ 2007-04-28 14:50 John DeSoi <desoi@pgedit.com>
parent: Richard Dunne <richarddunne1971@yahoo.com>
0 siblings, 0 replies; 4+ messages in thread
From: John DeSoi @ 2007-04-28 14:50 UTC (permalink / raw)
To: Richard Dunne <richarddunne1971@yahoo.com>; +Cc: pgsql-php
On Apr 28, 2007, at 10:09 AM, Richard Dunne wrote:
> $result=pg_query($connect, "insert into customer values
> ('$customer_name', '$customer_address', '$customer_contact_no')");
Are these really the first columns in the customer table? If not, you
need to specify the target columns in the insert, e.g.
insert into customer (customer_name, customer_address,
customer_contact_no) values ('$customer_name', '$customer_address',
'$customer_contact_no')
Even if these are the first columns, it is not a good idea to leave
the column specs out since your code will break if you change the
table in an incompatible way.
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
^ permalink raw reply [nested|flat] 4+ messages in thread
* Fw: select * from table not showing everything
@ 2007-04-28 20:45 Richard Dunne <richarddunne1971@yahoo.com>
0 siblings, 1 reply; 4+ messages in thread
From: Richard Dunne @ 2007-04-28 20:45 UTC (permalink / raw)
To: pgsql-php
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 <richarddunne1971@yahoo.com>
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<? include("http://localhost/Databases/getCustomers.php";;) ?>
<HTML>
<HEAD>
<TITLE> ALLIED AUTO PARTS </TITLE>
<meta http-equiv="content-type" content="text/xml; charset=iso-8859-1">
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<script language="JavaScript">
function Customers()
{
var url="http://localhost/Project/customers.php";;;
if(window.XMLHttpRequest)
http = new XMLHttpRequest();
else if (window.ActiveXObject)
http = new ActiveXObject(Microsoft.XMLHTTP);
http.onreadystatechange = function()
{
alert(http.readyState);
if(http.readyState == 4)
{
alert(http.status)
if(http.status == 200)
{
response = http.responseText;
alert(response);
}
else
{
// + " " + http.statusText;
alert(http.status);
}
}
}
http.open("GET", url, true);
http.setRequestHeader("text");
http.send(null);
}
</script>
</HEAD>
<BODY>
<p align="center">
<form action="viewCustomer.php">
<input type="button" value="View Customers" onclick="return Customers();" />
</form>
<script type="text/javascript" language="javascript">
var numfields;
var numrows;
function viewCustomers()
{
document.write('<tr>');
for (i=0; i < numfields; i++)
{
document.write('<td>' + fieldname[i] + '</td>');
}
document.write('</tr>');
}
for (i=0; i < numrows; i++)
{
document.write('<tr>');
for (j=0; j < numfields; j++)
{
document.write('<td>' + customers[i][j] + '</td>');
}
document.write('</tr>');
}
</script>
<p>
<p>
<TABLE align="center">
<TR>
<TD align="center" colspan="6"><H3>Choose from the following funtions</H3></TD>
</TR>
<TR>
<TD><a href="ViewParts.php">View Parts</a></TD>
<TD><a href="Purchases.php">Purchases</a></TD>
<TD><a href="Sales.php">Sales</a></TD>
<TD><a href="UpdateParts.php">Add parts</a></TD>
<TD><a href="UpdateCustomer.php">Update Customer</a></TD>
<TD><a href="UpdateSupplier.php">Update Supplier</a></TD>
</TR>
</TABLE>
</BODY>
</HTML>
php script for inserting form data
<?php
$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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Fw: select * from table not showing everything
@ 2007-04-29 07:40 Guillaume Lelarge <guillaume@lelarge.info>
parent: Richard Dunne <richarddunne1971@yahoo.com>
0 siblings, 0 replies; 4+ messages in thread
From: Guillaume Lelarge @ 2007-04-29 07:40 UTC (permalink / raw)
To: Richard Dunne <richarddunne1971@yahoo.com>; +Cc: pgsql-php
Richard Dunne a écrit :
> 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?
>
Perhaps because empty strings were send. You're not telling us your PHP
version. If you have 4.2.0 or later, register_globals is by default
disabled and $customer_name, $customer_address and $customer_contact_no
won't be registered. You'll need to use $_GET array to get those values.
Moreover, you don't escape strings.
Maybe you should try this
$query = "insert into customer values(";
$query .= "'" . pg_escape_string($_GET['customer_name']) . "', ";
$query .= "'" . pg_escape_string($_GET['customer_address']) . "', ";
$query .= "'" . pg_escape_string($_GET['customer_contact_no']) . "')";
$result = pg_query($connect, $query);
and read this
http://www.php.net/language.variables.predefined
Regards.
--
Guillaume.
<!-- http://abs.traduc.org/
http://lfs.traduc.org/
http://docs.postgresqlfr.org/ -->
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2007-04-29 07:40 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-28 14:09 select * from table not showing everything Richard Dunne <richarddunne1971@yahoo.com>
2007-04-28 14:50 ` John DeSoi <desoi@pgedit.com>
2007-04-28 20:45 Fw: select * from table not showing everything Richard Dunne <richarddunne1971@yahoo.com>
2007-04-29 07:40 ` Guillaume Lelarge <guillaume@lelarge.info>
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