Re: [PHP] resetting pg_fetch_array

2005-02-22 Thread Dave O
Richard Lynch wrote:
Dave O wrote:
Hi all.  I'm been trying the following code for the past day or so and I
 can't seem to get around it.  I'm issuing a query to pgsql and
iterating  through the results twice in order to facilitate the
separation of shipment history.
Below is the simplest example I can come up with.  The results only
display once, even though I'm not issuing any other db calls after the
1st iteration and the resouce id remains the same.  Heck, even
pg_num_rows returns the same result twice, but the results just won't
display a second time.
I'm running this on freebsd 5.3 using pgsql v8 and php 4.3.10.  Anybody
got any suggestions.  TIA.
Dave
table looptest
 rownum | rowstr
+
  1 | aa
  2 | bb
  3 | cc
  4 | dd
include ('connection.inc.php');
$sql = "SELECT rownum, rowstr FROM looptest";
$result = pg_query($conn, $sql);
$c=2;
$x=0;
echo "\n";
while ($x<$c)
{
echo pg_num_rows($result) . "->";
print_r($result);
echo "\n\n";
reset($result);
while($row = pg_fetch_array($result))

This automatically advances an internal "counter" to the next row.
You never "rewind" the counter.
[Be kind, rewind!]
You can either find the pg_data_seek function that does the rewind, or you
   ^  ^  ^  ^
 pg_result_seek ???
can do a counter yourself and pass in the optional row number argument to
pg_fetch_array:
$row_num = 0;
while ($row = pg_fetch_array($result, $row_num++))
The reset function you are using is for ARRAYS, and has nothing to do with
pg resources and database result sets.
I'm surprise you are not getting some kind of error on that...
Or maybe you aren't using 'error_reporting(E_ALL)' like you should.

 stuff snipped
Yep, pg_result_seek did the trick.  Using:
pg_result_seek($result, 0)
..just before the 'while' statement makes the results show up twice.  I 
reread the manual page for this and understood there was a counter, but 
it didn't click that there might be a pg function to handle this.  I 
took the mention of "array" too seriously and was looking under the 
array functions.

Btw, E_ALL is set, but following suggestions in these lists and the 
site, I've it set to log to a file and not display any errors.  That's 
probably something to reconsider for development.

Thanks for the help Richard.  Much appreciated.
Dave
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] resetting pg_fetch_array

2005-02-22 Thread Dave O
Hi all.  I'm been trying the following code for the past day or so and I 
 can't seem to get around it.  I'm issuing a query to pgsql and 
iterating  through the results twice in order to facilitate the 
separation of shipment history.

Below is the simplest example I can come up with.  The results only 
display once, even though I'm not issuing any other db calls after the 
1st iteration and the resouce id remains the same.  Heck, even 
pg_num_rows returns the same result twice, but the results just won't 
display a second time.

I'm running this on freebsd 5.3 using pgsql v8 and php 4.3.10.  Anybody 
got any suggestions.  TIA.

Dave
table looptest
 rownum | rowstr
+
  1 | aa
  2 | bb
  3 | cc
  4 | dd
include ('connection.inc.php');
$sql = "SELECT rownum, rowstr FROM looptest";
$result = pg_query($conn, $sql);
$c=2;
$x=0;
echo "\n";
while ($x<$c)
{
echo pg_num_rows($result) . "->";
print_r($result);
echo "\n\n";
reset($result);
while($row = pg_fetch_array($result))
{
echo $row["rownum"] . " -> " . $row["rowstr"] . " \n";
} 

echo "\n"; 

$x++; 

} 

echo "\n";
--
results
--
4->Resource id #4
1 -> aa
2 -> bb
3 -> cc
4 -> dd

4->Resource id #4

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Problem deleting a cookie...

2004-02-23 Thread Dave O
Forgot to -cc the list.
André Cerqueira wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
 > Here's what I use to set the cookie.
 > $value=(time() + 9000) . ":$uid:$username:$gid:$fullname";
 > SetCookie("Trackookie", $value, 0, "", "server.mssystems.com" );
 >
 > Here's what I use to delete the cookie.
 > SetCookie("Trackookie", "", time()-3600, "", "support.mssystems.com");
the domain is different
one of them uses one domain for creating and deleting, the other uses 
the other domain, right?
check that...


Sorry, didn't proofread my initial message.  I wish it were that easy as 
what you pointed out.  Here are the actual commands used in the script

Server 1 (support.mssystems.com)

Set cookie:
$value=(time() + 9000) . ":$uid:$username:$gid:$fullname";
SetCookie("Trackookie", $value, 0, "", "support.mssystems.com" );
Delete cookie:
SetCookie("Trackookie", "", time()-3600, "", "support.mssystems.com" );
Server 2 (token.mssystems.com)

Set cookie:
$value=(time() + 9000) . ":$uid:$username:$gid:$fullname";
SetCookie("Trackookie", $value, 0, "", "token.mssystems.com" );
Delete cookie:
SetCookie("Trackookie", "", time()-3600, "", "token.mssystems.com" );
As I stated in the initial post, the only difference between the two 
servers is the apache version (1.3.29 vs 2.0.48).  These are virtual 
hosts and the php directives are the same for both servers.  This just 
seems very puzzling.

do

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Problem deleting a cookie...

2004-02-23 Thread Dave O
Hi all.  I'm currently experiencing a problem deleting cookies on a test 
server.  Before I go on, here's the server info:

Server 1
--
Apache 1.3.29
PHP Version 4.3.4
Server 2
--
Apache 2.0.48
PHP Version 4.3.4
Previously running PHP 5.0.0.a4
I've got a technical support app running on Server 1.  Well I wanted to 
add some features and started playing around with PHP 5 and Apache 2 on 
Server 2.  So, I tried out some of my scripts that used the following 
for using cookies.

Here's what I use to set the cookie.
$value=(time() + 9000) . ":$uid:$username:$gid:$fullname";
SetCookie("Trackookie", $value, 0, "", "server.mssystems.com" );
Here's what I use to delete the cookie.
SetCookie("Trackookie", "", time()-3600, "", "support.mssystems.com" );
Now, creating the cookie is no problem.  Deleting the cookie is where I 
started having problems on Server 2.  At first, I thought it was PHP5 so 
I went to PHP4.  However, I still kept having the same problem.

Looking at the headers using Mozilla Live-Headers I was able to see that 
this was sent from both servers:

Set-Cookie: Trackookie=deleted; expires=Sun, 23-Feb-2003 22:47:22 GMT; 
domain=server.mssystems.com

However, if I look at the Mozilla cookie manager, I still see the cookie 
there for Server 2.  If I try the same thing on Server 1, the cookie 
gets deleted without any problems.

I suspect it may be due to my using Apache 2 and downgrading won't be a 
problem, but I wanted to check first if anyone had been experiencing the 
same problems.

I should add, though, that I was a little overzealous and added quite a 
few extensions on Server 2 in order to experiment with them.  Have there 
been any reports of extensions causing confllicts with cookies.

Thanks and I appreciate any general comments or advice about this.

do

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] GD2 Bundled with PHP v 4.3.2

2003-05-30 Thread Dave O Keeffe
Hi All,

I read in the ChangeLog for v4.3.2 that GD2 is bundled with this release.  I 
downloaded and installed the Windows Installer version but my sample 
imagecreate code still doesn't work, it reports the error 'Call to undefined 
function: imagecreate()'.

When I uncomment the ;extension=php_gd2.dll line in php.ini I get a error 
message saying this file cannot be found, which is no surprise seeing as 
it's nowhere on my machine.

Is GD actually bundled with the windows version or do I have to compile it 
myself?

Thanks for any help...

_
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php