OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 11 Mar 2004 04:58:01 -0000 Issue 2639

php-general-digest-helplists.php.net
Date: Wed Mar 10 2004 - 22:58:01 CST


php-general Digest 11 Mar 2004 04:58:01 -0000 Issue 2639

Topics (messages 180029 through 180101):

Re: Return value efficiency question
        180029 by: Robert Cummings

magic_quotes_sybase - Windows MSSQL
        180030 by: Jeremy
        180096 by: Tom Rogers

Re: How to make sure a redirect works
        180031 by: Vincent Jansen

Re: wysiwyg editor
        180032 by: Vincent Jansen

Re: Are $_POST and $_GET interchangable?
        180033 by: Five
        180037 by: Kelly Hallman

Re: small business inventory management package
        180034 by: Ralph

new to php question
        180035 by: Luke Brindley
        180039 by: Chris W. Parker

Letters and Numbers limitation
        180036 by: Mike Mapsnac
        180038 by: Larry E. Ullman

get_browser() - browscap.ini for Linux
        180040 by: Shaunak Kashyap
        180041 by: Chris W. Parker
        180046 by: James Kaufman
        180055 by: Shaunak Kashyap

Re: arrays, loops, vars and props
        180042 by: Chris W. Parker
        180045 by: Luis Mirabal
        180047 by: Michal Migurski
        180048 by: Chris W. Parker
        180050 by: Jason Davidson

error_log set but still writing to syslog and the apache error_log
        180043 by: Jason Lehman

Re: Passing array from class to class produces more than one result...
        180044 by: Luis Mirabal
        180092 by: Firman Wandayandi

Re: what does this mean?
        180049 by: Luis Mirabal

perl, cgi and php
        180051 by: Edward Peloke
        180052 by: joel boonstra

If Using PHP CLI to Query Oracle8I DB, is Version Number Critical?
        180053 by: Martin McCormick

PHP on Novell server
        180054 by: Tim Thorburn

ASP to PHP language problems
        180056 by: Alistair Hayward
        180057 by: Ligaya Turmelle
        180058 by: Alistair Hayward
        180059 by: Chris W. Parker
        180060 by: Alistair Hayward
        180061 by: Alistair Hayward
        180062 by: Sam Masiello
        180063 by: Richard Davey
        180064 by: Alistair Hayward
        180065 by: Sam Masiello
        180066 by: Alistair Hayward
        180067 by: Richard Davey
        180074 by: Raditha Dissanayake
        180078 by: Alistair Hayward
        180079 by: Alistair Hayward
        180082 by: Rodrigo Castro
        180084 by: Richard Davey
        180087 by: Alistair Hayward

Unique ID system - need help/ideas
        180068 by: J J
        180069 by: Chris W. Parker
        180070 by: J J
        180071 by: Chris W. Parker
        180072 by: J J
        180073 by: Chris W. Parker
        180075 by: Miles Thompson
        180085 by: J J
        180098 by: trlists.clayst.com
        180100 by: J J

How to mesure response time of php pages
        180076 by: Merlin
        180077 by: Chris W. Parker
        180080 by: Jason Sheets
        180094 by: Tom Rogers

proxy of sorts
        180081 by: erythros

Re: Are $_POST and $_GET interchangable? MORE
        180083 by: Five
        180088 by: daniel.electroteque.org
        180089 by: Richard Davey

Spelling without Aspell/Pspell
        180086 by: Justin French
        180090 by: Evan Nemerson
        180093 by: daniel.electroteque.org

Re: AI:Categorizer
        180091 by: Evan Nemerson

odd acrobat reaction to streaming files
        180095 by: Scott Taylor
        180097 by: daniel.electroteque.org

Regexp Oddity
        180099 by: trlists.clayst.com

Screen Res
        180101 by: res0b8b6

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


On Wed, 2004-03-10 at 08:30, trlistsclayst.com wrote:
> On 10 Mar 2004 Robert Cummings wrote:
>
> > Overhead is minimal since PHP doesn't actually copy the contents of the
> > container until an attempt to modify it is made. At which time the
> > contents are only actually copied if the internal reference count is
> > greater than 0. Generally this means it won't be copied since your
> > returning function will no longer be referencing it. This is not to be
> > confused with references as programmers work with them in scripts
> > themselves.
>
> Rob I have a related question, if you know ... what is the point at
> which passing objects by reference instead of by value provides a
> performance benefit?

Passing by reference appears to provide a small amount of speed increase
though IMHO very small. Check the following three scripts:

<?

$initial = array();

for( $i = 0; $i < 100000; $i++ )
{
    $initial[$i] = $i;
}
 
for( $i = 0; $i < 10000000; $i++ )
{
    $foo = $initial;
}
----------------------------------------------------------------
linux "time" command: 7.46user 0.02system 0:07.58elapsed 98%CPU
----------------------------------------------------------------

<?

for( $i = 0; $i < 100000; $i++ )
{
    $initial = $i;
}
 
for( $i = 0; $i < 10000000; $i++ )
{
    $foo = $initial;
}
----------------------------------------------------------------
linux "time" command: 7.25user 0.00system 0:07.25elapsed 99%CPU
----------------------------------------------------------------

<?

$initial = array();

for( $i = 0; $i < 100000; $i++ )
{
    $initial[$i] = $i;
}
 
for( $i = 0; $i < 10000000; $i++ )
{
    $foo = &$initial;
}
----------------------------------------------------------------
linux "time" command: 6.85user 0.02system 0:06.87elapsed 99%CPU
----------------------------------------------------------------

As you can see copying by value regardless of the value is pretty much
the same (I think the time discrepency is due to a slightly longer time
to populate the $initial array than to assign an integer value 100000
times to $initial (which makes sense O( lg n ) versus O( 1 )).

It seems passing by reference provides a small amount of advantage
(about 5% as shown above). Even though references may be faster I would
say now that it depends on what you want to do and who is maintaining
the code :) Also copies are definitely a good choice when you are
passing data that shouldn't affect some centralized storage variable
(such is usually the case for Singleton factories). Also don't forget
that the above example is assigning the data 10 million times, generally
the difference would be almost negligible.

> It sounds from the above like if you are not modifying the object in
> the called code then passing by value is always best because this is
> treated as a pass by reference unless and until there is a
> modification, so there is no performance cost. (I udnerstand that if
> modifying it then it must be passed by reference.)

Passing references everywhere when a reference isn't needed can make
your code more difficult to read since others reading it will constantly
be asking, "is this being passed as a reference for a reason? Does
changing the value outside of the function returning it or receiving it
have some transient effect?".

>
> If that's right, then ...
>
> - does the same apply to arrays?

Yes as shown above.

> - what happens if you pass an object by value and then call one of
> its methods which does not modify any data? Does the object get
> copied?

I checked with the internals list for this answer since I thought it
would work the same, and indeed it turns out that objects in PHP 4 do
work this way. However this is not quite true with PHP 5 which uses the
concept of object-handles. Nonetheless, Derick Rethans informed had the
following to say:

    "in php 5 it is true for "object-handles" and not objects, but
     that shouldn't be of any concern."

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


My ISP has the following settings in their php.ini file:

magic_quotes_gpc = ON
magic_quotes_sybase = OFF

I am using a Windows Server and a SQL Server database.

I need to set magic_quotes_sybase to ON so that quotes will be escaped
with another quote instead of a slash. However, I do not have access
to the php.ini file. Is there something like the .htaccess file that
can be used on a Windows server?

My ISP is using PHP v4.3.0.

Thank you!

Jeremy Markman

attached mail follows:


Hi,

Thursday, March 11, 2004, 3:23:20 AM, you wrote:
J> My ISP has the following settings in their php.ini file:

J> magic_quotes_gpc = ON
J> magic_quotes_sybase = OFF

J> I am using a Windows Server and a SQL Server database.

J> I need to set magic_quotes_sybase to ON so that quotes will be escaped
J> with another quote instead of a slash. However, I do not have access
J> to the php.ini file. Is there something like the .htaccess file that
J> can be used on a Windows server?

J> My ISP is using PHP v4.3.0.

J> Thank you!

J> Jeremy Markman

A quick fix is

str_replace("'","''",stripslashes($input));

--
regards,
Tom

attached mail follows:


>If you output a location header then I don't know what the browser will

>do with text sent after that. Hopefully nothing!

I experienced some strange behaviour(=no redirect at all!!) with a
script that send data after the location header.

Best to do this

header("Location: http://somesite.nl");
die();

Vincent

attached mail follows:


I use http://www.fredck.com/FCKeditor/

Vincent

attached mail follows:


"Jay Blanchard" <jay.blanchardniicommunications.com> wrote in message news:C8F323573C030A448F3E5A2B6FE2070B02A2DDnemesis...
[snip]
 for $_GET[], I found indirect references
(documentation of other subjects that use $_GET[] and $_POST[] )
but no documentation focusing directly on either.

Is there on line documentation specifically dedicated to these two
phenomena?
[/snip]

This is more of a general web programming question (see the info at
http://www.w3c.org) GET and POST are two different methods of moving
data from client to server. The GET method utilizes the URL for passing
data and is limited in size (I forget the total number of characters
allowed in the URL). It is also makes spoofing a little easier. Let us
say I am an employee of a company and my app designers have done a poor
job at security. I go to employee information at

http://www.foo.com/employee.php?eid=jsmith

If I have some snap and I want to see some other employee's info I can
then type it into the URL

http://www.foo.com/employee.php?eid=bstreisand

POST removes the information from the view of the user, and IIRC you can
pass tons of information to the server.

The rules for usage come down to this - A little common sense goes a
long way. There are really no specific rules. For web apps at my company
I set the rules, I have seen other companies with other rules for the
use of these two.

I googled a few different queries and can't find any direct documentation.

 http://www.w3c.org has a lot of info, but none that I can find' on this subject (they need a 'search this site' option)

attached mail follows:


Mar 10 at 9:45am, Five wrote:
> If I have some snap and I want to see some other employee's info I can
> then type it into the URL
> http://www.foo.com/employee.php?eid=bstreisand
>
> The rules for usage come down to this - A little common sense goes a
> long way. There are really no specific rules.

On that note, something to keep in mind is that GET variables (being part
of the URL) are written to server logs. Depending on the data being
passed, this could be a security issue (especially in a shared hosting
environment where untrusted users may have access to the logs).

--
Kelly Hallman
// Ultrafancy

attached mail follows:


OSSUITE:

http://sourceforge.net/projects/ossuite/

or just browse through sourceforge projects:

http://sourceforge.net/softwaremap/trove_list.php?form_cat=129&discrim=183

-----Original Message-----
From: Christian Calloway [mailto:callowaylcyahoo.com]
Sent: Tuesday, March 09, 2004 1:38 AM
To: php-generallists.php.net
Subject: [PHP] small business inventory management package

Hey,

Not looking to reinvent the wheel.. I am looking for an inventory management
software package (written in PHP of course) that would be suitable for a
small business. So in otherwords, nothing with any bells or whistles, just
something that is easily modified/extensible. Any suggestions, Thanks in
advance

Christian

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

attached mail follows:


I'm new to php but want to use it for a music club's website I'm
working on. Specifically, I want to create an online form that the
booking agent can fill out with information like Date, Time, Cover
Charge, Band Name, Description, etc and have this data populate the
calendar page in chronological order. For an example of what I'm
trying to do check out: http://www.schubas.com/calendar.asp

Any suggestions?

Thanks for your help,
Luke

http://www.brindleybrothers.com

attached mail follows:


Luke Brindley <mailto:lukebrindleybrothers.com>
    on Wednesday, March 10, 2004 10:37 AM said:

> Specifically, I want to create an online form that the
> booking agent can fill out with information like Date, Time, Cover
> Charge, Band Name, Description, etc and have this data populate the
> calendar page in chronological order.

[snip]

> Any suggestions?

are you looking for a premade app or did you have a specific question?

here are some things to think about.

1. do you know how to create a database?
2. do you know how to write SQL queries?
3. do you know how to retrieve data from a database with php?

if you answered no to any of those questions you are probably not ready
to create such a thing. otherwise, ask a more specific question and we
will try to help you out.

hth,
chris.

attached mail follows:


Form takes parameter username, so I want to accept username taht includes
only numbers and letters.
How can I check if variable contains only letters and numbers?

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now!
http://clk.atdmt.com/AVE/go/onm00200415ave/direct/01/

attached mail follows:


> Form takes parameter username, so I want to accept username taht
> includes only numbers and letters.
> How can I check if variable contains only letters and numbers?

Use regular expressions. See the PHP manual (for PCRE or POSIX) for
more. You'll also find a number of tutorials online about validating
form input with regex, I suspect.

Larry

attached mail follows:


I am running Apache 1.3.29 on a Linux platform. I am trying to use PHP's
get_browser function which needs a file called browscap.ini on the server.
It *seems* that there is no such file available for Linux (I have checked
the manual and the link that it mentions).

Can anyone point me to a source for a working, up-to-date Linux version of
browscap.ini

Thanks in advance,

Shaunak

attached mail follows:


Shaunak Kashyap <mailto:skashyapintertechmedia.com>
    on Wednesday, March 10, 2004 11:21 AM said:

> I am running Apache 1.3.29 on a Linux platform. I am trying to use
> PHP's get_browser function which needs a file called browscap.ini on
> the server. It *seems* that there is no such file available for Linux
> (I have checked the manual and the link that it mentions).
>
> Can anyone point me to a source for a working, up-to-date Linux
> version of browscap.ini

i'm just guessing with this but are you sure you need a "linux" version
of browscap.ini? afaik it's just a plain text file.

chris.

attached mail follows:


On Wed, Mar 10, 2004 at 02:21:19PM -0500, Shaunak Kashyap wrote:
> I am running Apache 1.3.29 on a Linux platform. I am trying to use PHP's
> get_browser function which needs a file called browscap.ini on the server.
> It *seems* that there is no such file available for Linux (I have checked
> the manual and the link that it mentions).
>
> Can anyone point me to a source for a working, up-to-date Linux version of
> browscap.ini
>
> Thanks in advance,
>
> Shaunak
>

I pick up mine from http://www.GaryKeith.com and use it fine under Linux.

--
Jim Kaufman
Linux Evangelist
public key 0x6D802619
http://www.linuxforbusiness.net

attached mail follows:


Thanks for the prompt reply.

I downloaded the file from www.GaryKeith.com and set up the php.ini entry to
point to it. Then I called get_browser() and it returned nothing.

Once again, my configuration is as under:

OS: Linux Red Hat Enterprise WS
PHP: 4.2.3
Web server: Apache 1.3.29

Have you tried using PHP's get_browser function? If that worked for you,
could you please let me know what your system configuration is?

Thanks,

Shaunak

> -----Original Message-----
> From: James Kaufman [mailto:jmkkaufman.eden-prairie.mn.us]
> Sent: Wednesday, March 10, 2004 3:31 PM
> To: php-generallists.php.net
> Subject: Re: [PHP] get_browser() - browscap.ini for Linux
>
>
> On Wed, Mar 10, 2004 at 02:21:19PM -0500, Shaunak Kashyap wrote:
> > I am running Apache 1.3.29 on a Linux platform. I am trying to use PHP's
> > get_browser function which needs a file called browscap.ini on
> the server.
> > It *seems* that there is no such file available for Linux (I
> have checked
> > the manual and the link that it mentions).
> >
> > Can anyone point me to a source for a working, up-to-date Linux
> version of
> > browscap.ini
> >
> > Thanks in advance,
> >
> > Shaunak
> >
>
> I pick up mine from http://www.GaryKeith.com and use it fine under Linux.
>
> --
> Jim Kaufman
> Linux Evangelist
> public key 0x6D802619
> http://www.linuxforbusiness.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Jason Davidson <mailto:jdavidsonzworg.com>
    on Wednesday, March 10, 2004 12:25 AM said:

> would the following example be faster or slower had i simply done
> $this->myArray[$i] = $i;
>
> class MyClass {
> var $myArray = array();
>
> function MyClass() {
> $myTempArray = array();
> for($i=0;$i<100;$i++)
> $myTempArray[$i] = $i;
> $this->myArray = $myTempArray;
> }
> }

here's how i would do it (coding styles aside):

function MyClass()
{
    $limit = 100;

    $i = -1;
    while(++$i < $limit)
    {
        $this->myArray[] = $i;
    }
}

chris.

attached mail follows:


i would do it this way

function MyClass()
{
    $this->myArray = range(0, 99);
}

luis.

"Chris W. Parker" <cparkerswatgear.com> escribió en el mensaje
news:001BD19C96E6E64E8750D72C2EA0ECEE2B8735ati-ex-01.ati.local...
Jason Davidson <mailto:jdavidsonzworg.com>
    on Wednesday, March 10, 2004 12:25 AM said:

> would the following example be faster or slower had i simply done
> $this->myArray[$i] = $i;
>
> class MyClass {
> var $myArray = array();
>
> function MyClass() {
> $myTempArray = array();
> for($i=0;$i<100;$i++)
> $myTempArray[$i] = $i;
> $this->myArray = $myTempArray;
> }
> }

here's how i would do it (coding styles aside):

function MyClass()
{
    $limit = 100;

    $i = -1;
    while(++$i < $limit)
    {
        $this->myArray[] = $i;
    }
}

chris.

attached mail follows:


>here's how i would do it (coding styles aside):
>
>function MyClass()
>{
> $limit = 100;
>
> $i = -1;
> while(++$i < $limit)
> {
> $this->myArray[] = $i;
> }
>}

Don't forget poor old range:

        $this->myArray = range(0, 99);

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html

attached mail follows:


Luis Mirabal <mailto:mirabaladinet.com.uy>
    on Wednesday, March 10, 2004 12:30 PM said:

> i would do it this way
>
> function MyClass()
> {
> $this->myArray = range(0, 99);
> }

guys (luis), guys (mike), let's not try to one-up each other...

...

...

but i would take it a step further. :P

function MyClass($limit = 100)
{
        $this->myArray = range(0, $limit-1);
}

c.

attached mail follows:


Im fully aware of diffrent ways of doing it, my question is, in the 2
ways i mentioned, which is more efficient. Ill take the question to
the internals list. Thanks for your responses.

Jason

"Chris W. Parker" <cparkerswatgear.com> wrote:
>
> Luis Mirabal <mailto:mirabaladinet.com.uy>
> on Wednesday, March 10, 2004 12:30 PM said:
>
> > i would do it this way
> >
> > function MyClass()
> > {
> > $this->myArray = range(0, 99);
> > }
>
> guys (luis), guys (mike), let's not try to one-up each other...
>
> ...
>
> ...
>
> but i would take it a step further. :P
>
> function MyClass($limit = 100)
> {
> $this->myArray = range(0, $limit-1);
> }
>
>
>
> c.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


I have set error_log to /var/logs/php_error.log and no matter what it
keeps writing to syslog. I have restarted the server and it shows up in
the phpinfo(); correctly but it won't write to the it keeps writing to
syslog. I have changed the owner to apache.apache and I have kept it to
  root.root but still nothing. I would appreciate any help.

attached mail follows:


mmmh... i think its not coded the right way, first of all, you shouldn't put
this:

$this->setArray(mysql_fetch_array($this->getResultID()));

in the Select method, you should do it in your FetchArray method, every time
it gets called, and return the value directly or false if there are no more
rows, an example:

function FetchArray() { return mysql_fetch_array($this->getResultID()); }

or something like that

"Jonathan Villa" <jvillaisdesigndev.com> escribió en el mensaje
news:1078932426.3002.17.cameljonathan...
> I'm writing a DBI class with the following function
>
> function Select($sql)
> {
> $this->setResultID(mysql_query($sql,$this->getDBConn()));
> if ($this->getResultID() == false)
> Error::fatalError(__FILE__.' ('.__LINE__.') : Unable to run query :
> '.mysql_error().'('.mysql_errno().')');
>
> $this->setNumRows(mysql_num_rows($this->getResultID()));
> $this->setArray(mysql_fetch_array($this->getResultID()));
> }
>
>
> When I call this, I want to be able to run
>
> while($data = $objDBI->FetchArray)
> {
> echo $data['username'];
> }
>
> but the results I get are
>
>
jvillajvillajvillajvillajvillajvillajvillajvillajvillajvillajvillajvilla....
etc....
>
> my $sql query is simple
>
> SELECT username FROM staff;
>
> and there are four rows in the db...
>
>
> For some reason, I can't pass the value of mysql_fetch_array out of the
> Select function.

attached mail follows:


Hi Jon!

If you wanna do that, use pass by reference operator "&" in front of your
method/function, the method should be like this:

class someClass {
    function &fetchArray() {
        // do something
    }
}

Good luck,
    Firman

----- Original Message -----
From: "Jonathan Villa" <jvillaisdesigndev.com>
To: <php-generallists.php.net>
Sent: Wednesday, March 10, 2004 10:27 PM
Subject: [PHP] Passing array from class to class produces more than one
result...

> I'm writing a DBI class with the following function
>
> function Select($sql)
> {
> $this->setResultID(mysql_query($sql,$this->getDBConn()));
> if ($this->getResultID() == false)
> Error::fatalError(__FILE__.' ('.__LINE__.') : Unable to run query :
> '.mysql_error().'('.mysql_errno().')');
>
> $this->setNumRows(mysql_num_rows($this->getResultID()));
> $this->setArray(mysql_fetch_array($this->getResultID()));
> }
>
>
> When I call this, I want to be able to run
>
> while($data = $objDBI->FetchArray)
> {
> echo $data['username'];
> }
>
> but the results I get are
>
>
jvillajvillajvillajvillajvillajvillajvillajvillajvillajvillajvillajvilla....
etc....
>
> my $sql query is simple
>
> SELECT username FROM staff;
>
> and there are four rows in the db...
>
>
> For some reason, I can't pass the value of mysql_fetch_array out of the
> Select function.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


the casting is as follows, any value distinct from zero, null or empty
string is converted to true, else the it is converted to false

"Harry Wiens" <h.wiensgmx.net> escribió en el mensaje
news:20040310144607.45663.qmailpb1.pair.com...
> $this->styles['shadow'] = (boolean)$bool;
> ^^^^^^^^^^^^
>
> what does "(boolean)$bool" mean?
>
> mfg.
> harry wiens

attached mail follows:


Hello,

First let me say, I know very little about perl and cgi. I have a friend
who is moving his site to a new hosting company. One of his php pages has
the following line of code:

 <?php
virtual("./timeline/ganttChart.cgi?user={$gallery->session->username}"); ?>

but when the page is displayed all that shows up is the content of the .cgi
script. Is this a configuration issue?

Thanks,
Eddie

 WARNING: The information contained in this message and any attachments is
intended only for the use of the individual or entity to which it is
addressed. This message may contain information that is privileged,
confidential and exempt from disclosure under applicable law. It may also
contain trade secrets and other proprietary information for which you and
your employer may be held liable for disclosing. You are hereby notified
that any unauthorized dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify HIPAAechoman.com by E-Mail and then
destroy this communication in a manner appropriate for privileged
information.

attached mail follows:


On Wed, Mar 10, 2004 at 04:07:28PM -0500, Edward Peloke wrote:
> First let me say, I know very little about perl and cgi. I have a friend
> who is moving his site to a new hosting company. One of his php pages has
> the following line of code:
>
> <?php
> virtual("./timeline/ganttChart.cgi?user={$gallery->session->username}"); ?>
>
> but when the page is displayed all that shows up is the content of the .cgi
> script. Is this a configuration issue?

The new hosting company's web servers don't appear to have their servers
setup to parse *.cgi files through CGI. They will need to fix that, or
he will need to move ganttChart.cgi into a directory that is setup to
handle CGI files -- sometimes you'll have a cgi-bin directory for this
purpose.

joel

--
[ joel boonstra | gospelcom.net ]

attached mail follows:


        We use PHP 4.3.4 (cli) to query a Microsoft SQL database
server with no problem. We are now going to attempt the same sort of
thing, only with a Pinnacle server running an Oracle8I data base.

        The php installation is on a FreeBSD UNIX platform and the
Pinnacle server is on a Windows platform.

        Being very new to all this, my question is simply whether or
not this should work? I am concerned that php comes with an Oracle7
client, but the data base I need to query and write back to is
Oracle8I which might, someday, upgrade to a higher version.

        If I am using the PHP CLI to extract data from the server
with, of course, correct syntax, does the Oracle version even matter?

        What we are going to do is extract information from work
orders and then build scripts, using this information to control a
telephone switch as well as create logs, etc.

        The php engine is simply going to let us pull and push data
back and forth between this UNIX system and the Pinnacle server.

        If this can't work, then I am wasting my/our time. If it
should work, then I'll set it up and make it work.

        We will most likely be running a php script which starts out like:

#!/usr/local/bin/php -q
<?
//Set env variables
putenv("SYBASE=/usr/local/etc/freetds");
putenv("TDSVER=70");

//Login to SQL
$numero= mssql_connect("sqlserver" , "UID" , "password" );

//Process each record
$result=mssql_query("SELECT * FROM NatRegLog WHERE process='no'",$numero );
________________________________________

//Logout of SQL
mssql_close($numero);

?>

        The script that will handle the Oracle DB will be similar to
this example, only running the appropriate Oracle SQL commands.

        Many thanks. If this is in the archives, I could have missed
it. The php web manual's Oracle section says,

>Introduction
>
> This extension adds support for Oracle database server access. See
> also the OCI8 extension.

Martin McCormick WB5AGZ Stillwater, OK
OSU Information Technology Division Network Operations Group

attached mail follows:


Hi,

I'm putting together a proposal to design a website that is to be hosted on
a Novell Enterprise 5.1 webserver - I'm told its an off-shoot of the
Netscape Enterprise server. I've spoken with the network admin, and we're
playing some phone tag right now, so I thought I'd ask here - is it
possible to install PHP on this server?

Now part two which is most likely unrelated to this group, but maybe
someone has come across this problem. As of now, there is no database
installed - the client wants to be able to update the content of all their
sites by themselves ... with no database, this presents a problem as I see
it. I've only dabbled in Perl years ago until I found PHP to be much
easier and faster for me to use. Is there a way that ppl know of where I
could let the client update their own content using only Perl (no idea what
version) and no database? I suppose there's some sick method of editing
text files, but that seems a little bit more hokey than I'd like to get into.

Thanks
-Tim

attached mail follows:


Hi ,

What is the equavilant in PHP to creating a recordset in ASP using a query?
This is what I do in PHP:
..................................

dim Type
Type = CStr(Request.QueryString("action")) (getting parameter from URL)

Dim cnn ' ADO connection
Dim rst ' ADO recordset
Dim strDBPath ' path to my Access database (*.mdb) file

strDBPath = Server.MapPath("/_database/database.mdb")
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"

Set rst = cnn.Execute("SELECT * FROM table WHERE Type ='" & type & "'
order by style")
..........................................
I can then call any field and display it in the html by using :
<%=rst.fields("whatever").value%>
..........................................
I can also create a loop:
<%Do While Not rstSimple.EOF%>
do something
<%
rstSimple.MoveNext
Loop
%>
............................................

Please can someone show me how to do the same thing in PHP?

Alistair

attached mail follows:


I don't know ASP but I think this is what you want:

$sql = "SELECT * FROM table WHERE Type = \"& type & \" order by style;";

$resultID = mysql_query($sql, DBlink); // send the query and returns a
pointer to the results
while ($row = mysql_fetch_assoc($resultID)) // while there are results
give them to me as an associative array
                                                                       //
results could also be returned as an array, object, or row
                                                                       //
see mysql_fetch_array, mysql_fetch_object, and mysql_fetch_row respectively
{
   Here is a loop
}

"Alistair Hayward" <alistairco-sys.co.nz> wrote in message
news:20040310222514.31406.qmailpb1.pair.com...
> Hi ,
>
> What is the equavilant in PHP to creating a recordset in ASP using a
query?
> This is what I do in PHP:
> ..................................
>
> dim Type
> Type = CStr(Request.QueryString("action")) (getting parameter from URL)
>
> Dim cnn ' ADO connection
> Dim rst ' ADO recordset
> Dim strDBPath ' path to my Access database (*.mdb) file
>
> strDBPath = Server.MapPath("/_database/database.mdb")
> Set cnn = Server.CreateObject("ADODB.Connection")
> cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
>
> Set rst = cnn.Execute("SELECT * FROM table WHERE Type ='" & type & "'
> order by style")
> ..........................................
> I can then call any field and display it in the html by using :
> <%=rst.fields("whatever").value%>
> ..........................................
> I can also create a loop:
> <%Do While Not rstSimple.EOF%>
> do something
> <%
> rstSimple.MoveNext
> Loop
> %>
> ............................................
>
> Please can someone show me how to do the same thing in PHP?
>
> Alistair

attached mail follows:


This is what I get when I try to create the recordset....

Notice: Use of undefined constant DBlink - assumed 'DBlink' in
D:\Development\Completed\Sealhouse\phpSealTest\ProductSpecs.php on line 24

Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in
D:\Development\Completed\Sealhouse\phpSealTest\ProductSpecs.php on line 24

Ligaya Turmelle wrote:

> I don't know ASP but I think this is what you want:
>
> $sql = "SELECT * FROM table WHERE Type = \"& type & \" order by style;";
>
> $resultID = mysql_query($sql, DBlink); // send the query and returns a
> pointer to the results
> while ($row = mysql_fetch_assoc($resultID)) // while there are results
> give them to me as an associative array
> //
> results could also be returned as an array, object, or row
> //
> see mysql_fetch_array, mysql_fetch_object, and mysql_fetch_row respectively
> {
> Here is a loop
> }
>
> "Alistair Hayward" <alistairco-sys.co.nz> wrote in message
> news:20040310222514.31406.qmailpb1.pair.com...
>
>>Hi ,
>>
>>What is the equavilant in PHP to creating a recordset in ASP using a
>
> query?
>
>>This is what I do in PHP:
>>..................................
>>
>>dim Type
>>Type = CStr(Request.QueryString("action")) (getting parameter from URL)
>>
>>Dim cnn ' ADO connection
>>Dim rst ' ADO recordset
>>Dim strDBPath ' path to my Access database (*.mdb) file
>>
>>strDBPath = Server.MapPath("/_database/database.mdb")
>>Set cnn = Server.CreateObject("ADODB.Connection")
>>cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
>>
>>Set rst = cnn.Execute("SELECT * FROM table WHERE Type ='" & type & "'
>>order by style")
>>..........................................
>>I can then call any field and display it in the html by using :
>><%=rst.fields("whatever").value%>
>>..........................................
>>I can also create a loop:
>><%Do While Not rstSimple.EOF%>
>>do something
>><%
>>rstSimple.MoveNext
>>Loop
>>%>
>>............................................
>>
>>Please can someone show me how to do the same thing in PHP?
>>
>>Alistair

attached mail follows:


Alistair Hayward <mailto:alistairco-sys.co.nz>
    on Wednesday, March 10, 2004 2:46 PM said:

> This is what I get when I try to create the recordset....
>
> Notice: Use of undefined constant DBlink - assumed 'DBlink' in
> D:\Development\Completed\Sealhouse\phpSealTest\ProductSpecs.php on
> line 24

well you're going to need to do a *little* research on your own.

oh what the heck...

DBlink is the same as your cnn in your asp code. in other words you
still need to create a connection to a database.

chris.

attached mail follows:


Thanks Chris,

Believe me, I have been doing research non-stop for a few days now and
this is my last resort.
The problem is the language. I can't find what I'm looking for on the
net because I don't know what it's called.

I have worked out how to create a connection to a mySQL server and
database. (after spending so much time configuring and installing PHP
and mySQL for the first time)
I now know how to use include files.
I can not figure out how to create a recordset and call fields from the
record set while performing a loop.

I have done heaps of research, but have not found what I need.

Chris W. Parker wrote:

> Alistair Hayward <mailto:alistairco-sys.co.nz>
> on Wednesday, March 10, 2004 2:46 PM said:
>
>
>>This is what I get when I try to create the recordset....
>>
>>Notice: Use of undefined constant DBlink - assumed 'DBlink' in
>>D:\Development\Completed\Sealhouse\phpSealTest\ProductSpecs.php on
>>line 24
>
>
> well you're going to need to do a *little* research on your own.
>
> oh what the heck...
>
> DBlink is the same as your cnn in your asp code. in other words you
> still need to create a connection to a database.
>
>
>
> chris.

attached mail follows:


This is what I have:
<?php

        $connection = mysql_connect("localhost","root","batman");
        if (!$connection) {
         echo "Couldn't make a connection!";
         exit;
     }
        $db = mysql_select_db("sealhouse", $connection);
        if (!$db) {
         echo "Couldn't select database!";
         exit;
     }
        $type = $_GET['type'];
        $sql = "SELECT * FROM tbCategory WHERE Type =$type order by style";
        $resultID = mysql_query($sql, DB);
        
?>

Chris W. Parker wrote:

> Alistair Hayward <mailto:alistairco-sys.co.nz>
> on Wednesday, March 10, 2004 2:46 PM said:
>
>
>>This is what I get when I try to create the recordset....
>>
>>Notice: Use of undefined constant DBlink - assumed 'DBlink' in
>>D:\Development\Completed\Sealhouse\phpSealTest\ProductSpecs.php on
>>line 24
>
>
> well you're going to need to do a *little* research on your own.
>
> oh what the heck...
>
> DBlink is the same as your cnn in your asp code. in other words you
> still need to create a connection to a database.
>
>
>
> chris.

attached mail follows:


Not trying to sound rude or anything, but have you looked up the mysql
functions at http://php.net/mysql in your research?

I would start with mysql_connect(), mysql_query(), and
mysql_fetch_array()/mysql_result().

There are lots of user notes on each page as well which should be of
assistance.

HTH!

--Sam

Alistair Hayward wrote:
> Thanks Chris,
>
> Believe me, I have been doing research non-stop for a few days now and
> this is my last resort.
> The problem is the language. I can't find what I'm looking for on the
> net because I don't know what it's called.
>
> I have worked out how to create a connection to a mySQL server and
> database. (after spending so much time configuring and installing PHP
> and mySQL for the first time)
> I now know how to use include files.
> I can not figure out how to create a recordset and call fields from
> the record set while performing a loop.
>
> I have done heaps of research, but have not found what I need.
>
> Chris W. Parker wrote:
>
>> Alistair Hayward <mailto:alistairco-sys.co.nz>
>> on Wednesday, March 10, 2004 2:46 PM said:
>>
>>
>>> This is what I get when I try to create the recordset....
>>>
>>> Notice: Use of undefined constant DBlink - assumed 'DBlink' in
>>> D:\Development\Completed\Sealhouse\phpSealTest\ProductSpecs.php on
>>> line 24
>>
>>
>> well you're going to need to do a *little* research on your own.
>>
>> oh what the heck...
>>
>> DBlink is the same as your cnn in your asp code. in other words you
>> still need to create a connection to a database.
>>
>>
>>
>> chris.

attached mail follows:


Hello Alistair,

Wednesday, March 10, 2004, 10:26:03 PM, you wrote:

AH> dim Type
AH> Type = CStr(Request.QueryString("action")) (getting parameter from URL)

unset($type);
$type = $_GET['action'];

(Please note - you don't HAVE to "unset" each variable, but if you are
working in a Register Globals ON environment, it's a good safety
measure).

AH> strDBPath = Server.MapPath("/_database/database.mdb")

MySQL doesn't work the same way as MDB files (thank goodness), so you
need to create a connection to the MySQL database:

$link = mysql_connect('localhost', 'username', 'password');

AH> Set cnn = Server.CreateObject("ADODB.Connection")
AH> cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"

mysql_select_db('database_name', $link);

AH> Set rst = cnn.Execute("SELECT * FROM table WHERE Type ='" & type & "'
AH> order by style")

$sql= "SELECT * FROM table WHERE type='$type' ORDER BY style";
$result = mysql_query($sql);

You now have the entire "record set" in $result. To obtain the first
row of data, do this:

AH> <%Do While Not rstSimple.EOF%>
AH> do something
AH> <%
AH> rstSimple.MoveNext
AH> Loop

A few ways to do this:

$total_records = mysql_num_rows($result);

for ($i=0; $i < $total_records; $i++)
{
    $data = mysql_fetch_assoc($result);
    print_r($data);
}

$data will now be an array holding the first set of information. The
print_r line just displays it so you can see it easily.

Instead of a FOR loop you could do a "while" loop checking to see the
end of the $result set, i.e.:

while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
      // do stuff
      print_r($row);
}

AH> <%=rst.fields("whatever").value%>

<?=$data['whatever']?>

--
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

attached mail follows:


Richard:
Thank you so much!

Richard Davey wrote:

> Hello Alistair,
>
> Wednesday, March 10, 2004, 10:26:03 PM, you wrote:
>
> AH> dim Type
> AH> Type = CStr(Request.QueryString("action")) (getting parameter from URL)
>
> unset($type);
> $type = $_GET['action'];
>
> (Please note - you don't HAVE to "unset" each variable, but if you are
> working in a Register Globals ON environment, it's a good safety
> measure).
>
> AH> strDBPath = Server.MapPath("/_database/database.mdb")
>
> MySQL doesn't work the same way as MDB files (thank goodness), so you
> need to create a connection to the MySQL database:
>
> $link = mysql_connect('localhost', 'username', 'password');
>
> AH> Set cnn = Server.CreateObject("ADODB.Connection")
> AH> cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
>
> mysql_select_db('database_name', $link);
>
> AH> Set rst = cnn.Execute("SELECT * FROM table WHERE Type ='" & type & "'
> AH> order by style")
>
> $sql= "SELECT * FROM table WHERE type='$type' ORDER BY style";
> $result = mysql_query($sql);
>
> You now have the entire "record set" in $result. To obtain the first
> row of data, do this:
>
> AH> <%Do While Not rstSimple.EOF%>
> AH> do something
> AH> <%
> AH> rstSimple.MoveNext
> AH> Loop
>
> A few ways to do this:
>
> $total_records = mysql_num_rows($result);
>
> for ($i=0; $i < $total_records; $i++)
> {
> $data = mysql_fetch_assoc($result);
> print_r($data);
> }
>
> $data will now be an array holding the first set of information. The
> print_r line just displays it so you can see it easily.
>
> Instead of a FOR loop you could do a "while" loop checking to see the
> end of the $result set, i.e.:
>
> while ($row = mysql_fetch_array($result, MYSQL_NUM))
> {
> // do stuff
> print_r($row);
> }
>
> AH> <%=rst.fields("whatever").value%>
>
> <?=$data['whatever']?>
>

attached mail follows:


Since I am assuming "Type" is a text field, you will want to enclose it
in single quotes. Also, because I am anal retentive, I like to also use
the addslashes() function on any input coming in on the GET string or
via a POST. Also, since all variables are preceded by a $ character,
your call to mysql_query will fail.

So, I would change your code to something like this:
$type = addslashes($_GET['type']);
$sql = "SELECT * FROM tbCategory WHERE Type ='$type' order by style";
$resultID = mysql_query($sql, $db);

HTH!

--Sam

Alistair Hayward wrote:
> This is what I have:
> <?php
>
> $connection = mysql_connect("localhost","root","batman");
> if (!$connection) {
> echo "Couldn't make a connection!";
> exit;
> }
> $db = mysql_select_db("sealhouse", $connection);
> if (!$db) {
> echo "Couldn't select database!";
> exit;
> }
> $type = $_GET['type'];
> $sql = "SELECT * FROM tbCategory WHERE Type =$type order by
style";
> $resultID = mysql_query($sql, DB);
>
>>
>
>
> Chris W. Parker wrote:
>
>> Alistair Hayward <mailto:alistairco-sys.co.nz>
>> on Wednesday, March 10, 2004 2:46 PM said:
>>
>>
>>> This is what I get when I try to create the recordset....
>>>
>>> Notice: Use of undefined constant DBlink - assumed 'DBlink' in
>>> D:\Development\Completed\Sealhouse\phpSealTest\ProductSpecs.php on
>>> line 24
>>
>>
>> well you're going to need to do a *little* research on your own.
>>
>> oh what the heck...
>>
>> DBlink is the same as your cnn in your asp code. in other words you
>> still need to create a connection to a database.
>>
>>
>>
>> chris.

attached mail follows:


Richard Davey wrote:
> A few ways to do this:
>
> $total_records = mysql_num_rows($result);
>
> for ($i=0; $i < $total_records; $i++)
> {
> $data = mysql_fetch_assoc($result);
> print_r($data);
> }
> $data will now be an array holding the first set of information. The
> print_r line just displays it so you can see it easily.
>
> Instead of a FOR loop you could do a "while" loop checking to see the
> end of the $result set, i.e.:
>
> while ($row = mysql_fetch_array($result, MYSQL_NUM))
> {
> // do stuff
> print_r($row);
> }
>
> AH> <%=rst.fields("whatever").value%>
>
> <?=$data['whatever']?>
>

I get this error: mysql_num_rows(): supplied argument is not a valid
MySQL result resource

Question: Where you have the //do stuff comment, I assume this is where
my HTML code will go. But can I put it between the open brackets? I.E:
{
html code
}

?

attached mail follows:


Hello Alistair,

Wednesday, March 10, 2004, 11:26:53 PM, you wrote:

AH> I get this error: mysql_num_rows(): supplied argument is not a valid
AH> MySQL result resource

Then your database connection failed OR the SQL query did. Check those
steps over before anything else.

Maybe post that part of your code so we can see?

AH> Question: Where you have the //do stuff comment, I assume this is where
AH> my HTML code will go. But can I put it between the open brackets? I.E:
AH> {
AH> html code
AH> }

Yes like so:

{
?>
html here
<?
}

Just like in ASP :)

--
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

attached mail follows:


Hi.
There is an ADO simulator for PHP (i think it's called ADODB PHP but i
can't remember the link). There is also a asp to php converter called
(can you guess? ) asp2php.

Alistair Hayward wrote:

> Hi ,
>
> What is the equavilant in PHP to creating a recordset in ASP using a
> query?
> This is what I do in PHP:
> ..................................
>
> dim Type
> Type = CStr(Request.QueryString("action")) (getting parameter from URL)
>
> Dim cnn ' ADO connection
> Dim rst ' ADO recordset
> Dim strDBPath ' path to my Access database (*.mdb) file
>
> strDBPath = Server.MapPath("/_database/database.mdb")
> Set cnn = Server.CreateObject("ADODB.Connection")
> cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath &
> ";"
>
> Set rst = cnn.Execute("SELECT * FROM table WHERE Type ='" & type & "'
> order by style")
> ..........................................
> I can then call any field and display it in the html by using :
> <%=rst.fields("whatever").value%>
> ..........................................
> I can also create a loop:
> <%Do While Not rstSimple.EOF%>
> do something
> <%
> rstSimple.MoveNext
> Loop
> %>
> ............................................
>
> Please can someone show me how to do the same thing in PHP?
>
> Alistair
>

--
Raditha Dissanayake.
---------------------------------------------------------------
http://www.radinks.com/upload/
Drag and Drop Upload thousands of files and folders in a single
transfer. (HTTP or FTP)

attached mail follows:


Richard Davey wrote:
> Hello Alistair,
>
> Wednesday, March 10, 2004, 11:26:53 PM, you wrote:
>
> AH> I get this error: mysql_num_rows(): supplied argument is not a valid
> AH> MySQL result resource
>
> Then your database connection failed OR the SQL query did. Check those
> steps over before anything else.
>
> Maybe post that part of your code so we can see?
>
> AH> Question: Where you have the //do stuff comment, I assume this is where
> AH> my HTML code will go. But can I put it between the open brackets? I.E:
> AH> {
> AH> html code
> AH> }
>
> Yes like so:
>
> {
> ?>
> html here
> <?
> }
>
> Just like in ASP :)
>

<?php

unset($type);
$type = $_GET['type'];

$link = mysql_connect('localhost', 'user', 'password');
        if (!$link) {
         echo "Couldn't make a connection!";
         exit;
     }
        $db = mysql_select_db("sealhouse", $link);
        if (!$db) {
         echo "Couldn't select database!";
         exit;
     }
$sql= "SELECT * FROM table WHERE type=$type ORDER BY style";
$result = mysql_query($sql);

$total_records = mysql_num_rows($result);

attached mail follows:


Sorry, was the query!

>
>
> Richard Davey wrote:
>
>> Hello Alistair,
>>
>> Wednesday, March 10, 2004, 11:26:53 PM, you wrote:
>>
>> AH> I get this error: mysql_num_rows(): supplied argument is not a valid
>> AH> MySQL result resource
>>
>> Then your database connection failed OR the SQL query did. Check those
>> steps over before anything else.
>>
>> Maybe post that part of your code so we can see?
>>
>> AH> Question: Where you have the //do stuff comment, I assume this is
>> where
>> AH> my HTML code will go. But can I put it between the open brackets?
>> I.E:
>> AH> {
>> AH> html code
>> AH> }
>>
>> Yes like so:
>>
>> {
>> ?>
>> html here
>> <?
>> }
>>
>> Just like in ASP :)
>>
>
> <?php
>
> unset($type);
> $type = $_GET['type'];
>
> $link = mysql_connect('localhost', 'user', 'password');
> if (!$link) {
> echo "Couldn't make a connection!";
> exit;
> }
> $db = mysql_select_db("sealhouse", $link);
> if (!$db) {
> echo "Couldn't select database!";
> exit;
> }
> $sql= "SELECT * FROM table WHERE type=$type ORDER BY style";
> $result = mysql_query($sql);
>
> $total_records = mysql_num_rows($result);

attached mail follows:


On Wednesday 10 March 2004 18:54, Raditha Dissanayake wrote:
> Hi.
> There is an ADO simulator for PHP (i think it's called ADODB PHP but i
> can't remember the link). There is also a asp to php converter called
> (can you guess? ) asp2php.

http://php.weblogs.com/

And

Pear::DB must work too :P
http://pear.php.net/package/DB

http://www.onlamp.com/pub/a/php/2001/11/29/peardb.html

--
roche

attached mail follows:


Hello Alistair,

Thursday, March 11, 2004, 1:25:47 AM, you wrote:

AH> <?php

AH> unset($type);
AH> $type = $_GET['type'];

AH> $link = mysql_connect('localhost', 'user', 'password');
AH> if (!$link) {
AH> echo "Couldn't make a connection!";
AH> exit;
AH> }
AH> $db = mysql_select_db("sealhouse", $link);
AH> if (!$db) {
AH> echo "Couldn't select database!";
AH> exit;
AH> }
AH> $sql= "SELECT * FROM table WHERE type=$type ORDER BY style";
AH> $result = mysql_query($sql);

AH> $total_records = mysql_num_rows($result);

Try and put single quotes around the $type in your query. Especially
if it's not numeric:

$sql = "SELECT blah WHERE type='$type'";

Otherwise, the code is fine. So assuming the database exists and the
query is valid (i.e. works from MySQL itself) then it should work.

--
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

attached mail follows:


To everyone, especially Richard,

Thanks a lot for the help. I have accomplished everything I needed to do
with your help, and I have never used PHP before.

Thanks again!

alistair

attached mail follows:


I was given a database that has uniques IDs such as:

AL00001
AL00002
AR00001
AR00002
MI00001
etc...

The first two letters are based on the state they live
in, then it would need to look at the next 5
characters to determine the next ID.

My problem is how do I recreate this in PHP to make
sure any newly added records follow this same unique
ID?

So if I insert another Alabama record the id would be:
AL00003

Or insert a record from a new state would be:
NY00001 (so NY00000 is the default starting point)

Any ideas? Thank you in advance!

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

attached mail follows:


J J <mailto:squid_66yahoo.com>
    on Wednesday, March 10, 2004 3:46 PM said:

> Any ideas? Thank you in advance!

does it all have to be in the same field? can you not just combine two
fields?

one field would be called 'id' and it would be auto-incrementing.
second field would be 'state' and it would contain the two letter
abbreviation.

i can think of a few other ways to get it all into one field, but
they're a bit less efficient. then again i'm no sql expert.

chris.

attached mail follows:


I'd like to keep it in one field if possible since
that's how their database is now and data will be
going back and forth.

Plus there should be allowed two of the same numbers,
so like:

AL00003
KY00003

So any state with more than one record can be
sequential and not jump around like KY00003, AL00004,
KY00005, etc.

Make sense?

--- "Chris W. Parker" <cparkerswatgear.com> wrote:
> J J <mailto:squid_66yahoo.com>
> on Wednesday, March 10, 2004 3:46 PM said:
>
> > Any ideas? Thank you in advance!
>
> does it all have to be in the same field? can you
> not just combine two
> fields?
>
> one field would be called 'id' and it would be
> auto-incrementing.
> second field would be 'state' and it would contain
> the two letter
> abbreviation.
>
> i can think of a few other ways to get it all into
> one field, but
> they're a bit less efficient. then again i'm no sql
> expert.
>
>
>
> chris.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

attached mail follows:


J J <mailto:squid_66yahoo.com>
    on Wednesday, March 10, 2004 4:03 PM said:

> I'd like to keep it in one field if possible since
> that's how their database is now and data will be
> going back and forth.

[snip]

> So any state with more than one record can be
> sequential and not jump around like KY00003, AL00004,
> KY00005, etc.
>
> Make sense?

yeah that makes sense. hmm.. well i'll give you my idea.. but it's very
possible there's a better way to do it (than what i'm going to suggest).

ok. one field will be used. it'll be a text (varchar) field. before you
do an insert you'll need to find out what's in there ahead of time and
then adjust accordingly. i'd select the last record that contained the
two letter abbreviation, find out what the number was, increment it,
then reconstruct the id and insert the new one.

this of course won't prevent the exact same process from happening at
the exact same time. i mean, two sessions could pull the same id and
then reconstruct the (new, but) same id.

make sense?

chris.

attached mail follows:


Will it be able to figure out what the last number is
if it's a character type and the number is something
like 00003? So it'll add one to make it 00004 and not
something like 10003.

??

--- "Chris W. Parker" <cparkerswatgear.com> wrote:
>
> yeah that makes sense. hmm.. well i'll give you my
> idea.. but it's very
> possible there's a better way to do it (than what
> i'm going to suggest).
>
> ok. one field will be used. it'll be a text
> (varchar) field. before you
> do an insert you'll need to find out what's in there
> ahead of time and
> then adjust accordingly. i'd select the last record
> that contained the
> two letter abbreviation, find out what the number
> was, increment it,
> then reconstruct the id and insert the new one.
>
> this of course won't prevent the exact same process
> from happening at
> the exact same time. i mean, two sessions could pull
> the same id and
> then reconstruct the (new, but) same id.
>
> make sense?
>
>
> chris.
>

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

attached mail follows:


J J <mailto:squid_66yahoo.com>
    on Wednesday, March 10, 2004 4:22 PM said:

> Will it be able to figure out what the last number is
> if it's a character type and the number is something
> like 00003? So it'll add one to make it 00004 and not
> something like 10003.

php knows. you'll just have to pad the string with zeros.

<?php

  $number = "000001";

  ++$number;

  echo $number;

?>

that will output "2" not "1000001".

chris.

attached mail follows:


At 04:10 PM 3/10/2004 -0800, Chris W. Parker wrote:
>J J <mailto:squid_66yahoo.com>
> on Wednesday, March 10, 2004 4:03 PM said:
>
> > I'd like to keep it in one field if possible since
> > that's how their database is now and data will be
> > going back and forth.
>
>[snip]
>
> > So any state with more than one record can be
> > sequential and not jump around like KY00003, AL00004,
> > KY00005, etc.
> >
> > Make sense?
>
>yeah that makes sense. hmm.. well i'll give you my idea.. but it's very
>possible there's a better way to do it (than what i'm going to suggest).
>
>ok. one field will be used. it'll be a text (varchar) field. before you
>do an insert you'll need to find out what's in there ahead of time and
>then adjust accordingly. i'd select the last record that contained the
>two letter abbreviation, find out what the number was, increment it,
>then reconstruct the id and insert the new one.
>
>this of course won't prevent the exact same process from happening at
>the exact same time. i mean, two sessions could pull the same id and
>then reconstruct the (new, but) same id.
>
>make sense?
>
>
>chris.

Yes Chris, that's the right idea. The problem is that this is being done
across the 'Net. Ideally you try and get a lock on the row for a given
state, fetch the value and increment/update, then release the lock. In a
web environment locks are a little tricky - what happens if a connection is
lost or times out?

For the original poster: Having said all this, make certain that there is
a unique, system-generated, primary key for each table. As these keys
*never* have to be seen by the public, don't get tampered with, etc., they
can be safely relied on for inter-table relationships. Down the road they
will save your bacon.

If the purpose of having separate numbering sequences for each state is to
keep track of a count, why bother? Just select for a count on each state.
If it's a matter of ego, in that if I have a lower registration number I
have higher status, well fill your boots with whatever scheme will work.

Really look at this v. closely. Quite often clients insist on wacko
numbering schemes which they are convinced are important, but frequently
result only because that's the way it's always been done. Also remember
there should be no data encoding within a field - that's why so many
columns are possible.

Example, membership numbers like MABT082003BM2, where the first four
characters are my initials, the next six the date I joined, and each of
the next the colour of my eyes, marital status and number of children, ARE
FORBIDDEN. All that information belongs in separate fields. This is what
you are tending towards with AL0003 and KY00107. Bad practice.

As I'm Canadian, if I stepped on any toes I'll apologize in advance. <g>

Cheers - Miles

attached mail follows:


Yeah thanks for the feedback, I'm already including a
primary key auto_increment field in place to tie the
tables together with an ID I *know* will be unique.
This other ID scheme is just to work within their
existing system that uses this. I'm just trying to
mirror/maintain that scheme for their purpose.

--- Miles Thompson <milesthompsonns.sympatico.ca>
wrote:
>
>
> For the original poster: Having said all this, make
> certain that there is
> a unique, system-generated, primary key for each
> table. As these keys
> *never* have to be seen by the public, don't get
> tampered with, etc., they
> can be safely relied on for inter-table
> relationships. Down the road they
> will save your bacon.
>
> If the purpose of having separate numbering
> sequences for each state is to
> keep track of a count, why bother? Just select for a
> count on each state.
> If it's a matter of ego, in that if I have a lower
> registration number I
> have higher status, well fill your boots with
> whatever scheme will work.
>
> Really look at this v. closely. Quite often clients
> insist on wacko
> numbering schemes which they are convinced are
> important, but frequently
> result only because that's the way it's always been
> done. Also remember
> there should be no data encoding within a field -
> that's why so many
> columns are possible.
>
> Example, membership numbers like MABT082003BM2,
> where the first four
> characters are my initials, the next six the date I
> joined, and each of
> the next the colour of my eyes, marital status and
> number of children, ARE
> FORBIDDEN. All that information belongs in separate
> fields. This is what
> you are tending towards with AL0003 and KY00107. Bad
> practice.
>
> As I'm Canadian, if I stepped on any toes I'll
> apologize in advance. <g>
>
> Cheers - Miles
>
> --

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

attached mail follows:


On 10 Mar 2004 J J wrote:

> My problem is how do I recreate this in PHP to make
> sure any newly added records follow this same unique
> ID?

I haven't played much with these functions but I think for MySQL you'd
want something like this, for the state "XX" (excuse the wrapped
lines):

        if ($result =
        mysql_query("select max(id) from table where left(id, 2) = 'XX'")) {
                $row = mysql_fetch_row($result);
                $newid = strpad($row[0] + 1, 5, "0", STR_PAD_LEFT);
                mysql_query("insert into table set id = 'XX'" . $newid);
                $newrecnum = mysql_insert_id();
        }

That is crude and uuntested, needs some error checking and most likely
table locking, but it's one possibility for a base.

--
Tom

attached mail follows:


Wow I think you are on to something!!! I'll give it a
whirl!

Thanks!

--- trlistsclayst.com wrote:
> On 10 Mar 2004 J J wrote:
>
> > My problem is how do I recreate this in PHP to
> make
> > sure any newly added records follow this same
> unique
> > ID?
>
> I haven't played much with these functions but I
> think for MySQL you'd
> want something like this, for the state "XX" (excuse
> the wrapped
> lines):
>
> if ($result =
> mysql_query("select max(id) from table where
> left(id, 2) = 'XX'")) {
> $row = mysql_fetch_row($result);
> $newid = strpad($row[0] + 1, 5, "0",
> STR_PAD_LEFT);
> mysql_query("insert into table set id = 'XX'" .
> $newid);
> $newrecnum = mysql_insert_id();
> }
>
> That is crude and uuntested, needs some error
> checking and most likely
> table locking, but it's one possibility for a base.
>
> --
> Tom
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

attached mail follows:


Hi there,

can anybody recommend tools to messure page loading time of php pages.
I am working on a new site and it apears to me that the old one loads
much faster. Are there any tools around to break this down to hard numbers?

thanx for any hint,

merlin

attached mail follows:


Merlin <mailto:news.groupsweb.de>
    on Wednesday, March 10, 2004 5:05 PM said:

> can anybody recommend tools to messure page loading time of php pages.
> I am working on a new site and it apears to me that the old one loads
> much faster. Are there any tools around to break this down to hard
> numbers?

you can time your scripts on the command line to see how long they
execute. maybe that will shed some light?

$ time php myscript.php

another idea is that maybe the old server was gzipping the data before
it went over the pipe and now it's not?

chris.

attached mail follows:


You can also use something like Turck MMCache to accelerate the scripts.
There is a class at http://pear.php.net for benchmarking PHP scripts and you
can use a web client that times how long it takes to download a page.

I would look at template caching and Turck MMCache to increase performance.

jason

-----Original Message-----
From: Chris W. Parker [mailto:cparkerswatgear.com]
Sent: Wednesday, March 10, 2004 6:15 PM
To: Merlin; php-generallists.php.net
Subject: RE: [PHP] How to mesure response time of php pages

Merlin <mailto:news.groupsweb.de>
    on Wednesday, March 10, 2004 5:05 PM said:

> can anybody recommend tools to messure page loading time of php pages.
> I am working on a new site and it apears to me that the old one loads
> much faster. Are there any tools around to break this down to hard
> numbers?

you can time your scripts on the command line to see how long they execute.
maybe that will shed some light?

$ time php myscript.php

another idea is that maybe the old server was gzipping the data before it
went over the pipe and now it's not?

chris.

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

attached mail follows:


Hi,

Thursday, March 11, 2004, 11:05:08 AM, you wrote:
M> Hi there,

M> can anybody recommend tools to messure page loading time of php pages.
M> I am working on a new site and it apears to me that the old one loads
M> much faster. Are there any tools around to break this down to hard numbers?

M> thanx for any hint,

M> merlin

Apache comes with a benchmark tool called ab which is good for this
kind of thing. You will need to give it a full path like
http://domain.com/index.php

--
regards,
Tom

attached mail follows:


two files proxy.php and image.php

proxy downloads the website and image downloads the pictures

proxy.php------------------------------------------------------
<?php

/************************************************\
* Check to see if a web address is present... *
* iproxy is where the imagaes are loaded *
* myproxy is the addres of the proxy php page *
\************************************************/

if(isset($_GET['web']))
{

$stimer = explode( ' ', microtime() );
$stimer = $stimer[1] + $stimer[0];

  $web = $_GET['web'];
  $iproxy = 'http://www.website.com/image.php?image=';
  $myproxy = 'http://www.website.com/proxy.php?web=';
  $site = '<a href="'.$myproxy.$web;

/************************************************\
* opens the remote page for reading *
* and loads it into alltext *
\************************************************/

  $fd = fopen($web,"rb");
  $alltext = "";
  do
  {
    $data = fread($fd, 8192);
    if (strlen($data) == 0)
    {
      break;
    }
    $alltext .= $data;
  }
  while (true);
  fclose($fd);

/************************************************\
* strips the address down to its root *
* unless it already is *
\************************************************/

  $web1 = dirname ($web);
  if($web1 !== "http:")
  {
    $web = $web1;
  }

/************************************************\
* removes current web address from tags and *
* checks for all variants of spacing and quotes *
* and then prints it out onto the screen *
\************************************************/

$pattern = array(
'{src[ ]*=[ ]*("|\')}i',
'{src=("|\')'.$web.'}i',
'{src=("|\')/}i',
'{src=("|\')http}i',
'{src=("|\')}i',
'{("|\'):::}i',
'{\.src[ ]*=[ ]*}i',
'{\.src="'.$web.'}i',
'{\.src="/}i',
'{\.src="http}i',
'{\.src="}i',
'{:::}i',
'{newImage\(("|\')'.$web.'}i',
'{newImage\(("|\')/}i',
'{newImage\(("|\')}i',
'{<a href[ ]*=[ ]*("|\')}i',
'{<a href=("|\')'.$web.'}i',
'{<a href=("|\')/}i',
'{<a href=("|\')http}i',
'{<a href=("|\')}i',
'{("|\'):::}i',
'{url\(}i',
'{background[ ]*=[ ]*("|\')}i',
'{background=("|\')'.$web.'}i',
'{background=("|\')/}i',
'{background=("|\')}i',
'{(\w)&(\w)}i'
);

$replace = array(
'src=\1',
'src=\1',
'src=\1',
'\1:::',
'src=\1'.$iproxy.$web.'/',
'src=\1'.$iproxy.'http',
'.src="',
'.src="',
'.src="',
':::',
'.src= "'.$iproxy.$web.'/" + ',
'src="'.$iproxy.'http'.'" + ',
'newImage(\1',
'newImage(\1',
'newImage(\1'.$iproxy.$web.'/',
'<a href=\1',
'<a href=\1',
'<a href=\1',
'\1:::',
'<a href=\1'.$myproxy.$web.'/',
'<a href=\1'.$myproxy.'http',
'url('.$iproxy.$web.'/',
'background=\1',
'background=\1',
'background=\1',
'background=\1'.$iproxy.$web.'/',
'\1 \2'
);

  $alltext = preg_replace($pattern, $replace, $alltext);

  $alltext = preg_replace('{<a
href=("|\')http://www\.website\.com/proxy\.php\?web=([^>]*)(gif|jpeg)}i',
'<a href=\1'.$iproxy.'\2\3', $alltext);

//-------------------------------------------------

$etimer = explode( ' ', microtime() );
$etimer = $etimer[1] + $etimer[0];
echo '<p style="margin:auto; text-align:center">';
printf( "Script timer: <b>%f</b> seconds. Parsed ".strlen($alltext)."
chars.", ($etimer-$stimer) );
echo '</p>';

  echo $alltext;
}

?>

image.php------------------------------------------------------
<?php

/************************************************\
* gets the image name an location from proxy.php *
* loads the image as image.php for proxy to call *
\************************************************/

$img = $_GET['image'];
$img = preg_replace("{ }", "&", $img);
$fd = fopen("$img","rb");
$alltext = "";
do
{
  $data = fread($fd, 8192);
  if (strlen($data) == 0)
  {
    break;
  }
  $alltext .= $data;
  //set_time_limit(1);
}
while (true);
fclose($fd);

echo $alltext;
?>

attached mail follows:


"Jay Blanchard" <jay.blanchardniicommunications.com> wrote in message news:C8F323573C030A448F3E5A2B6FE2070B035222B2nemesis...
[snip]
....stuff....
[/snip]

From http://www.w3.org/TR/html4/interact/forms.html#h-17.13.1

17.13.1 Form submission method
The method attribute of the FORM element specifies the HTTP method used
to send the form to the processing agent. This attribute may take two
values:

get: With the HTTP "get" method, the form data set is appended to the
URI specified by the action attribute (with a question-mark ("?") as
separator) and this new URI is sent to the processing agent.
post: With the HTTP "post" method, the form data set is included in the
body of the form and sent to the processing agent.
The "get" method should be used when the form is idempotent (i.e.,
causes no side-effects). Many database searches have no visible
side-effects and make ideal applications for the "get" method.

If the service associated with the processing of a form causes side
effects (for example, if the form modifies a database or subscription to
a service), the "post" method should