php-general Digest 26 Oct 2002 16:54:49 -0000 Issue 1667

Topics (messages 121513 through 121528):

ftp_problem - ... php_network_getaddresses: getaddrinfo failed: ...
        121513 by: vic
        121514 by: John Nichel
        121515 by: vic
        121516 by: John Nichel
        121517 by: vic
        121518 by: vic

Re: Couple of questions
        121519 by: Jason Wong

Re: ldap_add problem
        121520 by: Stig Venaas

parsing conundrum
        121521 by: Peter Harkins

mysql_fetch_row options
        121522 by: James Taylor
        121523 by: Tom Rogers
        121524 by: Jason Wong

Re: PHP Session register variable not always restored with contents
        121525 by: Victor Soroka

<script language=php???
        121526 by: Jason Porembski
        121527 by: John Nichel

passthru problems generating WAVs with mpg123
        121528 by: soren.byu.edu

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Never mind, problem NOT solved, I made an error in an earlier script and
that error interrupted this one so I thought it cleared, but alas, it
did not, so help still needed, if available, thanks.

- Victor | www.argilent.com  

-----Original Message-----
From: vic [mailto:siliconhype@;yahoo.ca] 
Sent: Saturday, October 26, 2002 12:48 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] ftp_problem - ... php_network_getaddresses:
getaddrinfo failed: ...

Ok, found problem, script ok, but a $_POST['...']; needed to be added to
the secure script as it was taking the pass from a form.

- Victor | www.argilent.com  

-----Original Message-----
From: victor [mailto:victor@;argilent.com] 
Sent: Saturday, October 26, 2002 12:34 AM
To: [EMAIL PROTECTED]
Subject: [PHP] ftp_problem - ... php_network_getaddresses: getaddrinfo
failed: ...

Any tips on trouble shooting this problem?

        Warning: php_network_getaddresses: getaddrinfo failed: Name or
service         not known in /xxx/xxx/xxx/xxx/new_user.php on line 121
        Could not establish FTP connection.

This is the code the error refers to:

        # set up basic connection
        $conn_id = ftp_connect($ftp_server)
        or die ('Could not establish FTP connection.');

The config file is somewhere else on the server - outside the public dir
for sec. reasons.

The info is correct. - I cannot divulge it, but it is correct (or let's
assume it is), so where to now???

- Victor | www.argilent.com  


______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message --- Can you ftp to the site from the box that the script is running on (via command line or GUI client)?

vic wrote:
Never mind, problem NOT solved, I made an error in an earlier script and
that error interrupted this one so I thought it cleared, but alas, it
did not, so help still needed, if available, thanks.

- Victor | www.argilent.com
-----Original Message-----
From: vic [mailto:siliconhype@;yahoo.ca] Sent: Saturday, October 26, 2002 12:48 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] ftp_problem - ... php_network_getaddresses:
getaddrinfo failed: ...

Ok, found problem, script ok, but a $_POST['...']; needed to be added to
the secure script as it was taking the pass from a form.

- Victor | www.argilent.com
-----Original Message-----
From: victor [mailto:victor@;argilent.com] Sent: Saturday, October 26, 2002 12:34 AM
To: [EMAIL PROTECTED]
Subject: [PHP] ftp_problem - ... php_network_getaddresses: getaddrinfo
failed: ...

Any tips on trouble shooting this problem?

Warning: php_network_getaddresses: getaddrinfo failed: Name or
service not known in /xxx/xxx/xxx/xxx/new_user.php on line 121
Could not establish FTP connection.

This is the code the error refers to:

# set up basic connection
$conn_id = ftp_connect($ftp_server)
or die ('Could not establish FTP connection.');

The config file is somewhere else on the server - outside the public dir
for sec. reasons.

The info is correct. - I cannot divulge it, but it is correct (or let's
assume it is), so where to now???

- Victor | www.argilent.com

______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca


--- End Message ---
--- Begin Message ---
Could this be the problem?

>From the pho.net documentation on ftp_connect():

"

I think what some other posts were trying to say which may need
clarification is that in PHP 4.2.3, ftp_connect("myhost.com") was
failing most of the time, except it would work like every few minutes.

The fix is that ftp_connect seems to have a bug resolving addresses. If
you do:

$hostip = gethostbyname($host);
$conn_id = ftp_connect($hostip);

It seems to solve the problem.
(Other users referred to an ftpbuf() error... not sure what that is, but
this should fix it.)

"

- Victor | www.argilent.com  

-----Original Message-----
From: John Nichel [mailto:jnichel@;by-tor.com] 
Sent: Saturday, October 26, 2002 1:07 AM
To: vic
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] ftp_problem - ... php_network_getaddresses:
getaddrinfo failed: ...

Can you ftp to the site from the box that the script is running on (via 
command line or GUI client)?

vic wrote:
> Never mind, problem NOT solved, I made an error in an earlier script
and
> that error interrupted this one so I thought it cleared, but alas, it
> did not, so help still needed, if available, thanks.
> 
> - Victor | www.argilent.com  
> 
> -----Original Message-----
> From: vic [mailto:siliconhype@;yahoo.ca] 
> Sent: Saturday, October 26, 2002 12:48 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: [PHP] ftp_problem - ... php_network_getaddresses:
> getaddrinfo failed: ...
> 
> Ok, found problem, script ok, but a $_POST['...']; needed to be added
to
> the secure script as it was taking the pass from a form.
> 
> - Victor | www.argilent.com  
> 
> -----Original Message-----
> From: victor [mailto:victor@;argilent.com] 
> Sent: Saturday, October 26, 2002 12:34 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] ftp_problem - ... php_network_getaddresses: getaddrinfo
> failed: ...
> 
> Any tips on trouble shooting this problem?
> 
>       Warning: php_network_getaddresses: getaddrinfo failed: Name or
> service       not known in /xxx/xxx/xxx/xxx/new_user.php on line 121
>       Could not establish FTP connection.
> 
> This is the code the error refers to:
> 
>       # set up basic connection
>       $conn_id = ftp_connect($ftp_server)
>       or die ('Could not establish FTP connection.');
> 
> The config file is somewhere else on the server - outside the public
dir
> for sec. reasons.
> 
> The info is correct. - I cannot divulge it, but it is correct (or
let's
> assume it is), so where to now???
> 
> - Victor | www.argilent.com  
> 
> 
> ______________________________________________________________________

> Post your free ad now! http://personals.yahoo.ca
> 



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

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Yes, if the machine can't get to the site, then php won't be able too.

vic wrote:
Could this be the problem?




--- End Message ---
--- Begin Message ---
        So I tried this and I still get the setup id error. And to
answer your question I have to get SSL going but there is too much work
for that tonight, and my server doesn't allow telneting without SSL (and
good for them).
        
        # set up basic connection
        $hostip = gethostbyname($ftp_server)
        or die ('Could not get FRP server IP');
        
        echo ($hostip); 
        # this apparently only adds "ftp." before $ftp_server
        
        $conn_id = ftp_connect($hostip)
        or die ('Could not establish FTP connection.');

- Victor | www.argilent.com  

-----Original Message-----
From: vic [mailto:siliconhype@;yahoo.ca] 
Sent: Saturday, October 26, 2002 1:30 AM
To: 'John Nichel'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] ftp_problem - ... php_network_getaddresses:
getaddrinfo failed: ...

Could this be the problem?

>From the pho.net documentation on ftp_connect():

"

I think what some other posts were trying to say which may need
clarification is that in PHP 4.2.3, ftp_connect("myhost.com") was
failing most of the time, except it would work like every few minutes.

The fix is that ftp_connect seems to have a bug resolving addresses. If
you do:

$hostip = gethostbyname($host);
$conn_id = ftp_connect($hostip);

It seems to solve the problem.
(Other users referred to an ftpbuf() error... not sure what that is, but
this should fix it.)

"

- Victor | www.argilent.com  

-----Original Message-----
From: John Nichel [mailto:jnichel@;by-tor.com] 
Sent: Saturday, October 26, 2002 1:07 AM
To: vic
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] ftp_problem - ... php_network_getaddresses:
getaddrinfo failed: ...

Can you ftp to the site from the box that the script is running on (via 
command line or GUI client)?

vic wrote:
> Never mind, problem NOT solved, I made an error in an earlier script
and
> that error interrupted this one so I thought it cleared, but alas, it
> did not, so help still needed, if available, thanks.
> 
> - Victor | www.argilent.com  
> 
> -----Original Message-----
> From: vic [mailto:siliconhype@;yahoo.ca] 
> Sent: Saturday, October 26, 2002 12:48 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: [PHP] ftp_problem - ... php_network_getaddresses:
> getaddrinfo failed: ...
> 
> Ok, found problem, script ok, but a $_POST['...']; needed to be added
to
> the secure script as it was taking the pass from a form.
> 
> - Victor | www.argilent.com  
> 
> -----Original Message-----
> From: victor [mailto:victor@;argilent.com] 
> Sent: Saturday, October 26, 2002 12:34 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] ftp_problem - ... php_network_getaddresses: getaddrinfo
> failed: ...
> 
> Any tips on trouble shooting this problem?
> 
>       Warning: php_network_getaddresses: getaddrinfo failed: Name or
> service       not known in /xxx/xxx/xxx/xxx/new_user.php on line 121
>       Could not establish FTP connection.
> 
> This is the code the error refers to:
> 
>       # set up basic connection
>       $conn_id = ftp_connect($ftp_server)
>       or die ('Could not establish FTP connection.');
> 
> The config file is somewhere else on the server - outside the public
dir
> for sec. reasons.
> 
> The info is correct. - I cannot divulge it, but it is correct (or
let's
> assume it is), so where to now???
> 
> - Victor | www.argilent.com  
> 
> 
> ______________________________________________________________________

> Post your free ad now! http://personals.yahoo.ca
> 



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

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

______________________________________________________________________ 
Post your ad for free now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
By: "...ll get the setup id error. And to answ..." I meant "... stupid
...".

- Victor | www.argilent.com  

-----Original Message-----
From: vic [mailto:siliconhype@;yahoo.ca] 
Sent: Saturday, October 26, 2002 1:36 AM
To: 'vic'; 'John Nichel'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] ftp_problem - ... php_network_getaddresses:
getaddrinfo failed: ...

        So I tried this and I still get the setup id error. And to
answer your question I have to get SSL going but there is too much work
for that tonight, and my server doesn't allow telneting without SSL (and
good for them).
        
        # set up basic connection
        $hostip = gethostbyname($ftp_server)
        or die ('Could not get FRP server IP');
        
        echo ($hostip); 
        # this apparently only adds "ftp." before $ftp_server
        
        $conn_id = ftp_connect($hostip)
        or die ('Could not establish FTP connection.');

- Victor | www.argilent.com  

-----Original Message-----
From: vic [mailto:siliconhype@;yahoo.ca] 
Sent: Saturday, October 26, 2002 1:30 AM
To: 'John Nichel'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] ftp_problem - ... php_network_getaddresses:
getaddrinfo failed: ...

Could this be the problem?

>From the pho.net documentation on ftp_connect():

"

I think what some other posts were trying to say which may need
clarification is that in PHP 4.2.3, ftp_connect("myhost.com") was
failing most of the time, except it would work like every few minutes.

The fix is that ftp_connect seems to have a bug resolving addresses. If
you do:

$hostip = gethostbyname($host);
$conn_id = ftp_connect($hostip);

It seems to solve the problem.
(Other users referred to an ftpbuf() error... not sure what that is, but
this should fix it.)

"

- Victor | www.argilent.com  

-----Original Message-----
From: John Nichel [mailto:jnichel@;by-tor.com] 
Sent: Saturday, October 26, 2002 1:07 AM
To: vic
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] ftp_problem - ... php_network_getaddresses:
getaddrinfo failed: ...

Can you ftp to the site from the box that the script is running on (via 
command line or GUI client)?

vic wrote:
> Never mind, problem NOT solved, I made an error in an earlier script
and
> that error interrupted this one so I thought it cleared, but alas, it
> did not, so help still needed, if available, thanks.
> 
> - Victor | www.argilent.com  
> 
> -----Original Message-----
> From: vic [mailto:siliconhype@;yahoo.ca] 
> Sent: Saturday, October 26, 2002 12:48 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: RE: [PHP] ftp_problem - ... php_network_getaddresses:
> getaddrinfo failed: ...
> 
> Ok, found problem, script ok, but a $_POST['...']; needed to be added
to
> the secure script as it was taking the pass from a form.
> 
> - Victor | www.argilent.com  
> 
> -----Original Message-----
> From: victor [mailto:victor@;argilent.com] 
> Sent: Saturday, October 26, 2002 12:34 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] ftp_problem - ... php_network_getaddresses: getaddrinfo
> failed: ...
> 
> Any tips on trouble shooting this problem?
> 
>       Warning: php_network_getaddresses: getaddrinfo failed: Name or
> service       not known in /xxx/xxx/xxx/xxx/new_user.php on line 121
>       Could not establish FTP connection.
> 
> This is the code the error refers to:
> 
>       # set up basic connection
>       $conn_id = ftp_connect($ftp_server)
>       or die ('Could not establish FTP connection.');
> 
> The config file is somewhere else on the server - outside the public
dir
> for sec. reasons.
> 
> The info is correct. - I cannot divulge it, but it is correct (or
let's
> assume it is), so where to now???
> 
> - Victor | www.argilent.com  
> 
> 
> ______________________________________________________________________

> Post your free ad now! http://personals.yahoo.ca
> 



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

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca

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

______________________________________________________________________ 
Post your ad for free now! http://personals.yahoo.ca

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

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
On Friday 25 October 2002 02:04, Chris Boget wrote:
> > 1)  Does anyone know of a JS mailing list that actually has a good
> > amount of traffic (receives more than 10 email messages a day)?
>
> Dunno

google -> javascript weenie

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Pound for pound, the amoeba is the most vicious animal on earth.
*/

--- End Message ---
--- Begin Message ---
On Thu, Oct 24, 2002 at 04:37:56PM -0400, GC wrote:
> Hi, I wrote a simple page that tries to enter a string into a LDAP server.
> I get the following error:
> 
> Warning: LDAP: add operation could not be completed. in
> /var/www/html/user/adduser_p.php on line 65
> 
> Where in my log files can I go to look for more detailed info on that error,
> I don't know if I have logging enabled for slapd.  Thanks!!

There are a number of things that could be wrong, but the most likely
is access rights I suppose. The best way to solve this is indeed to
turn on more logging in slapd if necessary. Please see slapd
docs for how to do this.

Stig
--- End Message ---
--- Begin Message ---
        If you know what recursion is and like a challege, here's a puzzle
to keep you up nights. If not, you'll probably just want to mutter to
yourself "what a poor, unlucky bastard" and pass on by.

        I'm parsing some data files into a PHP array and am stumped. I'm at
a loss for how to do this without grinding through character by character.
That would work, but my subconcious is nagging at me that there's got to be
a more elegant way to do it that I'm just not seeing, so I'm going to
describe the problem and ask for help before I start grinding.

        The app I'm getting this from has 4 data types: int, string, array
and mapping (associative array). 

        Ints and strings are pretty straightforward, but there's no way to
tell 0 from null int or null string. This is an annoying limitation of the
app that just has to be ignored and dealt with by whatever gets this data
from us. This (among other reasons) make me glad PHP is weakly-typed.

        Arrays are indexed from 0 and values can mix ints and strings
freely.

        To start, mappings are arrays indexed by ints or strings. Mappings
aren't just arrays, though, they have a "width" (which is really a nested
array that I'm pretty certain is an ugly historical artifact.) Width allows
multiple values for one key and must be the same for all values in a
mapping, though the values (both of keys and their values) don't have to be
of the same type. Mappings can also mix ints and strings.

        The tough part is that arrays and mappings can nest inside of each
other and the only characters quoted in strings are \, " and \n. This means
recursion must be used, but I just can't figure out a way to find the
boundaries of each element. Anyone with a clean way to do this (probably
with some kind of crazy regexp) will recieve my awe and gratitude.

        Here's an example file[1]:

null_string 0
some_string "Fourscore and seven years ago..."
unset_int 0
an_int 42
negative_int -12
null_array ({ })
null_mapping ([ ])
easy_array ({9,22,"test",})
easy_mapping (["string":3,"foo":"bar",[12]:"I am not a crook!",])
medium_array ({"a string, containing a comma and a \"",23,})
medium_mapping (["str\"ing":3;5;7, 9:"Read my lips.";11;13;,])
hard_array ({"comma, string",({3,4,5,}),({"'\"str'",4,({3,4,({ }),}),}),})
hard_mapping ([17:"str";15,"foo":([ ]);17,"b'l\\a\nh":19;([21:23,]),"tour de 
force":({29,31});({([ ])}),])

        You may notice the last one is pathological[2]. Yes, PHP will really
let you use " and \n in array keys. The real data do sometimes get about
this complex; consider this a compressed version. As a fun fact, I've
learned vim's % command doesn't work when there's an odd number of double
quotes between your parens/braces.

        Calling print_r on the array this generates would return:

Array
(
    [null_string] => 0
    [some_string] => "Fourscore and seven years ago..."
    [unset_int] => 0
    [an_int] => 42
    [negative_int] => -12
    [null_array] => Array
        (
        )

    [null_mapping] => Array
        (
        )

    [easy_array] => Array
        (
               [0] => 9
               [1] => 22
               [0] => test
        )

    [easy_mapping] => Array
        (
               [string] => 3
               [foo] => "bar"
               [12] => "I am not a crook!"
        )

    [medium_array] => Array
        (
               [0] => a string, containing a comma and a "
               [1] => 23
        )

    [medium_mapping] => Array
        (
               [string] => Array
                   (
                        [0] => 3
                        [1] => 5
                        [2] => 7
                   )

               [9] => Array
                   (
                        [0] => Read my lips.
                        [1] => 11
                        [2] => 13
                   )

        )

    [hard_array] => Array
        (
               [0] => comma, string
               [1] => Array
                   (
                        [0] => 3
                        [1] => 4
                        [2] => 5
                   )

               [2] => Array
                   (
                        [0] => '"str'
                        [1] => 4
                        [2] => Array
                            (
                                [0] => 3
                                [1] => 4
                                [2] => Array
                                    (
                                    )

                            )

                   )

        )

    [hard_mapping] => Array
        (
             [17] => Array
                 (
                     [0] => str
                     [1] => 15
                 )

             [foo] => Array
                 (
                     [0] => Array
                         (
                         )

                     [1] => 17
                 )

             [b'l\a\nh] => Array
                 (
                     [0] => 19
                     [1] => Array
                         (
                             [21] => 23
                         )

                 )

             [tour de force] => Array
                 (
                     [0] => Array
                         (
                             [29] => 31
                         )

                     [1] => Array
                         (
                             [0] => Array
                                 (
                                 )
                         )

                 )

        )

)

        The truly eagle-eyed will note that print_r doesn't really escape \n
when outputting, which is ugly and should probably have a bug report filed
on it. I've ignored this behavior of print_r to produce more readable
output.

        Anyone who gets the 'tour de force' can contact me for the 'victory
lap' puzzle if it didn't occur to them while solving this one. It's equally
frustrating.

[1] Brownie points to anyone who recognizes the app that outputs this data
format. Yep, I'm doing web integration. Feel free to contact me off-list if
you've any ideas/code to share or would like to see what I'm doing. Yes,
technically, mappings can be indexed by an array or mapping. I've ignored
this because 1. PHP can't do this and 2. Anyone doing this will be dragged
out into the street and shot.

[2] http://tuxedo.org/~esr/jargon/html/entry/pathological.html
--- End Message ---
--- Begin Message ---
There's got to be a better way to go about this: I am constantly doing mysql
queries where I am doing
a count(), so a sample query would be like this: "select count(*) from
database".  I'm expecting only
ONE value back exactly, and that's the count results.  However, to get this
data into a variable, i'm
having to write code like this:

$result = mysql_query("select count(*) from database", $db);
$myrow = mysql_fetch_row($result);
$staticvar += $myrow[0];

$staticvar will never be an array, it's just a simple variable storing a
number.  I *could* do it like this:

$result = mysql_query("select * from database", $db);
$staticvar += mysql_num_rows($result);

However, the mysql query will be much, much slower if I do it like this.

Basically, what I'm asking, is how to do something like:

$staticvar += mysql_fetch_row($result);

I want to eliminate step two, and I don't want to involve any temporary
arrays when there's always just one
value.  Any suggestions? Thanks a bunch!

--- End Message ---
--- Begin Message ---
Hi,

Saturday, October 26, 2002, 8:23:23 PM, you wrote:
JT> There's got to be a better way to go about this: I am constantly doing mysql
JT> queries where I am doing
JT> a count(), so a sample query would be like this: "select count(*) from
JT> database".  I'm expecting only
JT> ONE value back exactly, and that's the count results.  However, to get this
JT> data into a variable, i'm
JT> having to write code like this:

JT> $result = mysql_query("select count(*) from database", $db);
JT> $myrow = mysql_fetch_row($result);
JT> $staticvar += $myrow[0];

JT> $staticvar will never be an array, it's just a simple variable storing a
JT> number.  I *could* do it like this:

JT> $result = mysql_query("select * from database", $db);
JT> $staticvar += mysql_num_rows($result);

JT> However, the mysql query will be much, much slower if I do it like this.

JT> Basically, what I'm asking, is how to do something like:

JT> $staticvar += mysql_fetch_row($result);

JT> I want to eliminate step two, and I don't want to involve any temporary
JT> arrays when there's always just one
JT> value.  Any suggestions? Thanks a bunch!

(untested :)

$result = mysql_query("select count(*) as cnt from database", $db);
$staticvar += mysql_result($result,0,0);

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
On Saturday 26 October 2002 18:23, James Taylor wrote:
> There's got to be a better way to go about this: I am constantly doing
> mysql queries where I am doing
> a count(), so a sample query would be like this: "select count(*) from
> database".  I'm expecting only
> ONE value back exactly, and that's the count results.  However, to get this
> data into a variable, i'm
> having to write code like this:
>
> $result = mysql_query("select count(*) from database", $db);
> $myrow = mysql_fetch_row($result);
> $staticvar += $myrow[0];
>
> $staticvar will never be an array, it's just a simple variable storing a
> number.  I *could* do it like this:
>
> $result = mysql_query("select * from database", $db);
> $staticvar += mysql_num_rows($result);
>
> However, the mysql query will be much, much slower if I do it like this.
>
> Basically, what I'm asking, is how to do something like:
>
> $staticvar += mysql_fetch_row($result);
>
> I want to eliminate step two, and I don't want to involve any temporary
> arrays when there's always just one
> value.  Any suggestions? Thanks a bunch!

You can assign the directly into a variable using something like:

  list($count) = mysql_fetch_array($result);

Not sure whether you can do a += into an existing variable though.

Why don't you just stuff the above into a function instead?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Runt packets
*/

--- End Message ---
--- Begin Message ---
On Thu, 24 Oct 2002 21:26:30 +0000, John W. Holmes wrote:

> What is supposed to be in the session? Maybe these users are just
> denying cookies?
Maybe... But my php compiled with --use-trans-sid and use this feature.
In the session i store account, access timestamp etc...

P.S. And 10% of traffic ~2000 visitors.

--- End Message ---
--- Begin Message ---
Hey folks.  I am attempting to run PHP code with <script language="php"> and
it doesn't work.  Any ideas as to why and how I can fix that?  Also what is
the best way to run a snippet of PHP code in an ASP page?  Thanks in
advance.

Jason "Gluten Mifflin" Porembski
http://www.world-gaming.com


--- End Message ---
--- Begin Message ---
Does it work when you do it like this....

<?php

some code;
some more code;

?>

Jason Porembski wrote:
Hey folks.  I am attempting to run PHP code with <script language="php"> and
it doesn't work.  Any ideas as to why and how I can fix that?  Also what is
the best way to run a snippet of PHP code in an ASP page?  Thanks in
advance.

Jason "Gluten Mifflin" Porembski
http://www.world-gaming.com




--- End Message ---
--- Begin Message --- I've written a little script for VoiceXML applications to generate a WAV from an MP3 on demand:

#file wavwrapper.php
<?
header('Content-Type: audio/wav');
$filename = $_GET['filename'];

$mp3dir="/var/www/mp3s/";
$playercmd="/usr/local/bin/mpg123 -m -w - -q -4 --8bit";
passthru("$playercmd $mp3dir/$filename 2> /tmp/playererror");
?>


I request it as wavwrapper?filename=song.mp3, and the browser reads the MIME type properly, prompts me to play or download the song. I download it, and save it as a WAV file. However, Mozilla downloads about 1.5M of data, saves it all to a file, and then displays the downloaded size as 1k. And then when I try to play it back, it won't play; it's like an empty file. Same thing happens if I try to play it directly. But if I redirect the output of mpg123 from standard out (so it goes across the web connection) to a file and then download the file, the file plays just fine. I figure there's something to do with the way PHP dumps back the binary data that just isn't working right, but I don't know what it is. Anyone have any ideas?

--
Soren Harward
[EMAIL PROTECTED]

--- End Message ---

Reply via email to