pg_fetch_row Problem
am 02.03.2004 00:50:15 von CSeader
Greetings,
I am not sure what is going on with my script here, but i am getting this e=
rror when i run it.
Warning: pg_fetch_row(): Unable to jump to row 706 on PostgreSQL result ind=
ex 3. in /var/www/html/PMS/csv_export.php on line 32
Warning: Cannot modify header information - headers already sent by (output=
started at /var/www/html/PMS/csv_export.php:4) in /var/www/html/PMS/csv_ex=
port.php on line 59
Warning: Cannot modify header information - headers already sent by (output=
started at /var/www/html/PMS/csv_export.php:4) in /var/www/html/PMS/csv_ex=
port.php on line 62
Warning: Cannot modify header information - headers already sent by (output=
started at /var/www/html/PMS/csv_export.php:4) in /var/www/html/PMS/csv_ex=
port.php on line 63
Warning: Cannot modify header information - headers already sent by (output=
started at /var/www/html/PMS/csv_export.php:4) in /var/www/html/PMS/csv_ex=
port.php on line 64
Can anyone tell me what is going on here???????
I am including my script here below so you can see what it is doing, maybe =
you all can see something im not:
pg_connect("host=3D172.18.74.10 port=3D5432 dbname=3Dacquisuite_db user=3Dp=
gadmin password=3Dpgadmin")=20
or die ( 'Unable to connect to server.' );=20
printf("Connected Successfully");
$MM_param1__panels =3D ''%'';
if (isset($HTTP_GET_VARS['panel'])) {
$MM_param1__panels =3D $HTTP_GET_VARS['panel'];
}
$MM_param2__panels =3D ''%'';
if (isset($HTTP_GET_VARS['startdate'])) {
$MM_param2__panels =3D $HTTP_GET_VARS['startdate'];
}
$MM_param3__panels =3D ''%'';
if (isset($HTTP_GET_VARS['enddate'])) {
$MM_param3__panels =3D $HTTP_GET_VARS['enddate'];
}
$MM_param4__panels =3D ''%'';
if (isset($HTTP_GET_VARS['order'])) {
$MM_param4__panels =3D $HTTP_GET_VARS['order'];
}
$query =3D sprintf("SELECT * FROM %s WHERE utctime AT TIME ZONE 'MST' BETWE=
EN '%s' AND '%s' ORDER BY utctime %s", $MM_param1__panels,$MM_param2__panel=
s,$MM_param3__panels,$MM_param4__panels);
$result =3D pg_exec($query);
$count =3D pg_num_fields($result);
for ($i =3D 0; $i < $count; $i++){
$header .=3D pg_fieldname($result,$i)."\t";
}
while($row =3D pg_fetch_row($result,$result_count++)){
$line =3D '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value =3D "\t";
}else{
# important to escape any quotes to preserve them in the data.
$value =3D str_replace('"', '""', $value);
# needed to encapsulate data in quotes because some data might be multi lin=
e.
# the good news is that numbers remain numbers in Excel even though quoted.
$value =3D '"' . $value . '"' . "\t";
}
$line .=3D $value;
}
$data .=3D trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r"
# and this looks like a "box character" in Excel
$data =3D str_replace("\r", "", $data);
# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.
if ($data == "") {
$data =3D "\nno matching records found\n";
}
# This line will stream the file to the user rather than spray it across th=
e screen
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default to
header("Content-Disposition: attachment; filename=3Dexcelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;=20
?>
Any Help would be appreciated.
Thanks,
Cameron Seader
mailto:CSeader@Idahopower.com
1.208.388.2582 Office
[INFO] -- Access Manager:
This transmission may contain information that is privileged, confidential =
and/or exempt from disclosure under applicable law. If you are not the int=
ended recipient, you are hereby notified that any disclosure, copying, dist=
ribution, or use of the information contained herein (including any relianc=
e thereon) is STRICTLY PROHIBITED. If you received this transmission in err=
or, please immediately contact the sender and destroy the material in its e=
ntirety, whether in electronic or hard copy format. Thank you. A2
---------------------------(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
Re: pg_fetch_row Problem
am 02.03.2004 01:17:25 von Chris Smith
Hi Cameron,
I think the reason is you're going beyond the number of results you have
for that query.
Rewrite the while(...) loop to look like this:
$result_count = 0;
while($result_count < $count) {
$row = pg_fetch_row($result, $result_count);
..........
}
See if that works.
Chris.
-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Seader, Cameron
Sent: Tuesday, March 02, 2004 10:50 AM
To: pgsql-php@postgresql.org
Subject: [PHP] pg_fetch_row Problem
Greetings,
I am not sure what is going on with my script here, but i am getting
this error when i run it.
Warning: pg_fetch_row(): Unable to jump to row 706 on PostgreSQL result
index 3. in /var/www/html/PMS/csv_export.php on line 32
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 59
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 62
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 63
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 64 Can anyone tell me what is
going on here??????? I am including my script here below so you can see
what it is doing, maybe you all can see something im not:
pg_connect("host=172.18.74.10 port=5432 dbname=acquisuite_db
user=pgadmin password=pgadmin")
or die ( 'Unable to
connect to server.' );
printf("Connected
Successfully");
$MM_param1__panels = ''%'';
if (isset($HTTP_GET_VARS['panel'])) {
$MM_param1__panels = $HTTP_GET_VARS['panel'];
}
$MM_param2__panels = ''%'';
if (isset($HTTP_GET_VARS['startdate'])) {
$MM_param2__panels = $HTTP_GET_VARS['startdate'];
}
$MM_param3__panels = ''%'';
if (isset($HTTP_GET_VARS['enddate'])) {
$MM_param3__panels = $HTTP_GET_VARS['enddate'];
}
$MM_param4__panels = ''%'';
if (isset($HTTP_GET_VARS['order'])) {
$MM_param4__panels = $HTTP_GET_VARS['order'];
}
$query = sprintf("SELECT * FROM %s WHERE utctime AT TIME ZONE 'MST'
BETWEEN '%s' AND '%s' ORDER BY utctime %s",
$MM_param1__panels,$MM_param2__panels,$MM_param3__panels,$MM _param4__pan
els);
$result = pg_exec($query);
$count = pg_num_fields($result);
for ($i = 0; $i < $count; $i++){
$header .= pg_fieldname($result,$i)."\t";
}
while($row = pg_fetch_row($result,$result_count++)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
# important to escape any quotes to preserve them in the data.
$value = str_replace('"', '""', $value);
# needed to encapsulate data in quotes because some data might be multi
line. # the good news is that numbers remain numbers in Excel even
though quoted.
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r" #
and this looks like a "box character" in Excel
$data = str_replace("\r", "", $data);
# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel. if
($data == "") {
$data = "\nno matching records found\n";
}
# This line will stream the file to the user rather than spray it across
the screen
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default
to
header("Content-Disposition: attachment; filename=excelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;
?>
Any Help would be appreciated.
Thanks,
Cameron Seader
mailto:CSeader@Idahopower.com
1.208.388.2582 Office
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
---------------------------(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 8: explain analyze is your friend
Re: pg_fetch_row Problem
am 02.03.2004 01:34:26 von CSeader
Chris,
I tryed this out and it works great thanks, but now i get this message.
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html=
/PMS/csv_export.php on line 41
Know where i can set execution times?
is this for PHP or PostgreSQL?
Thanks,
Cameron
-----Original Message-----
From: Chris Smith [mailto:chris@interspire.com]
Sent: Monday, March 01, 2004 5:17 PM
To: Seader, Cameron; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Hi Cameron,
I think the reason is you're going beyond the number of results you have
for that query.
Rewrite the while(...) loop to look like this:
$result_count =3D 0;
while($result_count < $count) {
$row =3D pg_fetch_row($result, $result_count);
..........
}
See if that works.
Chris.
-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Seader, Cameron
Sent: Tuesday, March 02, 2004 10:50 AM
To: pgsql-php@postgresql.org
Subject: [PHP] pg_fetch_row Problem
Greetings,
I am not sure what is going on with my script here, but i am getting
this error when i run it.
Warning: pg_fetch_row(): Unable to jump to row 706 on PostgreSQL result
index 3. in /var/www/html/PMS/csv_export.php on line 32
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 59
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 62
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 63
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 64 Can anyone tell me what is
going on here??????? I am including my script here below so you can see
what it is doing, maybe you all can see something im not:
pg_connect("host=3D172.18.74.10 port=3D5432 dbname=3Dacquisuite_db
user=3Dpgadmin password=3Dpgadmin")=20
or die ( 'Unable to
connect to server.' );=20
printf("Connected
Successfully");
$MM_param1__panels =3D ''%'';
if (isset($HTTP_GET_VARS['panel'])) {
$MM_param1__panels =3D $HTTP_GET_VARS['panel'];
}
$MM_param2__panels =3D ''%'';
if (isset($HTTP_GET_VARS['startdate'])) {
$MM_param2__panels =3D $HTTP_GET_VARS['startdate'];
}
$MM_param3__panels =3D ''%'';
if (isset($HTTP_GET_VARS['enddate'])) {
$MM_param3__panels =3D $HTTP_GET_VARS['enddate'];
}
$MM_param4__panels =3D ''%'';
if (isset($HTTP_GET_VARS['order'])) {
$MM_param4__panels =3D $HTTP_GET_VARS['order'];
}
$query =3D sprintf("SELECT * FROM %s WHERE utctime AT TIME ZONE 'MST'
BETWEEN '%s' AND '%s' ORDER BY utctime %s",
$MM_param1__panels,$MM_param2__panels,$MM_param3__panels,$MM _param4__pan
els);
$result =3D pg_exec($query);
$count =3D pg_num_fields($result);
for ($i =3D 0; $i < $count; $i++){
$header .=3D pg_fieldname($result,$i)."\t";
}
while($row =3D pg_fetch_row($result,$result_count++)){
$line =3D '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value =3D "\t";
}else{
# important to escape any quotes to preserve them in the data.
$value =3D str_replace('"', '""', $value);
# needed to encapsulate data in quotes because some data might be multi
line. # the good news is that numbers remain numbers in Excel even
though quoted.
$value =3D '"' . $value . '"' . "\t";
}
$line .=3D $value;
}
$data .=3D trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r" #
and this looks like a "box character" in Excel
$data =3D str_replace("\r", "", $data);
# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel. if
($data == "") {
$data =3D "\nno matching records found\n";
}
# This line will stream the file to the user rather than spray it across
the screen
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default
to
header("Content-Disposition: attachment; filename=3Dexcelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;=20
?>
Any Help would be appreciated.
Thanks,
Cameron Seader
mailto:CSeader@Idahopower.com
1.208.388.2582 Office
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
---------------------------(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
[INFO] -- Access Manager:
This transmission may contain information that is privileged, confidential =
and/or exempt from disclosure under applicable law. If you are not the int=
ended recipient, you are hereby notified that any disclosure, copying, dist=
ribution, or use of the information contained herein (including any relianc=
e thereon) is STRICTLY PROHIBITED. If you received this transmission in err=
or, please immediately contact the sender and destroy the material in its e=
ntirety, whether in electronic or hard copy format. Thank you. A2
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
Re: pg_fetch_row Problem
am 02.03.2004 01:40:35 von Chris Smith
Hi Cameron,
Excellent :)
The max timeout is a PHP thing - see
http://www.php.net/manual/en/function.set-time-limit.php
Chris.
-----Original Message-----
From: Seader, Cameron [mailto:CSeader@idahopower.com]
Sent: Tuesday, March 02, 2004 11:34 AM
To: Chris Smith; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Chris,
I tryed this out and it works great thanks, but now i get this message.
Fatal error: Maximum execution time of 30 seconds exceeded in
/var/www/html/PMS/csv_export.php on line 41
Know where i can set execution times?
is this for PHP or PostgreSQL?
Thanks,
Cameron
-----Original Message-----
From: Chris Smith [mailto:chris@interspire.com]
Sent: Monday, March 01, 2004 5:17 PM
To: Seader, Cameron; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Hi Cameron,
I think the reason is you're going beyond the number of results you have
for that query.
Rewrite the while(...) loop to look like this:
$result_count = 0;
while($result_count < $count) {
$row = pg_fetch_row($result, $result_count);
..........
}
See if that works.
Chris.
-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Seader, Cameron
Sent: Tuesday, March 02, 2004 10:50 AM
To: pgsql-php@postgresql.org
Subject: [PHP] pg_fetch_row Problem
Greetings,
I am not sure what is going on with my script here, but i am getting
this error when i run it.
Warning: pg_fetch_row(): Unable to jump to row 706 on PostgreSQL result
index 3. in /var/www/html/PMS/csv_export.php on line 32
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 59
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 62
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 63
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 64 Can anyone tell me what is
going on here??????? I am including my script here below so you can see
what it is doing, maybe you all can see something im not:
pg_connect("host=172.18.74.10 port=5432 dbname=acquisuite_db
user=pgadmin password=pgadmin")
or die ( 'Unable to
connect to server.' );
printf("Connected
Successfully");
$MM_param1__panels = ''%'';
if (isset($HTTP_GET_VARS['panel'])) {
$MM_param1__panels = $HTTP_GET_VARS['panel'];
}
$MM_param2__panels = ''%'';
if (isset($HTTP_GET_VARS['startdate'])) {
$MM_param2__panels = $HTTP_GET_VARS['startdate'];
}
$MM_param3__panels = ''%'';
if (isset($HTTP_GET_VARS['enddate'])) {
$MM_param3__panels = $HTTP_GET_VARS['enddate'];
}
$MM_param4__panels = ''%'';
if (isset($HTTP_GET_VARS['order'])) {
$MM_param4__panels = $HTTP_GET_VARS['order'];
}
$query = sprintf("SELECT * FROM %s WHERE utctime AT TIME ZONE 'MST'
BETWEEN '%s' AND '%s' ORDER BY utctime %s",
$MM_param1__panels,$MM_param2__panels,$MM_param3__panels,$MM _param4__pan
els);
$result = pg_exec($query);
$count = pg_num_fields($result);
for ($i = 0; $i < $count; $i++){
$header .= pg_fieldname($result,$i)."\t";
}
while($row = pg_fetch_row($result,$result_count++)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
# important to escape any quotes to preserve them in the data.
$value = str_replace('"', '""', $value);
# needed to encapsulate data in quotes because some data might be multi
line. # the good news is that numbers remain numbers in Excel even
though quoted.
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r" #
and this looks like a "box character" in Excel
$data = str_replace("\r", "", $data);
# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel. if
($data == "") {
$data = "\nno matching records found\n";
}
# This line will stream the file to the user rather than spray it across
the screen
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default
to
header("Content-Disposition: attachment; filename=excelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;
?>
Any Help would be appreciated.
Thanks,
Cameron Seader
mailto:CSeader@Idahopower.com
1.208.388.2582 Office
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
---------------------------(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
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Re: pg_fetch_row Problem
am 02.03.2004 12:47:26 von Adam Alkins
This is a multi-part message in MIME format.
--------------020307070006060207020404
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
set_time_limit(int seconds);
This is a PHP issue. The default value is set in our php.ini file, under
the max_execution_time value. See
http://us3.php.net/manual/en/function.set-time-limit.php
-Adam
Seader, Cameron wrote:
>Chris,
>I tryed this out and it works great thanks, but now i get this message.
>
>Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/PMS/csv_export.php on line 41
>
>Know where i can set execution times?
>is this for PHP or PostgreSQL?
>
>Thanks,
>Cameron
>-----Original Message-----
>From: Chris Smith [mailto:chris@interspire.com]
>Sent: Monday, March 01, 2004 5:17 PM
>To: Seader, Cameron; pgsql-php@postgresql.org
>Subject: RE: [PHP] pg_fetch_row Problem
>
>
>Hi Cameron,
>
>I think the reason is you're going beyond the number of results you have
>for that query.
>
>Rewrite the while(...) loop to look like this:
>
>$result_count = 0;
>while($result_count < $count) {
> $row = pg_fetch_row($result, $result_count);
>.........
>}
>
>See if that works.
>
>Chris.
>
>-----Original Message-----
>From: pgsql-php-owner@postgresql.org
>[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Seader, Cameron
>Sent: Tuesday, March 02, 2004 10:50 AM
>To: pgsql-php@postgresql.org
>Subject: [PHP] pg_fetch_row Problem
>
>
>Greetings,
>I am not sure what is going on with my script here, but i am getting
>this error when i run it.
>Warning: pg_fetch_row(): Unable to jump to row 706 on PostgreSQL result
>index 3. in /var/www/html/PMS/csv_export.php on line 32
>
>Warning: Cannot modify header information - headers already sent by
>(output started at /var/www/html/PMS/csv_export.php:4) in
>/var/www/html/PMS/csv_export.php on line 59
>
>Warning: Cannot modify header information - headers already sent by
>(output started at /var/www/html/PMS/csv_export.php:4) in
>/var/www/html/PMS/csv_export.php on line 62
>
>Warning: Cannot modify header information - headers already sent by
>(output started at /var/www/html/PMS/csv_export.php:4) in
>/var/www/html/PMS/csv_export.php on line 63
>
>Warning: Cannot modify header information - headers already sent by
>(output started at /var/www/html/PMS/csv_export.php:4) in
>/var/www/html/PMS/csv_export.php on line 64 Can anyone tell me what is
>going on here??????? I am including my script here below so you can see
>what it is doing, maybe you all can see something im not:
>pg_connect("host=172.18.74.10 port=5432 dbname=acquisuite_db
>user=pgadmin password=pgadmin")
> or die ( 'Unable to
>connect to server.' );
> printf("Connected
>Successfully");
>
>$MM_param1__panels = ''%'';
>if (isset($HTTP_GET_VARS['panel'])) {
> $MM_param1__panels = $HTTP_GET_VARS['panel'];
>}
>$MM_param2__panels = ''%'';
>if (isset($HTTP_GET_VARS['startdate'])) {
> $MM_param2__panels = $HTTP_GET_VARS['startdate'];
>}
>$MM_param3__panels = ''%'';
>if (isset($HTTP_GET_VARS['enddate'])) {
> $MM_param3__panels = $HTTP_GET_VARS['enddate'];
>}
>$MM_param4__panels = ''%'';
>if (isset($HTTP_GET_VARS['order'])) {
> $MM_param4__panels = $HTTP_GET_VARS['order'];
>}
>
>$query = sprintf("SELECT * FROM %s WHERE utctime AT TIME ZONE 'MST'
>BETWEEN '%s' AND '%s' ORDER BY utctime %s",
>$MM_param1__panels,$MM_param2__panels,$MM_param3__panels,$M M_param4__pan
>els);
>
>$result = pg_exec($query);
>$count = pg_num_fields($result);
>
>for ($i = 0; $i < $count; $i++){
> $header .= pg_fieldname($result,$i)."\t";
>}
>
>while($row = pg_fetch_row($result,$result_count++)){
> $line = '';
> foreach($row as $value){
> if(!isset($value) || $value == ""){
> $value = "\t";
> }else{
># important to escape any quotes to preserve them in the data.
> $value = str_replace('"', '""', $value);
># needed to encapsulate data in quotes because some data might be multi
>line. # the good news is that numbers remain numbers in Excel even
>though quoted.
> $value = '"' . $value . '"' . "\t";
> }
> $line .= $value;
> }
> $data .= trim($line)."\n";
>}
># this line is needed because returns embedded in the data have "\r" #
>and this looks like a "box character" in Excel
> $data = str_replace("\r", "", $data);
>
># Nice to let someone know that the search came up empty.
># Otherwise only the column name headers will be output to Excel. if
>($data == "") {
> $data = "\nno matching records found\n";
>}
>
># This line will stream the file to the user rather than spray it across
>the screen
>header("Content-type: application/octet-stream");
>
># replace excelfile.xls with whatever you want the filename to default
>to
>header("Content-Disposition: attachment; filename=excelfile.xls");
>header("Pragma: no-cache");
>header("Expires: 0");
>
>echo $header."\n".$data;
>?>
>
>Any Help would be appreciated.
>Thanks,
>
>Cameron Seader
>mailto:CSeader@Idahopower.com
>1.208.388.2582 Office
>
>
>
>[INFO] -- Access Manager:
>This transmission may contain information that is privileged,
>confidential and/or exempt from disclosure under applicable law. If you
>are not the intended recipient, you are hereby notified that any
>disclosure, copying, distribution, or use of the information contained
>herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
>received this transmission in error, please immediately contact the
>sender and destroy the material in its entirety, whether in electronic
>or hard copy format. Thank you. A2
>
>
>
>---------------------------(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
>
>
>
>
>
>[INFO] -- Access Manager:
>This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. A2
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
>
>
>
>
--
Adam Alkins
1-868-627-9115
http://www.rasadam.com
--------------020307070006060207020404
Content-Type: text/x-vcard; charset=utf8;
name="postgresql.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="postgresql.vcf"
begin:vcard
fn:Adam Alkins
n:Alkins;Adam
org:Snikla enterprises;I.T.
adr:;;#8 French Street;Woodbrook;;;Trinidad and Tobago
email;internet:postgresql at (@) rasadam dot (.) com
title:PHP Programmer
tel;work:1-868-627-9115
tel;fax:1-868-627-9117
tel;cell:1-868-756-5173
x-mozilla-html:FALSE
url:http://www.snikla.com
version:2.1
end:vcard
--------------020307070006060207020404
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
--------------020307070006060207020404--
Re: pg_fetch_row Problem
am 02.03.2004 14:51:16 von CSeader
Greetings,
I set the set_time_limit function to this
set_time_limit(20*60); // This will set timelimit to 20 minutes.
Wow this script take a long time to execute. Why is it takeing so long?=20
Is there a better way to do this?
-Cameron
-----Original Message-----
From: Chris Smith [mailto:chris@interspire.com]
Sent: Monday, March 01, 2004 5:41 PM
To: Seader, Cameron; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Hi Cameron,
Excellent :)
The max timeout is a PHP thing - see
http://www.php.net/manual/en/function.set-time-limit.php
Chris.
-----Original Message-----
From: Seader, Cameron [mailto:CSeader@idahopower.com]=20
Sent: Tuesday, March 02, 2004 11:34 AM
To: Chris Smith; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Chris,
I tryed this out and it works great thanks, but now i get this message.
Fatal error: Maximum execution time of 30 seconds exceeded in
/var/www/html/PMS/csv_export.php on line 41
Know where i can set execution times?
is this for PHP or PostgreSQL?
Thanks,
Cameron
-----Original Message-----
From: Chris Smith [mailto:chris@interspire.com]
Sent: Monday, March 01, 2004 5:17 PM
To: Seader, Cameron; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Hi Cameron,
I think the reason is you're going beyond the number of results you have
for that query.
Rewrite the while(...) loop to look like this:
$result_count =3D 0;
while($result_count < $count) {
$row =3D pg_fetch_row($result, $result_count);
..........
}
See if that works.
Chris.
-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Seader, Cameron
Sent: Tuesday, March 02, 2004 10:50 AM
To: pgsql-php@postgresql.org
Subject: [PHP] pg_fetch_row Problem
Greetings,
I am not sure what is going on with my script here, but i am getting
this error when i run it.
Warning: pg_fetch_row(): Unable to jump to row 706 on PostgreSQL result
index 3. in /var/www/html/PMS/csv_export.php on line 32
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 59
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 62
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 63
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 64 Can anyone tell me what is
going on here??????? I am including my script here below so you can see
what it is doing, maybe you all can see something im not:
pg_connect("host=3D172.18.74.10 port=3D5432 dbname=3Dacquisuite_db
user=3Dpgadmin password=3Dpgadmin")=20
or die ( 'Unable to
connect to server.' );=20
printf("Connected
Successfully");
$MM_param1__panels =3D ''%'';
if (isset($HTTP_GET_VARS['panel'])) {
$MM_param1__panels =3D $HTTP_GET_VARS['panel'];
}
$MM_param2__panels =3D ''%'';
if (isset($HTTP_GET_VARS['startdate'])) {
$MM_param2__panels =3D $HTTP_GET_VARS['startdate'];
}
$MM_param3__panels =3D ''%'';
if (isset($HTTP_GET_VARS['enddate'])) {
$MM_param3__panels =3D $HTTP_GET_VARS['enddate'];
}
$MM_param4__panels =3D ''%'';
if (isset($HTTP_GET_VARS['order'])) {
$MM_param4__panels =3D $HTTP_GET_VARS['order'];
}
$query =3D sprintf("SELECT * FROM %s WHERE utctime AT TIME ZONE 'MST'
BETWEEN '%s' AND '%s' ORDER BY utctime %s",
$MM_param1__panels,$MM_param2__panels,$MM_param3__panels,$MM _param4__pan
els);
$result =3D pg_exec($query);
$count =3D pg_num_fields($result);
for ($i =3D 0; $i < $count; $i++){
$header .=3D pg_fieldname($result,$i)."\t";
}
while($row =3D pg_fetch_row($result,$result_count++)){
$line =3D '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value =3D "\t";
}else{
# important to escape any quotes to preserve them in the data.
$value =3D str_replace('"', '""', $value);
# needed to encapsulate data in quotes because some data might be multi
line. # the good news is that numbers remain numbers in Excel even
though quoted.
$value =3D '"' . $value . '"' . "\t";
}
$line .=3D $value;
}
$data .=3D trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r" #
and this looks like a "box character" in Excel
$data =3D str_replace("\r", "", $data);
# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel. if
($data == "") {
$data =3D "\nno matching records found\n";
}
# This line will stream the file to the user rather than spray it across
the screen
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default
to
header("Content-Disposition: attachment; filename=3Dexcelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;=20
?>
Any Help would be appreciated.
Thanks,
Cameron Seader
mailto:CSeader@Idahopower.com
1.208.388.2582 Office
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
---------------------------(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
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
[INFO] -- Access Manager:
This transmission may contain information that is privileged, confidential =
and/or exempt from disclosure under applicable law. If you are not the int=
ended recipient, you are hereby notified that any disclosure, copying, dist=
ribution, or use of the information contained herein (including any relianc=
e thereon) is STRICTLY PROHIBITED. If you received this transmission in err=
or, please immediately contact the sender and destroy the material in its e=
ntirety, whether in electronic or hard copy format. Thank you. A2
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Re: pg_fetch_row Problem
am 02.03.2004 23:08:32 von Chris Smith
Hi Cameron,
It will take a long time unless you have some indexes on your fields -
even then depending on how much data you have :)
Echo out the query it's running and speed that up - using 'explain' is
the easiest way to work out what's going on. See
http://www.postgresql.org/docs/7.4/static/indexes-examine.ht ml for more
info on explain.
You'll most likely need to add an index on whichever field gets compared
for startdate and enddate (at least) ....
Apart from that without seeing the proper query it runs and the database
table schema we're just guessing.
Chris.
-----Original Message-----
From: Seader, Cameron [mailto:CSeader@idahopower.com]
Sent: Wednesday, March 03, 2004 12:51 AM
To: Chris Smith; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Greetings,
I set the set_time_limit function to this set_time_limit(20*60); // This
will set timelimit to 20 minutes.
Wow this script take a long time to execute. Why is it takeing so long?
Is there a better way to do this?
-Cameron
-----Original Message-----
From: Chris Smith [mailto:chris@interspire.com]
Sent: Monday, March 01, 2004 5:41 PM
To: Seader, Cameron; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Hi Cameron,
Excellent :)
The max timeout is a PHP thing - see
http://www.php.net/manual/en/function.set-time-limit.php
Chris.
-----Original Message-----
From: Seader, Cameron [mailto:CSeader@idahopower.com]
Sent: Tuesday, March 02, 2004 11:34 AM
To: Chris Smith; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Chris,
I tryed this out and it works great thanks, but now i get this message.
Fatal error: Maximum execution time of 30 seconds exceeded in
/var/www/html/PMS/csv_export.php on line 41
Know where i can set execution times?
is this for PHP or PostgreSQL?
Thanks,
Cameron
-----Original Message-----
From: Chris Smith [mailto:chris@interspire.com]
Sent: Monday, March 01, 2004 5:17 PM
To: Seader, Cameron; pgsql-php@postgresql.org
Subject: RE: [PHP] pg_fetch_row Problem
Hi Cameron,
I think the reason is you're going beyond the number of results you have
for that query.
Rewrite the while(...) loop to look like this:
$result_count = 0;
while($result_count < $count) {
$row = pg_fetch_row($result, $result_count);
..........
}
See if that works.
Chris.
-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Seader, Cameron
Sent: Tuesday, March 02, 2004 10:50 AM
To: pgsql-php@postgresql.org
Subject: [PHP] pg_fetch_row Problem
Greetings,
I am not sure what is going on with my script here, but i am getting
this error when i run it.
Warning: pg_fetch_row(): Unable to jump to row 706 on PostgreSQL result
index 3. in /var/www/html/PMS/csv_export.php on line 32
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 59
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 62
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 63
Warning: Cannot modify header information - headers already sent by
(output started at /var/www/html/PMS/csv_export.php:4) in
/var/www/html/PMS/csv_export.php on line 64 Can anyone tell me what is
going on here??????? I am including my script here below so you can see
what it is doing, maybe you all can see something im not:
pg_connect("host=172.18.74.10 port=5432 dbname=acquisuite_db
user=pgadmin password=pgadmin")
or die ( 'Unable to
connect to server.' );
printf("Connected
Successfully");
$MM_param1__panels = ''%'';
if (isset($HTTP_GET_VARS['panel'])) {
$MM_param1__panels = $HTTP_GET_VARS['panel'];
}
$MM_param2__panels = ''%'';
if (isset($HTTP_GET_VARS['startdate'])) {
$MM_param2__panels = $HTTP_GET_VARS['startdate'];
}
$MM_param3__panels = ''%'';
if (isset($HTTP_GET_VARS['enddate'])) {
$MM_param3__panels = $HTTP_GET_VARS['enddate'];
}
$MM_param4__panels = ''%'';
if (isset($HTTP_GET_VARS['order'])) {
$MM_param4__panels = $HTTP_GET_VARS['order'];
}
$query = sprintf("SELECT * FROM %s WHERE utctime AT TIME ZONE 'MST'
BETWEEN '%s' AND '%s' ORDER BY utctime %s",
$MM_param1__panels,$MM_param2__panels,$MM_param3__panels,$MM _param4__pan
els);
$result = pg_exec($query);
$count = pg_num_fields($result);
for ($i = 0; $i < $count; $i++){
$header .= pg_fieldname($result,$i)."\t";
}
while($row = pg_fetch_row($result,$result_count++)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
# important to escape any quotes to preserve them in the data.
$value = str_replace('"', '""', $value);
# needed to encapsulate data in quotes because some data might be multi
line. # the good news is that numbers remain numbers in Excel even
though quoted.
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r" #
and this looks like a "box character" in Excel
$data = str_replace("\r", "", $data);
# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel. if
($data == "") {
$data = "\nno matching records found\n";
}
# This line will stream the file to the user rather than spray it across
the screen
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default
to
header("Content-Disposition: attachment; filename=excelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;
?>
Any Help would be appreciated.
Thanks,
Cameron Seader
mailto:CSeader@Idahopower.com
1.208.388.2582 Office
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
---------------------------(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
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
[INFO] -- Access Manager:
This transmission may contain information that is privileged,
confidential and/or exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any
disclosure, copying, distribution, or use of the information contained
herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
received this transmission in error, please immediately contact the
sender and destroy the material in its entirety, whether in electronic
or hard copy format. Thank you. A2
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org