Re: [PHP] HELP - Clean and simple

2006-05-22 Thread Scott Hurring

On 5/22/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:


while($row=mysql_fetch_array($result)) {

if (!$$row[0]) {

$$row[0] = array();

$$row[0][$row[2]] = $row[1];

}

else {

$$row[0][$row[2]] = $row[1];

}

}



IMO, unless you have a *really* good reason for doing things this way,
putting values into an array is almost always better than using the "$$"
direct declaration.

i.e.  why not use? $vars[ $row[0] ][ $row[2] ] = $row[1];

--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] Date() finding yesterday

2006-05-21 Thread Scott Hurring

mktime also works: http://php.net/mktime:

date("Y-m-d", mktime( ... ))

On 5/21/06, Rabin Vincent <[EMAIL PROTECTED]> wrote:


On 5/21/06, John Taylor-Johnston
<[EMAIL PROTECTED]> wrote:
> I cannot seem to get this right. How can I produce yesterday?
>
> $today = date("Y-m-d");
> $yesterday = date("Y-m-") . date("d")-1;
> $yesterday = date("Y-m-d")-1;
> $yesterday = date("Y-m-"."d"-1);
>
> I've been looking at the manual :) ...

Use php.net/strtotime:

$yesterday = date('Y-m-d', strtotime('-1 day'));

Rabin

--
http://rab.in

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





--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] Running two versions of PHP locally

2006-05-19 Thread Scott Hurring

On 5/19/06, John Hicks <[EMAIL PROTECTED]> wrote:


It looks like 'application/x-httpd-php' is the default type for php4.
Does php5 have a different type? Is there a way to explicitly assign a
new type to a module?

To be more explicit: When installing php5, what do I need to do to make
this configuration work:


 ServerName myPhp4domain.com
 DocumentRoot /allmydomains/myPhp4domain
...
 
 AddType application/x-httpd-php .php
...
 



 ServerName myPhp5domain.com
 DocumentRoot /allmydomains/myPhp5domain
...
 
 AddType  .php
...
 


If this is possible, it would be a much cleaner upgrade path than mixing
a module and a cgi setup.



I may be wrong, but last time i checked, i remember reading that both the
php4 and php5 module use the same type and it was impossible to have them
both installed as modules in that way.  This was a while back, *right* when
php5 first came out, so things may have changed by now.

But that's pretty much why i went with a mixed Module/CGI approach, because
i didnt see any way (short of port proxying or file extensions, which i
didn't want to do just for aesthetic reasons) to get two concurrent modules
to play nice together.

After all, the goal is to be able to upgrade from php4 to php5,

gradually, on a domain-by-domain or even page-by-page basis. Forcing a
transition to cgi along with a transition to PHP5 compounds the
complexity of the task.



In my experience, there was no real difference between module php4 and CGI
php5 aside from a slight performance/memory hit for the CGI.  But i wasn't
running sites that got an insane amount of traffic, so i was quite willing
to take the small performance hit for the improvements offered by php5.

Also, i did this on a dedicated box i was in complete control of, not a
multi-user vhost.  There might be security implications for CGI php5 that
i'm not aware of, simply because i didn't use it in that context.

I'd be interested to know if anyone does get both php4 & php5 modules
installed together without file extention hints or port proxying.

--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] PHP & JavaScript

2006-05-19 Thread Scott Hurring

Yeah, i guess it all depends what you're doing what works for you.

Another avenue to try (depending on your application) is:
Group all your checkboxes together inside of a uniquely-named DIV and then
use javascript to get all of the "checkbox" elements inside the DIV.  That
way, you dont really need to know or care about their id/name.

On 5/19/06, Jay Blanchard <[EMAIL PROTECTED]> wrote:


[snip]
For grouped checkboxes that have numerical keys, why not give them an ID
that's simply a concatenation of NAME and the VALUE, so it's unique?
[/snip]

Because JavaScript loops through all the like ID'ed checkboxes to check
or uncheck groups. It could be done the other way, but then JavaScript
code has to have more to it to increment from the value of the first ID.

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





--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] Running two versions of PHP locally

2006-05-19 Thread Scott Hurring

You should be able to do that with PHP4 and PHP5.

However, most people don't wnat to have to use "php5" and "php4" as file
extensions but rather want to be able to say, "everything on blah.com use
php5 and everything on foo.org use php4"... or even to specify differeing
versions within a single host (on a per-directory basis)

You can easily accomplish this by using PHP4 as a module and PHP5 as CGI
(and i'm sure other ways as well, but ive only personally done it this way)

It makes it very easy to selectively downgrade (or upgrade) depending on
your needs without having to jump through file-naming hoops or proxy ports,
etc...


On 5/19/06, John Hicks <[EMAIL PROTECTED]> wrote:


Just a quick sanity check from a php4 user who's thinking of trying php5:

With PHP3 and PHP4 (I thought) you could install both Apache modules and
invoke them on a page by page basis based on the extension you assign
them in Apache ( .php v. .php4 for example).

Are you all saying you can't do that with PHP4 and PHP5? Why not?

Thanks,

---J

Richard Lynch wrote:
> With Apache, find Rasmus' post regarding "Proxy PHP4 PHP5" in the
> archives of this very list.
>
> You're on your own with IIS.
>
> On Fri, May 19, 2006 11:07 am, Phillip S. Baker wrote:
>> Greetings Gents,
>>
>> I am interested in running two versions of of PHP.
>> I want to see if I can get my boss to buy into migrating to PHP 5.
>>
>> I want to set it up locally.
>>
>> Locally I am running apache on a windows XP box with PHP 4.
>>
>> I would like I would like to be able to set up PHP 5 as well on the
>> server and have some folders/virtual hosts set up in php 4 and others
>> in
>> php 5?
>>
>> Is this possible?
>> How would I go about doing it?
>>
>> Thanks
>>
>> Phillip
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>

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





--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] PHP & JavaScript

2006-05-19 Thread Scott Hurring

For grouped checkboxes that have numerical keys, why not give them an ID
that's simply a concatenation of NAME and the VALUE, so it's unique?

Run the NAME though a preg_replace to replace non alphanum chars (\W+) with
an underscore first to make sure it's a valid ID.

i.e.




I've used this with some code i wrote that allows me to either output a
multi-select or a group of checkboxes, from a single array of values.

On 5/19/06, Richard Lynch <[EMAIL PROTECTED]> wrote:


Simplest solution is to use id="whatever" for JS.

It *is* possible to get [] into the name of a box in JS, but I never
succeeded in any useful way myself.

On Fri, May 19, 2006 9:33 am, Jay Blanchard wrote:
> Can they play nicely together?
>
> For instance I have a small JavaScript sniplet that will check certain
> checkboxes if a radio button is selected. Since I have a fair amount
> of
> checkboxes I want to put them in an array all their own so I use the
> XHTML syntax w/brackets;
>
> 
>
> Suddenly JavaScript doesn't care for the object and throws an error
> (take the brackets out and it works fine for JS, but PHP cannot see
> all
> of the values). I have Googled for this but think that my search
> term(s)
> are failing me because the condition is hard to describe.  Would
> someone
> please point me in the right direction?
>
> Thanks!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Like Music?
http://l-i-e.com/artists.htm

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





--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] Running two versions of PHP locally

2006-05-19 Thread Scott Hurring

I wrote up a little HOWTO on my site on getting PHP4 (as module) and PHP5
(as cgi) running concurrently.  Maybe it'll help

http://hurring.com/howto/php4_and_php5/

On 5/19/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Phillip S. Baker wrote:
> I am interested in running two versions of of PHP.
> I want to see if I can get my boss to buy into migrating to PHP 5.
>
> I want to set it up locally.
>
> Locally I am running apache on a windows XP box with PHP 4.
>
> I would like I would like to be able to set up PHP 5 as well on the
> server and have some folders/virtual hosts set up in php 4 and others in
> php 5?
>
> Is this possible?
> How would I go about doing it?

Set up one as module, the other as CGI (or both as CGI of course).

google will provide you with many many pointers on this subject, eg:

http://www.gentoo.org/proj/en /php/php4-php5-configuration.xml

Gr,

Koen

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





--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] Encryption Advice

2006-05-19 Thread Scott Hurring

On 5/19/06, Lawrence Kennon <[EMAIL PROTECTED]> wrote:


For an ecommerce site where sensitive data is stored
either in files, or in a database, have you used some
form of encryption to protect your customer's data?

I have a client who currently uses a Perl scripted
shopping cart that stores orders (including credit
card numbers) in plain text files on a shared server.
The security of these files depends purely on the
user/file system security measures enforced by the
hosting company (which I think is a reasonably good
company, but still I don't see it as being
sufficiently secure).

I am going to rewrite the shopping cart using PHP and
was looking into ways to protect the data. Using GNU
Privacy Guard (gpg) seemed like the ideal method
because I could store the client's public key on the
server to encrypt orders and the customer could then
download the encrypted files and decrypt them on his
PC with his private key (the client manually submits
orders through his "store front" merchant account). I
know this is a somewhat archaic procedure but it works
sufficiently well for this client.

However the hosting company won't support gpg so that
leaves me with PHP mcrypt functions which I think
would work very well, except for on thing - how to
protect the secret key which now has to be on the
server?

Any ideas/suggestions/experience along that line?

Thanks in advance,

Lawrence Kennon




Lawrence, from the very start, if you're on a shared-server, security is
going to be compromised to a large degree.  Hopefully your server at least
uses suexec or suphp to prevent other people's scripts reading your data.
If not, i'd say look for a new host immediately.

As for your private key.  Step 1 is to definitely keep it outside your
doc_root, Step 2 is to give it really restrictive permissions like 400 or
600.  I'm not entirely sure how much you can really do above that on a
shared server.

If you can convince your clients that security is a top-priority on this
project, talk about getting a dedicated box so that your first-level of
defense is simply "nobody else is on the box", then you can worry a little
bit less about your private key being stolen.

--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] Session Not Being Passed?

2006-05-19 Thread Scott Hurring

On 5/19/06, Richard Lynch <[EMAIL PROTECTED]> wrote:


On Thu, May 18, 2006 9:23 pm, Mark Sargent wrote:
> Movie 1
> 
> 
>  $favMovie=urlencode("Life Of Brian");
> echo " href='http://localhost/moviesite.php?favMovie=$favMovie'>";

Errr.

localhost is going to end up being THEIR localhost, which is, like,
their own computer where the browser is, which is very very very
unlikely to have your moviesite.php script on it, if you see what I
mean...

Unless YOU are running this on your own desktop or something.



I almost never use a server name for this reason.  If you simply use an
absolute path, it'll point to whatever machine (local dev, live server,
etc...) it happens to be running on without you having to care.

i.e. 

--
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/


Re: [PHP] Question about "if" statement evaluating (0=="string")as TRUE

2003-02-03 Thread Scott Hurring
I figured it was along those lines... i know that perl also caught
me a few times becuase perl differentiates between "==" and "eq"
for numerical or string comparisions.

I'll probaly end up using the "===", becuase i've got a severe
aversion to using functions for comparisions.  :-)

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Marco Tabini" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I think this is happening because you're comparing apples to oranges.
> Your first comparison causes an integer to be compared to a string.
> Because the string "string" evaluates to the integer value 0, the
> comparison succeeds. The manual recommends the use of the identical
> comparison operator (===) instead, or--better yet--the strcmp() function
> when comparing two strings.
>
> Cheers,
>
>
> Marco
>
> --
> 
> php|architect - The magazine for PHP Professionals
> The monthly worldwide magazine dedicated to PHP programmers
>
> Come visit us at http://www.phparch.com!
>



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




[PHP] Re: newbie - decimal places in arthimetic functions

2002-12-13 Thread Scott Hurring
round it

http://www.php.net/manual/en/function.round.php

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Max Clark" <[EMAIL PROTECTED]> wrote in message
atdba1$2id$[EMAIL PROTECTED]">news:atdba1$2id$[EMAIL PROTECTED]...
> Hi-
>
> How can I control the decimal places returned by an arthimetic function?
>
> I would like this divsion function to only return two decimal places
> (rounded up).
>
> $calcsize = $value / $oneGig;
>
> Thanks in advance,
> Max
>
>
>
>



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




[PHP] Question about "if" statement evaluating (0=="string") as TRUE

2002-12-13 Thread Scott Hurring
Erm... this seems a bit odd to me.  I'm using PHPv4.2.2 on Win32

Is that becuase PHP is not properly comparing the numerical value with
the string value?





--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--



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




[PHP] Re: Displaying output from MySQL

2002-12-11 Thread Scott Hurring
Add 0



--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Beauford.2002" <[EMAIL PROTECTED]> wrote in message
001b01c2a1af$b9995e20$6401a8c0@p1">news:001b01c2a1af$b9995e20$6401a8c0@p1...
> Hi,
>
> Not sure if this is a PHP of a MySQL question, so I am sending it to both
> groups. Basically I have a list of numbers with two decimal places in the
> MySQL database, but I only want to display some of them with the decimal
> points.
>
> i.e.
>
> 70 (not 70.00)
> 87
> 51.5
> 46.75
> 12
> 29
> 5.5
> -1
> 45
>
> I know it's probably a weird request, but any thoughts on how one would do
> this.
>
> TIA
>
>



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




[PHP] Re: # of lines in a file

2002-12-09 Thread Scott Hurring
... or, if the file is HUGE and you don't want to read it all into RAM
using file(), you could open the file using fopen() and read line-by-line
until you get to the one you want.  (or use fseek() fread() funcs to grab
a big chunk of text at once and then count the newlines, and loop until
you find the line you want)

TIMTOWTDI :-)

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
<[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hey guys, I've been searching the manual for a way to grab the number of
> lines in a file and read a particular line from it, however I found no
> solution to my problem so I'm wondering if any of you out there could help me
> :-)
>
> - CS
>



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




Re: [PHP] Re: Not able to connect to FTP server

2002-12-09 Thread Scott Hurring
it doesn't look like the FTP is failing becuase of the if() construction,
becuase this works fine...



Have you tried checking error messages (IIRC, $php_errmsg can be
setup to hold the most recent error message), or try turning up the
error reporting on your test server to E_ALL (look in php.ini)

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Adam Voigt" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Umm, try this:

$ftp = ftp_connect("ftp.direw.net") or die("Couldn't connect.");

See if you get "Couldn't connect".
I suspect it's cause your both checking the variable and setting it in
the same clause.


On Mon, 2002-12-09 at 12:34, bill wrote:
Have you tried passive mode?

Vinod wrote:

> Hi friends,
>
> I am having a DSL Internet connectivity in our office and my PC is
> connected to Internet using a HTTP/FTP Proxy(192.168.0.10) and the
> browser(Mozilla) in my PC is configured to connect to net through the
> proxy
>
> When I tried to connect to our ftp site using the following script, I
> have received the message that Unable to connect. But the same script
> is working fine with a direct modem connection.
>
> The script is
>
> // connect to ftp server
>
> if(!($ftp=ftp_connect("ftp.dirw.net")))
> {
> print("Unable to connect");
> exit;
> }
>
> Please suggest me on how to connect to the ftp site using the proxy
> server.
>
> Regards,
>
> Vinod.B


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

--
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc



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




Re: [PHP] Dynamic vs. Static

2002-12-09 Thread Scott Hurring
If you do it correctly, yes.

The apache module usually lives somewhere in the apache hierarchy,
whereas the 'php' binary is '/usr/bin/' or '/usr/local/bin/', so they
can quite happily co-exist.

Beware though, when upgrading one, upgrade BOTH.
It drove me nuts once when i forgot, and ended up having a
more recent command line version than apache module
and couldn't figure out why cmdline scripts were acting
differently than when served up thru apache.

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
<[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>  Can I do that using the same src I used to create the dynamic module and
> both would work hapilly together?
>
> Thanks,
>
> Ed
>
>
> On Mon, 9 Dec 2002, John Nichel wrote:
>
> > No.  To get the binary executable, compile it without the apache switch.
> >
> > [EMAIL PROTECTED] wrote:
> > >  When you compile php for apache using the dynamic module example used in
> > > the documentation, do you not get an exacutable php to use from the
> > > command line?
> > >
> > > Ed
> > >
> > >
> > >
> >
> >
> > --
> > By-Tor.com
> > It's all about the Rush
> > http://www.by-tor.com
> >
>



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




Re: [PHP] writing to mysql using php

2002-12-09 Thread Scott Hurring
You're limited to one action per statement, not one record.

Using "UPDATE ... WHERE", you can update any number of rows
with a single SQL statement.

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Hugh Danaher" <[EMAIL PROTECTED]> wrote in message
001301c29fc8$b20f06c0$0100a8c0@win95">news:001301c29fc8$b20f06c0$0100a8c0@win95...
> Shams,
> Most database actions you want your user to do should be limited to them
> writing to one record and/or updating that one record.  If instead you want
> to update information on several records, then you'd need a statement like:
> $table="your_table_name";
> $query=mysql_query("update $table set column_name='what ever' where
> other_column_name='something else'");
> Hope this helps,
> Hugh
>
> - Original Message -
> From: "Enrique Garcia Briones" <[EMAIL PROTECTED]>
> To: "Shams" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Monday, December 09, 2002 12:10 PM
> Subject: RE: [PHP] writing to mysql using php
>
>
> > If there were no more replies... you can use it by means of BUCLES, isn't
> > it?
> >
> > BR, Enrique
> >
> > -Mensaje original-
> > De: Shams [mailto:[EMAIL PROTECTED]]
> > Enviado el: Martes, 03 de Diciembre de 2002 04:32 a.m.
> > Para: [EMAIL PROTECTED]
> > Asunto: [PHP] writing to mysql using php
> >
> >
> > Hi,
> >
> > I'm relatively new to PHP and mySQL.
> >
> > I currently have a simple table created within a MySQL database.  And I
> have
> > a php script that connects to the database, presents a form for the user
> to
> > fill in, and then writes that record to the table.
> >
> > Instead... is it possible, to write to multiple records at once using a
> > tabular view rather than one record at a time with a columnar view ?
> >
> > Many Thanks,
> >
> > Shams
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>



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




Re: [PHP] Linux and Graphics

2002-12-09 Thread Scott Hurring
With RedHat, AFAIR you have to compile PHP from source
*after* first configuring the GD libraries.

It's always been a massive PITA when i've had to compile PHP
on Redhat with Graphic ext's -- try debian instead ;-)

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Ray Hunter" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> What functions do you want to use?
>
> You can review the functions in the manual and it will tell you how to
> configure php with them...
>
> On Mon, 2002-12-09 at 13:31, Todd Cary wrote:
> > I am running PHP in a RedHat 7.3 environment and I notice that the
> > graphic functions are not present.  Since I am quite new to Linux, I
> > would appreciate it if someone could explain to me what I need to do
> > to have graphic functions.
> >
> > Many thanks.
> >
> > Todd
> > --
> > Ariste Software, Petaluma, CA 94952
> --
>
> Ray Hunter
> email: [EMAIL PROTECTED]
> www: http://venticon.com
>



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




[PHP] Re: Generating forms using OOP

2002-12-09 Thread Scott Hurring
Here's an OOP function from an HTML class i wrote to simplify forms
myself -- It might come in handy for ya later :-)

// Single Select dropdown box
/*
  @params
   $name  String Name of this form element
   $items  Array Array of items to place in this select box
 $selected String Single item to select

Example params are:

  $name = "form[xyz]";
  $items = array(
"one" => "First element",
  "two"   => "Second element",
  "three" => "Third thingy");
  $selected = "two";

Output HTML will be:
  
 First element
 Second element
 Third thingy
  

*/
function select($name, $items, $selected='', $misc='')
{
 $text = "";
 $end  = " \n";
 // What to indent multi-line items with
 $indent = "";

 if (!is_array($items) || !count($items))
  return ($text . $end);

 while (list($k,$v) = each($items))
 {
  // If there's a linebreak in the value, split the lines into separate
  // OPTION lines, and indent the add'l lines
  $v = preg_replace("/\n/", "\n{$indent}", $v);
  $words = split("\n", $v);

  $already_selected = 0;
  foreach ($words as $word)
  {
   $text .= "\t wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi People,
>
> I ve just started with some OOP programming in PHP and now i have to
> build a set of classes that can generate a html form.. But i have a
> problem with the  thing
> I hope someone can help me here or give me some pointers,... any help is
> apreciated. Here is a part of my code :
>
> class selectField extends formElement {
>
> //Constructor
> function selectField($name, $value) {
> formElement::setName($name);
> formElement::setValue($value);
> }
>
> function generateSelectField() {
> $theOutput = "name."\">\n";
> foreach($this->value as $key=>$val) {
> $theOutput .= " value=\"".$this->value."\">".$this->value."\n";
> }
> $theOutput .= "\n";
> Return $theOutput;
> }
> }
>
> This is how i call the Object:
>
> $test[] = "Test1";
> $test[] = "Test2";
> $test[] = "Test3";
> $test[] = "Test4";
> $test[] = "Test5";
> $select = new selectField("testje", $test);
> echo$select->generateSelectField();
>
> But all i get is a select box with the word Array in it 5 times...Thanks
> for your time...
>
> Best regards,
>
> Davy Obdam
> mailto:[EMAIL PROTECTED]
>
>



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




[PHP] Re: Auto Increment Problems....

2002-07-30 Thread Scott Hurring

If you have an auto_increment mysql field, it's supposed to save you
the time of computing the "next" ID.  the database will handle it for you.

Use "0" as the ID for new rows and mysql will automagically compute
the next ID.

All of this info is on the mysql.com/doc/ site... please check there
in the future for MySQL questions

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Georgie Casey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> rite,
>
> my primary key column ("id") is set to auto_increment as usual which is very
> handy. But when I delete a row, the auto_increment just keeps incrementing
> and there's this 'hole' left where I deleted the row!
>
> Apart from this looking ugly, it poses another problem. In my PHP script
> where I can add new rows, I query the table, checking how many rows in the
> table altogether and set the new id as the next number, but this doesnt work
> if theres 'holes' in the id field, as the new record tries to overwrite
> another id.
>
> So I've 2 questions
> 1) Can the next auto_increment value be 'set' by a SQL query
> 2) Can I get a SQL query to INSERT INTO the first 'hole' it finds in the ID
> column??
>
> TIA
>
>



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




[PHP] Re: IIS Bugs???

2002-07-12 Thread Scott Hurring

There's a problem with IIS and the rest of the world :-)

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Brian McGarvie" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
OK This is a followon from my Browser thread... on [EMAIL PROTECTED];
[EMAIL PROTECTED]

I have switched the application to run from Apache, and the Browsers that were
having trouble now seem (I think - will be doing more testing later) to have
dissapeared.

So, is there a problem with IIS or PHP or IIS with PHP?

[ http://www.the-local-guide.com :: http://www.mcgarvie.net ]



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




Re: [PHP] ' giving problem while inserting in table.

2002-07-12 Thread Scott Hurring

or, more appropriately, use the database-specific escape function...

for mysql:
http://www.php.net/manual/en/function.mysql-escape-string.php
http://www.php.net/manual/en/function.mysql-real-escape-string.php

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Martin Clifford" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Use addslashes() on ALL strings before inserting them into your database.  Then,
on your frontend, extract the data and use stripslashes() on all strings.

Hope to help!

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/


>>> "Anil Garg" <[EMAIL PROTECTED]> 07/12/02 10:45AM >>>
Hi,
I am making a faq maintenance system using mysql and php.
To insert a entry in to a faq table i am using the following query:
-
INSERT INTO faq_table_netvd (id,question,
answer,netvcr,netdetector,add_date,mod_date,keyword,category,display,attach_
id)
 VALUES ('0','$frm[question]',
'$frm[answer]','$frm[netvcr]','$frm[netdetector]','$frm[add_date]','$frm[mod
_date]','$frm[keyword]','$frm[category]','$frm[display]','$frm[attach_id]')
 ");
---
now the problem is when $frm[question] has some string like: "why i can't
eat".
i get the following error:
MySQL Error: You have an error in your SQL syntax near 't eat?' ,answer =
'Please recheck the power of your specs:)' ' at line 3.Putting a '\' before
' (e.g. \')solves my problem...but when i open the same quesion to edit it,
again i have to put backslashes where ever i find " ' "  in the quesion or
answer.

Can anyone please suggest a solution to this.

thanx and regards

anil

[please ask if i havent explained the problem fully]



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





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




Re: [PHP] Final Year Computer Science Project involving PHP

2002-07-12 Thread Scott Hurring

... and  you could provide hooks so that the billing/sales/inventory
systems could all be separate "modules" of some sort,
and you could add/swap out modules as they're needed...
and perhaps have them communicate thru XML/SOAP, so
that they could be on different hosts altogether.  :-)

There's a million things you could do, that's the beauty
and curse of knowing how to program... too many projects
and ideas, not enough time.

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
002f01c229ba$a796a9c0$8102a8c0@niigziuo4ohhdt">news:002f01c229ba$a796a9c0$8102a8c0@niigziuo4ohhdt...
> [snip]
> Computer Science student (yes, that's me...) by giving him some ideas on his
> final year project very possible involving PHP and SQL...
> [/snip]
>
> How about a billing system? Accepts orders, processes invoicing, tracks
> customer trends and habits, has a method for tracking "aged" bills (over 30,
> over 60, over 90, etc.), a method for collections, etc. Billing systems can
> be quite complex and require extensive planning, they must tie in with
> inventory systems, sales systems, etc. You could do the whole integration.
>
> HTH!
>
> Jay
>
>



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




Re: [PHP] Re: PHP does not work??

2002-06-26 Thread Scott Hurring

There is no feasable way to "hide" data being submitted to your
website.  Anything that a user's browser can send, the user can
telnet to port 80 of your server and "spoof".

You can try POSTing data, which will not appear in the URL,
but dont even waste time trying to "hide" submitted data,
rather, build a stronger backend.

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Scott Fletcher" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi Erik!
>
> This is my 2nd posting, not sure what happened to my first one.  Sorry about
> not seeing your previous posting before.  Windows crashed on me.  My fault.
> I didn't know we can use php.ini in UNIX or Linux.  Cool!  Haven't been
> using it on UNIX for a long time.  I think I can leave it out for now and
> make some changes to the scripts instead.  When I saw the php.ini on
> Windows, I couldn't believe of so many configuration.  So, I think it will
> be helpful to make some changes to teh website and keep it simple for
> someone who will take my place as webmaster.
>
> Saw your comments about "_GET['data']".  I tried that and it worked.  I have
> one question, what about the hyperlink?  People will see the option in the
> hyperlink.  You know.  Is there a way around it to hid that in the
> hyperlink?  Just curious.
>
> Thanks,
>  Scott
>
> "Erik Price" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >
> > On Wednesday, June 26, 2002, at 02:13  PM, Scott Fletcher wrote:
> >
> > > I'm using UNIX, not windows, so there is no php.ini in UNIX.
> >
> > Sorry, don't take offense if I ask if you've been living under a rock --
> > I only use Linux, and there is definitely a php.ini file that you use.
> > I put mine in /usr/local/lib/ .  If you follow the source install
> > instructions, you will see that the last step is:
> >
> > $ cp php.ini-dist /usr/local/lib/php.ini
> >
> > Yep, that means you're supposed to copy php.ini-dist to a dir on your
> > server.  This is your configuration file, where register_globals and a
> > million other configuration directives are decided...
> >
> >
> > ?
> >
> >
> >
> > Erik
> >
> >
> >
> >
> > 
> >
> > Erik Price
> > Web Developer Temp
> > Media Lab, H.H. Brown
> > [EMAIL PROTECTED]
> >
>
>



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




[PHP] Re: form post

2002-06-12 Thread Scott Hurring

There's no way to for PHP to say "Yo, let's ride... submit that form"
Client-side manipulations must be done client-side, with
javascript or something similar.


--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Kris Vose" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Is there a way to post input types that are "hidden"  with out using a html form
in php?  I know you can do it in java script with Form.submit().

So... if I have three hidden fields can I "post" them without pressing a button
that uses a form by using a php function?

Thanks in advance.

Kris



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




[PHP] Re: is preg_replace the fastest way?

2002-06-11 Thread Scott Hurring

I think this is similar to what you're asking for, but it's
probably slower (you have to split(), traverse, then join())

foreach ($noiselist as $noise)
foreach ($inputlist as $input)
if ($noise == $input) // do something

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Zac Hillier" <[EMAIL PROTECTED]> wrote in message
007f01c2118a$f7a0ba20$667ba8c0@ws">news:007f01c2118a$f7a0ba20$667ba8c0@ws...
> Hi All,
>
> I'm writing a search facility and am stripping noise words from a string
> (The string contains between 50 - 200 words). Presently I'm importing a text
> file of noise words (The noise words file contains almost 1000 words) then
> using :
>
>#-- remove noisewords
>$cntLmt = count($noise_words);
>for ($i=0; $i<$cntLmt; $i++) {
> $filterword = trim(strtolower($noise_words[$i]));
> $filtered = preg_replace("/(\b$filterword \b)/x"," ",$filtered);
>}
>
> to remove these noise words.
>
> However I'm wondering if it would be quicker to separate the $filtered
> string and then look for the words in a noise words string. If so how would
> I do this and remove the words?
>
> Thanks
>
> Zac
>



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




Re: [PHP] Re: Emulating a class destructor

2002-06-11 Thread Scott Hurring

In the 5 minutes i took to test it out, it seems that register_shutdown
doesn't seem to like object methods (?)
I did come up with a solution, but it't not really the best way to
do things put cRoute_Destructor() into the same file as the
class declarations, so that when you include() the class, you'll
get access to cRoute_Destructor, and to the user, it will appear
to all run smoothly.

// start of cRoute.inc
class cRoute{
function cRoute(){
register_shutdown_function('cRoute_Destructor',$this);
}

function cleanup(){
 print "Please call close()";
$this->close();
}

function close(){
//close open sockets, etc.
}
} // End of class

function cRoute_Destructor($x) {
 $x->cleanup();
}
// end of cRoute.inc


$test = new cRoute();
exit;

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Sqlcoders.Com Programming Dept" <[EMAIL PROTECTED]> wrote in message
00ce01c211dd$32079ec0$6520fea9@dw">news:00ce01c211dd$32079ec0$6520fea9@dw...
> > This is completely off the top of my head (i've never done this
> > before) -- but try single-quoting it to prevent interpolation
> >
> > register_shutdown_function('$this->cleanup()');
> >
>
> Hiya,
> thanks for the suggestion, but i get the same 'Unable to call ...' message.
> Any other ways you can think of?
> I tried the following:
> '$this->cleanup()'
> '$this->cleanup'
>
> I also tried the :: syntax but it woudlnt work, plus the actions to be
> performed rely on data contained within the instance.
>
> TIA,
> Dw.
>
>
> > --
> > Scott Hurring
> > Systems Programmer
> > EAC Corporation
> > scott (*) eac.com
> > --
> > "William_dw -- Sqlcoders" <[EMAIL PROTECTED]> wrote in message
> > 009401c211d9$a1863da0$6520fea9@dw">news:009401c211d9$a1863da0$6520fea9@dw...
> > > Hi there!,
> > > I'm trying to emulate a class destructor, according to the PHP
> documentation
> > > I can emulate this by using a call to register_shutdown_function(),
> > > containing the function to be called upon shutdown.
> > >
> > > While this apparently works outside a class, I want to use it inside a
> > > class, in other words I want to have something like this:
> > >
> > > class cRoute{
> > > function cRoute(){
> > > //register the shutdown function in case people who use this
> class
> > > dont call the appropiate close methods.
> > > register_shutdown_function("cleanup()");
> > > }
> > >
> > > function cleanup(){
> > > //cleanup.
> > > trigger_error("Please call close() before the page ends, to
> prevent
> > > problems close() has been called automatically for you.");
> > > $this->close();
> > > }
> > >
> > > function close(){
> > > //close open sockets, etc.
> > > }
> > > }
> > >
> > > I have tried:
> > > register_shutdown_function("cleanup()");
> > > register_shutdown_function("$this->cleanup()");
> > > register_shutdown_function($this->cleanup());
> > > register_shutdown_function("cDB::cleanup()");
> > >
> > > They all return something like: Warning: Unable to call ()() - function
> does
> > > not exist in Unknown on line 0
> > >
> > > If anyone has any ideas I'd appreciate the help.
> > > Thanks in advance!,
> > > Dw.
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>



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




Re: [PHP] Re: GOTO command. Doest it exist?

2002-06-11 Thread Scott Hurring

Well, IMO, the only languages that really need goto's are low-level
ones like assembly and C.

goto's are more trouble than they're worth when you get into
structured or OO programming.

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Carlos U. Cirello Filho" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> OK,
>
> Anyway goto's are bad and wrong things... And one shouldn't use it.  I am
> wrong in trying to solve such problem using it. But I was really amazed that
> PHP did not have goto
>
> Kind Regards,
>
>
> Carlos Cirello
>
>
> "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
> 000e01c21183$ab49e590$8102a8c0@niigziuo4ohhdt">news:000e01c21183$ab49e590$8102a8c0@niigziuo4ohhdt...
> > [snip]
> > Subject: Re: [PHP] GOTO command. Doest it exist?
> > [/snip]
> >
> > No, and you don't need it. The reason? Ask yourself, "what is the use of a
> > GOTO?". Usually GOTO indicates a function of some sort, which you could
> > easily replicate with a function() or switch() if you need to send your
> > application in a different direction depending upon a set of
> circumstances.
> >
> > HTH!
> >
> > Jay
> >
> >
>
>



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




[PHP] Re: Emulating a class destructor

2002-06-11 Thread Scott Hurring

This is completely off the top of my head (i've never done this
before) -- but try single-quoting it to prevent interpolation

register_shutdown_function('$this->cleanup()');

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"William_dw -- Sqlcoders" <[EMAIL PROTECTED]> wrote in message
009401c211d9$a1863da0$6520fea9@dw">news:009401c211d9$a1863da0$6520fea9@dw...
> Hi there!,
> I'm trying to emulate a class destructor, according to the PHP documentation
> I can emulate this by using a call to register_shutdown_function(),
> containing the function to be called upon shutdown.
>
> While this apparently works outside a class, I want to use it inside a
> class, in other words I want to have something like this:
>
> class cRoute{
> function cRoute(){
> //register the shutdown function in case people who use this class
> dont call the appropiate close methods.
> register_shutdown_function("cleanup()");
> }
>
> function cleanup(){
> //cleanup.
> trigger_error("Please call close() before the page ends, to prevent
> problems close() has been called automatically for you.");
> $this->close();
> }
>
> function close(){
> //close open sockets, etc.
> }
> }
>
> I have tried:
> register_shutdown_function("cleanup()");
> register_shutdown_function("$this->cleanup()");
> register_shutdown_function($this->cleanup());
> register_shutdown_function("cDB::cleanup()");
>
> They all return something like: Warning: Unable to call ()() - function does
> not exist in Unknown on line 0
>
> If anyone has any ideas I'd appreciate the help.
> Thanks in advance!,
> Dw.
>



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




Re: [PHP] cut text?

2002-06-11 Thread Scott Hurring

Try (this is untested)

if (length($string) > 30) {
  print substr($string, 0, 30) ."...";
}
else {
  print $string;
}

--OR-- (if you want to over-write $string)

$string = ((length($string) >= 30) ? substring($string, 0, 30) ."..." :
$string );

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Hawk" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Lets say I have a news text, and in a menu, I just want to print the first..
> lets say 30 letters, and maybe add a "..." after, and link it to the full
> text.
>
>
>



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




[PHP] Re: url string

2002-06-10 Thread Scott Hurring

Did you verify that the variables actually contain data?

They're probably empty, which is why they dont seem to
be passing correctly.

--
Scott Hurring
Systems Programmer
EAC Corporation
scott (*) eac.com
--
"Kris Vose" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
I am looking for a way to pass two variables in a url string to a php script.  I
originally was using java script to acomplish this because once the user is
redirected they can not press the back button to get back to the original page.
It looks like this:
?>
 window.location =
"somefile.php?user=<?username?>&pass=<?userpass?>"
 window.location =
'somefile.php?user=$username&pass=$userpass'";

Unfortunately both ways do not work.  In the first instance the script jumps to
the window location but does not pass php variables into the url string.  In the
second instances the java script does not even compile.

Is there a way to do this with php?...html?...javascript?

...I think that window.location does not except url string variables or
something.  Anyway if anyone can help it would be appreciated.  Thanks.


Kris



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




RE: [PHP] very simple eregi / loop question

2002-06-07 Thread Scott Hurring

well, either make sure $search contains the entire page
or, you have an array fo lines, loop thru it line by line

foreach ($lines as $line)
eregi( ... )

AFAIK, eregi will match *everything* and dump it all into
$matches (at least that's the behaviour that pregs follow,
i dont use eregs)

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Robert [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 07, 2002 4:46 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] very simple eregi / loop question
> 
> 
> How would you loop though a file ( or web page) and get all 
> of a certain
> thing. I'm trying to strip stuff out of tables, but I have 
> only managed to
> get the first of what I'm searching for. My expression is
> eregi("[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}", $search, 
> $content);
> which does the job, but how do I apply that to get all of 
> that from the
> page?
> 
> thanks
> 
> --
> 
> 
> 
> 
> 
> 
> 
> Robert Packer
> Programming and Design Associate
> 814-944-1108
> [EMAIL PROTECTED]
> -- NRC Online --
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Weird intermittent "No Database Selected" problem

2002-06-06 Thread Scott Hurring

I assume you're not checking the status returned by the
database function calls, becuase they'd probably give
you valueable information on *why* it's doing that.  :)

try checking the return val, and (if using mysql) print
out mysql_error() if you get a bad return val.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Jeff Field [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 4:58 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Weird intermittent "No Database Selected" problem
> 
> 
> I apologize...I just posted this to the database list but 
> then realized it
> may not be a database issue, so thought I'd better give it a 
> shot over here.
> 
> Help!
> 
> I've been having a weird problem today (and maybe it's been 
> there all along,
> just haven't noticed...it's only been live a few days).  I 
> have a web page
> that allows users to query my database by either subject or 
> alphabet (A-Z).
> Today (and I think I noticed it once before but didn't pay 
> much attention),
> if you do a query, the first time it comes back with the results.  The
> second time, clicking the same letter (or sometimes other 
> letters), for
> instance, it comes back with a "Database Not Selected" error. 
>  Or, every
> time in a row for a dozen times it comes back with a 
> "Database Not Selected"
> error.  Or, sometimes it comes back with the results just 
> fine for twenty
> times in a row. Or, ...
> 
> You get the idea.  It doesn't happen all the time, just 
> sometimes, and in no
> particular order.  Very strange because I'm not changing a dang thing.
> Anyway, I've already tried rebooting the server, no change.  
> And, I've tried
> accessing the web page from other machines, same problem.  
> Has anyone ever
> run into this?
> 
> I'm running Red Hat 7.2, Apache 1.3.23, MySQL 3.23.49a, and PHP 4.2.1.
> 
> Here's the code in the web page with only some name changes 
> (for security,
> ya know):
> 
>  function Query()
>   {
>   global $mydb, $recordset, $total_rows, $letter;
>   $letter = $_GET['letter'];
>   mysql_select_db($database_mydb, $mydb);
>   $query = sprintf("SELECT name
>   FROM tbl_mytable
>   WHERE name LIKE %s
>   ORDER BY name ASC",
>   SQLStr($letter . "%", "text"));
>   $recordset = mysql_query($query, $mydb) or 
> die(mysql_error());
>   $total_rows = mysql_num_rows($recordset);
>   }
> ?>
> 
> And then the code in my include where I keep all the db 
> connection stuff:
> 
>  $hostname_mydb = "localhost";
> $database_mydb = "mydb";
> $username_mydb = "user";
> $password_mydb = "";
> $mydb= mysql_pconnect($hostname_mydb, $username_mydb, 
> $password_mydb) or
> die(mysql_error());
> ?>
> 
> Any help is appreciated!!  Thanks!
> 
> Jeff
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




[PHP] RE: Possible bug? (was Re: [PHP] Arrays: Please help before I go insane?)

2002-06-06 Thread Scott Hurring

When i run your code, the result is 100% correct, even
though you're outputting the wrong text label to go along
with the value 
you say "branch[one][two]" = $branch[one]
and since $branch[one] *IS* an Array, the output is correct
(even though "branch[one][two]" is NOT an Array --
very very important difference)

Here's my output of the code below:

SET == SET
Passing to getParentNodes:
currentBranch[one][two] = Array




---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Chris Boget [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 4:43 PM
> To: Scott Hurring; Php-General (E-mail)
> Subject: Possible bug? (was Re: [PHP] Arrays: Please help before I go
> insane?)
> 
> 
> > In that case, split it up into two-steps, to only init the
> > array if you need to i'm not really sure how the rest of
> > your code is -- you could probably do this a nicer way,
> > but this will work:
> > if (!is_array($ary["this"]))
> > $ary["this"] = array();
> > $ary["this"]["that"] = 1;
> 
> This is all well and good.  But I'm already doing that last 
> one and it's 
> that last that is getting messed up.
> 
> Again, if you look at the page I gave the link for, you'll 
> see where it 
> says:
> 
> currentBranch[other][joe] = Array
> 
> (all good) but the next line it says:
> 
> Passing to getParentNodes: currentBranch[joe][monster] = SET
> 
> which it shouldn't.  Where it says "SET" it should say "Array".  This
> is what my code is doing:
> 
> --
> 
> $currentBranch["$nodeName"]["{$nodeInfo[parent]}"] = "SET";
> 
> echo "Passing to getParentNodes: 
> currentBranch[$nodeName][{$nodeInfo[parent]}] = " . 
> $currentBranch["$nodeName"] . "\n";
> 
> --
> 
> $nodeInfo[parent] is a valid value.  So $currentBranch["$nodeName"]
> should be an array after that.  However, by some miracle (or bug in 
> PHP), instead of printing out "Array", it's print out "SET".  
> And I have
> no idea why it's doing that in my code.  The above works fine 
> by itself,
> however in my function it doesn't *even though they are doing the same
> things with no other code between*.
> 
> Chris
> 
> 

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




RE: [PHP] OOP style question

2002-06-06 Thread Scott Hurring

It depends highly on what you're doing and how you're doing it :)

If somethign needs to be done *always*, just throw it into the
Object so that the user won't have to call it explicitly,
however if you want to provide fine-grained control over
how/when/why things are cleaned-up, you might want to
keep it "public" and let the user call it explicitly.


For example, if clean-up is automatic, and only once-per-session,
this might be somewhat along the lines of what i think you're
asking for:::

function dothis($form) 
{
  // . do whatever to POSTED variables

  $this->cleanup($form);
}

function cleanup($form)
{
  // Only run once per instance
  if ($this->cleanup_called)
return 1;
  $this->cleanup_called = 1;

  // ... do cleanup
}

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Erik Price [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 4:58 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] OOP style question
> 
> 
> I'm trying to solve my earlier-posted dilemma of a class attribute 
> (array) that is "remembering" elements that should have been 
> unset().  
> The good news is that, according to some testing I've been 
> doing (I have 
> separated the relevant code and am directly testing it), it 
> looks like 
> PHP is behaving as expected -- I really hope that it's just 
> an error on 
> my part, so that I can fix it.
> 
> But out of this exercise I have begun to wonder something.  
> If someone 
> who is better-schooled than I in object oriented programming 
> style could 
> respond I would be very grateful.
> 
> I have a method in my class that essentially unsets an array 
> element.  
> The frequency with which this method is called varies 
> depending on the 
> circumstances, so i can't "hard-code" the solution to this 
> problem.  But 
> after the method is done being called (however many times it need be 
> called), a second method needs to be called.  Think of this 
> second one 
> as a "clean up" method, that needs to be called anytime the 
> first method 
> is called, but ONLY ONCE per script instance, no matter how 
> many times 
> the first method was called.  This means that I can't just 
> call method 
> #2 every time I call method #1.
> 
> Now, originally I was doing all of this method calling from 
> the script 
> itself.  For each variable POSTed by the user, I call the 
> first method.  
> But now that I have a second "clean-up" method that needs to 
> be called, 
> how should I go about it?  Should I have one "master" method in the 
> class that is called from the script, and itself does all the work?  
> This keeps all of the work in the class, and out of the 
> calling script.
> 
> OR...
> 
> Should I keep the class free of code that only executes according to 
> POST variables from the user, and keep this kind of thing in 
> the calling 
> script.  That way, the object's class is more flexible, and 
> can be used 
> in more contexts.
> 
> Again, this is really a question of style -- I can get it to 
> work either 
> way.  I'm just wondering if a class should be written to 
> handle ALL CODE 
> related to its class, and keep most of the work in "private" methods 
> (not really enforced in PHP but whatever), or whether the 
> class should 
> be written so that it has a lot of public methods that can be called 
> from the script, which means that the class is more flexible 
> in the long 
> run?
> 
> A question of encapsulation vs modularity, it would seem.
> 
> Your thoughts are gratefully accepted.
> 
> 
> 
> Erik
> 
> 
> 
> 
> 
> 
> 
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Trying to list a directory content HELP PLEASE

2002-06-06 Thread Scott Hurring

Instead of chdir() try putting the path directly into 
readdir();  it'll make the code a tiny bit cleaner.

readdir("/home/casapu/paginas/images/carteleras");

** and check return values! **

$fd = readdir(...)
if (!$fd) die("Cannot readdir");

The code you have *should* work, but you'll never
know why it's not working if you don't check return
statuses

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Jason Wong [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 3:44 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Trying to list a directory content HELP PLEASE
> 
> 
> On Friday 07 June 2002 00:47, webmaster mbtradingco wrote:
> > I know my doubt is probable odd, but I would ask your help please.
> >
> > I need a user to be able to select an image from a directory, from a
> > drop down box. For this I need to list all the images 
> available on the
> > directory, hence, I have this code:
> >
> >
> >  >   chdir("/home/casapu/paginas/images/carteleras");
> >   $direc = opendir(".");
> >   while ($f = readdir($direc)); {
> >   print("".$f."");
> >}
> > ?>
> >.");
> >
> > but this is not working. I have reviewed the code against all the
> > manuals/books I have, and it says it should work but it 
> doesn't. Anyone
> > knows what I'm doing wrong?
> 
> how doesn't it work?
> 
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications 
> Development *
> 
> /*
> Fashions have done more harm than revolutions.
>   -- Victor Hugo
> */
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




[PHP] Some generic pointers for secure writing (was Re: Anyone?)

2002-06-06 Thread Scott Hurring

Well, off the top of my head, some good pointers are:

*NEVER* use any unchecked/unquoted vars in system()
or database calls.  ever.  i mean it :-)

never assume that you'll get correct data from a form.  
validate everything.

never be careless with user passwords or sesitive data.
never put them in GET strings, or store them in HIDDEN
fields on the form or in cookies.

and make sure you check the error status of every function
that bothers to return one.  time and time again, simple
errors that go unchecked can balloon into huge errors that
completely baffle you and drag the script into bug hell.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Jas [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 3:48 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Anyone?
> 
> 
> Ok, I think you have gotten my point... I simply want to make 
> sure that the
> code I am writting is "up to par" on security issues such as 
> you listed.
> Maybe there are some examples of what to do vs. what not to 
> do when writting
> code that would be near impossible to exploit.  I simply do 
> not need some
> script kiddie messing with the time and research I have put 
> into making this
> application.  Any resources would be appreciated!
> Jas
> 
> "Scott Hurring" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > No language is "secure" becuase there's no such thing.
> > even supposedly secure Java VM sandboxes have well-known
> > security exploits.
> >
> > PHP code is as secure as you write it.
> > Bad programmer = bad code
> >
> > Name any language or program and there are
> > well-documented ways to subvert it.  Buffer
> > overflows in "C", and flawed Double-byte char
> > support in "IIS", to name a few recent and
> > better-known exploits.
> >
> > ---
> > Scott Hurring
> > Systems Programmer
> > EAC Corporation
> > [EMAIL PROTECTED]
> > Voice: 201-462-2149
> > Fax: 201-288-1515
> >
> > > -Original Message-
> > > From: Adam Voigt [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, June 06, 2002 1:22 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [PHP] Re: Anyone?
> > >
> > >
> > > Yes, PHP is a secure programming language.
> > >
> > > On Thu, 2002-06-06 at 13:18, Jas wrote:
> > > > I cannot believe that no one with alot of PHP and MySQL
> > > experience has not
> > > > replied to this post yet.  Is PHP not a secure scripting
> > > language?  I would
> > > > really like a little insight into this question, anyone?
> > > >
> > > > "Jas" <[EMAIL PROTECTED]> wrote in message
> > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > > I posted this yesterday and did not get any response 
> at all?  Just
> > > > wondering
> > > > > if someone can give me some insight into some security
> > > measures for a
> > > > > content management application...
> > > > >
> > > > > Posted 06/05/2002
> > > > > Ok, I am not a security expert so I would like to know if
> > > my security
> > > > > measures I have implimented is adequate enough to keep
> > > people out.  Any
> > > > > pointers on this would be very helpful as I am trying to
> > > impliment a
> > > > secure
> > > > > way for people to update a website through the use of a
> > > content management
> > > > > application.  Example of code is as follows
> > > > >
> > > > > // Login form - index.php
> > > > >  action="auth_done.php">
> > > > >   
> > > > >maxlength="20">
> > > > > Select an image to identify yourself as an administrator.
> > > > >
> > > > >  image01
> > > > >  image02
> > > > >  image03
> > > > >  image04
> > > > >  image05
> > > > >
> > > > >   
> > > > >   
> > > > > 
> > > > >
> > > > > // Authentication checker - auth_done.php
> > > > >   #check fields for valid entries in 
> form
> > > > > if ((!$u_name) || (!$p_word) || (!$image)

RE: [PHP] Arrays: Please help before I go insane?

2002-06-06 Thread Scott Hurring

In that case, split it up into two-steps, to only init the
array if you need to i'm not really sure how the rest of
your code is -- you could probably do this a nicer way,
but this will work:

if (!is_array($ary["this"]))
$ary["this"] = array();

$ary["this"]["that"] = 1;

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Chris Boget [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 3:43 PM
> To: Scott Hurring
> Cc: PHP General
> Subject: Re: [PHP] Arrays: Please help before I go insane?
> 
> 
> > Try:  $ary["this"] = array("that" => 1);
> 
> That works great until "this" has 2 children.  The second child 
> overwrites the first. :(
> 
> Chris
> 
> 

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




RE: [PHP] Can I get back a deleted row from mysql?

2002-06-06 Thread Scott Hurring

Nope.

For future reference, perhaps create two identical tables,
one for actual live data and one for trash, and instead of
deleting anything, just move it all into the trash table.

then, you can purge the trash table every few days/months.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Jan Grafström [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 3:11 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Can I get back a deleted row from mysql?
> 
> 
> Hi,
> I wonder if you can get back or view the deleted data in a 
> delted row in
> mysql?
> 
> "DELETE FROM $table WHERE id=$id"
> 
> I used the above code to delete.
> Thanks for any help.
> --
> Regards,
> Jan Grafström
> Sweden
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] FW: NEED HELP (passing variable to new page)

2002-06-06 Thread Scott Hurring

... especially when the error is not even with PHP  :-)

Contrary to what some newbies seem to think, this list is
not a free consulting service... none of us are obligated
to help everyone with every problem.

We're all volunteers -- sometimes we just don't have
the time or knowledge to answer every question,
especially when the questions aren't related to PHP,
or are really vauge or common or just plain silly :-)

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 2:40 PM
> To: Igor Portnoy
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] FW: NEED HELP (passing variable to new page)
> 
> 
> Asking twice doesn't help, bud. It's just going to piss people off.
> 
> If someone has an answer they'll let  you know, otherwise 
> look for other
> resources.
> 
> ---John Holmes...
> 
> - Original Message -
> From: "Igor Portnoy" <[EMAIL PROTECTED]>
> To: "[EMAIL PROTECTED]" <'[EMAIL PROTECTED]'>
> Sent: Thursday, June 06, 2002 2:24 PM
> Subject: [PHP] FW: NEED HELP (passing variable to new page)
> 
> 
> So can anybody help me with my problem?
> 
> 
> 
> -Original Message-
> From: Igor Portnoy
> Sent: Thursday, June 06, 2002 9:36 AM
> To: '[EMAIL PROTECTED]'
> Subject: NEED HELP (passing variable to new page)
> 
> 
> 
> Hello,
> 
> 
> 
> I am having hard time passing the variable to the next page. 
> May be you
> can help me. Let me explain:
> 
> 
> 
> I am using mySQL database to store information about images (ID, name,
> author, description, etc).  I am pulling some of the information to
> create this (look at the example here:
> http://www.gibsonusa.com/test/page/index.php) Now, I want a new window
> appear when user clicks on the image. I have achieved it with the
> following script:
> 
> 
> 
> echo "";
> 
> echo" function pop1() {";
> 
> echo" window.open(\"info.php?prod_id=$result[0]\"); }";   \\ 
> $result[0]
> is variable that stores id of the image in database
> 
> echo "";
> 
> 
> 
> I am calling this function in the following manner: echo" onclick=\"pop1();\"";
> 
> 
> 
> You can see the result if you click on the image.  The new page opens
> up, BUT the id (product_id in this case) value is not passed 
> to the next
> page correctly.  If you click on the first or second image on 
> the first
> page it shows that the ID is the same for both of them.  
> However if you
> look at the source code you can see that the ids are assigned 
> correctly.
> The same thing happens if you click on any image that says "no image
> available" (I am using different script to generate those).  It seems
> that the script picks up and stores in the memory the value 
> of an ID of
> the last image generated with the script (I don't know if that make
> sense).
> 
> 
> 
> Oh, by the way the contents of info.php that I am calling in 
> the script
> above are as following:
> 
>  
> $myid = $_GET['prod_id'];
> 
> echo" Product ID: $myid";
> 
> ?>
> 
> 
> 
> What am I doing wrong?  Can you help?
> 
> 
> 
> Thank you.
> 
> Sorry for lengthy e-mail.
> 
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] [PLEASE HELP] Passing variable to new page.

2002-06-06 Thread Scott Hurring

Javascript, being silly, has silly string rules:

function pop1($id) {
  window.open("info.php?prod_id="+ $id);
}

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Chris Knipe [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 2:50 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] [PLEASE HELP] Passing variable to new page.
> 
> 
> > echo "";
> > echo" function pop1() {";
> > echo" window.open(\"info.php?prod_id=$result[0]\"); }"; \\ 
> $result[0] is
> > variable that stores id of the image in database
> > echo "";
> >
> > I am calling this function in the following manner: echo" > onclick=\"pop1();\"";
> ^
> 
> You're not passing a value to the variable.  Try using 
> something like: (i'm
> NO java guru, and this definately isn't the list for java)...
> 
> function pop1($id) {
>   window.open("info.php?prod_id=$id");
> }
> 
> and
> 
> 
> 
> Where 12345 is the product ID that you assigned to variable 
> prod_id, which
> will in return be displayed in the second PHP file.  You're problem's
> related to the java script, not assigning the value to the 
> variable.  This
> isn't a PHP issue.
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Re: Anyone?

2002-06-06 Thread Scott Hurring

No language is "secure" becuase there's no such thing.
even supposedly secure Java VM sandboxes have well-known
security exploits.

PHP code is as secure as you write it.
Bad programmer = bad code

Name any language or program and there are
well-documented ways to subvert it.  Buffer
overflows in "C", and flawed Double-byte char
support in "IIS", to name a few recent and 
better-known exploits.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Adam Voigt [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 1:22 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Anyone?
> 
> 
> Yes, PHP is a secure programming language.
> 
> On Thu, 2002-06-06 at 13:18, Jas wrote:
> > I cannot believe that no one with alot of PHP and MySQL 
> experience has not
> > replied to this post yet.  Is PHP not a secure scripting 
> language?  I would
> > really like a little insight into this question, anyone?
> > 
> > "Jas" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > I posted this yesterday and did not get any response at all?  Just
> > wondering
> > > if someone can give me some insight into some security 
> measures for a
> > > content management application...
> > >
> > > Posted 06/05/2002
> > > Ok, I am not a security expert so I would like to know if 
> my security
> > > measures I have implimented is adequate enough to keep 
> people out.  Any
> > > pointers on this would be very helpful as I am trying to 
> impliment a
> > secure
> > > way for people to update a website through the use of a 
> content management
> > > application.  Example of code is as follows
> > >
> > > // Login form - index.php
> > > 
> > >   
> > >   
> > > Select an image to identify yourself as an administrator.
> > >
> > >  image01
> > >  image02
> > >  image03
> > >  image04
> > >  image05
> > >
> > >   
> > >   
> > > 
> > >
> > > // Authentication checker - auth_done.php
> > >   #check fields for valid entries in form
> > > if ((!$u_name) || (!$p_word) || (!$image)){
> > >  header("Location: index.php");
> > >  exit;
> > > }
> > >   connects to database
> > > require '/path/to/database/connection/script/dbcon.php';
> > >   #selects database table containing users 
> that are allowed to
> > > use application
> > > $db_table = 'users';
> > > $sql = "SELECT * from $db_table WHERE un = \"$user\" AND pw =
> > > password(\"$pw\")";
> > > $result = @mysql_query($sql,$dbh) or die("Couldn't 
> execute query");
> > >   #loops through all records to find a 
> match
> > > $num = mysql_numrows($result);
> > >  if ($num !=0) {
> > >   #creates variables for sessions
> > >   $p_hash = "$p_word";
> > >   $to_hash = "$image";
> > >   #creates md5 hash of image user selected
> > >   $pstring = md5($to_hash);
> > >   #creates md5 hash of password user 
> entered
> > >   $image_sel = md5(uniqid(microtime($p_word),1));
> > >   #starts session for user
> > >session_start();
> > >   #registers variables created (md5 of 
> password, username, &
> > > image) in session
> > >session_register('user');
> > >session_register('$pstring');
> > >session_register('$image_sel');
> > >   #captures users ip address (logging stuff, 
> not listed in
> > this
> > > code for security reasons)
> > >   $ipaddy = $REMOTE_ADDR;
> > >   #echoes success message to authenticated 
> user
> > >   $msg_success = "You have been authorized to make 
> changes to the
> > > website! Your IP address has been recorded and sent to 
> the administrator:
> > > $ipaddy";
> > >   } else {
> > >   #this prints if user name and password 
> combination is not
> > > found in database
> > >   p

RE: [PHP] Arrays: Please help before I go insane?

2002-06-06 Thread Scott Hurring

Try:  $ary["this"] = array("that" => 1);



---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Chris Boget [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 1:48 PM
> To: PHP General
> Subject: Re: [PHP] Arrays: Please help before I go insane?
> 
> 
> > Now, what I'm trying to do is build a tree based on the 
> data in the DB.  
> > It's working relatively ok if I uncomment the code that is 
> on line 48 and 
> > comment out line 49.  However, what I really want to do is 
> build a fully 
> > associative array doing this and now** an array that has 
> string keys but 
> > then, those arrays having numeric keys (copy and run this code 
> > un/commenting the lines above and you'll see what I mean).
> 
> ** should be "not"
> 
> To elaborate, what I'm trying to do is build an array that 
> looks like this:
> 
> $array["this"]["that"] = "whatever";
> $array["this"]["other"] = "whatever";
> 
> and not one that looks like this:
> 
> $array["this"][0] = "that";
> $array["this"][1] = "other";
> 
> because I just want to be able to get the keys and not have to worry
> about when I should be using the value of the key or the value of the
> array element.
> 
> Again, the problem that I'm having (as demonstrated by the code) is
> that when I'm trying to set it up so that it's like the first 
> example above,
> 
> $array["this"]
> 
> isn't always evaluating as an array, though it always should.
> 
> Chris
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Re: PHP Apache Module AND command Line

2002-06-05 Thread Scott Hurring

Grab the PHP ZIP, unzip it, add it to your PATH.  done.  :-)

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: John Taylor-Johnston [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 5:13 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: PHP Apache Module AND command Line
> 
> 
> I can. I did it once in windows on a dos command line.
> I believe I used print ""; instead of echo "aaa";
> 
> 
> Steve Buehler wrote:
> 
> > Is there doc somewhere to would tell how to install PHP as 
> a command line
> > interpreter (like perl) without messing up the installation 
> of PHP that is
> > installed as a module in/for Apache?  Basically, I want to 
> have both on the
> > same server.  Or can this even be done?
> >
> > Thank You
> > Steve
> 
> --
> John Taylor-Johnston
> --
> ---
>   ' ' '   Collège de Sherbrooke:
>  ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
>- Université de Sherbrooke:
>   http://compcanlit.ca/
>   819-569-2064
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Re: Finding out how a variable was registered

2002-06-05 Thread Scott Hurring

If you want to stop most people, try posting an MD5() hash
of the field contents to the form, and then verifying it
upon form submittal.

For example:




However, if you get a smart user, he can simply change
the value and the MD5 hash to be the correct hash of
the new value and circumvent all your work. 

(But then again, if you get anyone that's smart and
committed, it's just a matter of time before he will
figure out *some* loophole to subvert your forms)

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: John Taylor-Johnston [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 5:24 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Finding out how a variable was registered
> 
> 
> If you change your header to pragma-nocache, he should not be able
> to see the source to know what elements he needs for a .
> Or you could also use a session to hide the variables?
> 
> Joe Pemberton wrote:
> 
> > Is there a function call to figure out how a variable was 
> registered?  I am writing a page that handles a form and I 
> need to know whether or not a variable was created using the 
> GET or POST method (I don't want the user to be able to to 
> 'foo.php?var=value' and mess with the results)
> > - - Joe
> >
> > [EMAIL PROTECTED]
> 
> --
> John Taylor-Johnston
> --
> ---
>   ' ' '   Collège de Sherbrooke:
>  ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
>- Université de Sherbrooke:
>   http://compcanlit.ca/
>   819-569-2064
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Finding out how a variable was registered

2002-06-05 Thread Scott Hurring

Yes, but you really must realize how utterly easy it is to 
POST bogus variables to a form  (Save the page as HTML, edit,
load in browser, submit -- bingo).If you're using the
assumption "these vars were POSTed, so they're safe", you're
begging for trouble.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 4:30 PM
> To: Joe Pemberton; php list
> Subject: Re: [PHP] Finding out how a variable was registered
> 
> 
> Use $HTTP_POST_VARS['var'] instead of $var and you will know 
> it comes from
> post. Or $HTTP_GET_VARS['var'] if you want it from GET (the URL).
> 
> Or use the superglobals like someone else mentioned if you 
> have the latest
> PHP version.
> 
> ---John Holmes...
> 
> - Original Message -
> From: "Joe Pemberton" <[EMAIL PROTECTED]>
> To: "php list" <[EMAIL PROTECTED]>
> Sent: Wednesday, June 05, 2002 2:45 PM
> Subject: [PHP] Finding out how a variable was registered
> 
> 
> Is there a function call to figure out how a variable was 
> registered?  I am
> writing a page that handles a form and I need to know whether or not a
> variable was created using the GET or POST method (I don't 
> want the user to
> be able to to 'foo.php?var=value' and mess with the results)
> - - Joe
> 
> [EMAIL PROTECTED]
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Need some suggestions about "community" :)

2002-06-05 Thread Scott Hurring

Oh my.  There are many ways go about creating a community,
but a database for Each User?  That's pure insanity.

Try making perhaps a table for each user, or maybe 
(depending on what kind and how much user data
you're keeping) use one single table for all users.

Read up on Database Normalization for some good
design pointers:
http://home.earthlink.net/~billkent/Doc/simple5.htm

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Hawk [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 6:04 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Need some suggestions about "community" :)
> 
> 
> Just for fun I, and a few friends were going to make a 
> community, started
> about an hour ago :)
> Haven't started with the design or anything yet, but I was 
> thinking how the
> best way to handle users would be, or atleast what you can 
> recommend, first
> I thought about having a database with users, and one with 
> messages and
> stuff, and then I thought it might be smoother to create a 
> database for each
> user, and store all his/her things in it, what do you think?
> If there is any other good way, I'm also open for suggestions :)
> 
> HÃ¥kan
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] php and javascript question

2002-06-05 Thread Scott Hurring

As someone else suggested a few days ago: try using an IFRAME,
and refreshing it from javascript with the values you need.

The whole browser will not refresh, just the IFRAME, which
will give the illusion of jscript and php talking to each
other in realtime.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Martin Clifford [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 4:24 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] php and javascript question
> 
> 
> As far as I'm aware you can't create a javascript variable 
> and use it within PHP on the same page.  You can add that 
> variable's value to a hidden form element to be passed to the 
> next page, but I don't think so with the same page.
> 
> martin
> 
> >>> "kemu" <[EMAIL PROTECTED]> 06/05/02 02:30PM >>>
> I have a page first he generates a var in javascript
> my next question is
> is it possible to use that var in php on the same page
> first he does the javascript then the php ?
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] htaccess

2002-06-05 Thread Scott Hurring

Try creating an .htaccess protected script, and do a 
var_dump($GLOBALS) to see what vars are set, and if
any of them contain the name you logged in with.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Steve Buehler [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 5:39 PM
> To: PHP
> Subject: [PHP] htaccess
> 
> 
> I have a php script in an .htaccess protected directory.  Is 
> there a way 
> that PHP could find out what login was used?
> 
> Steve
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Is this possible

2002-06-05 Thread Scott Hurring

Since you didnt include the code for InsideClass, i can only
assume that you're probably getting errors becuase "$bob"
is not initialized anywhere.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: James Edgar [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 5:27 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Is this possible
> 
> 
> I am trying to run a class inside a class, it says that the 
> object is there but when I go to get the info, it is not 
> there. I have attached the code below. Any help would be 
> greatly appreciated.
> 
> class myfirstClass
>   {
> 
>   
>   function Track($tracknum)
>   {
>   include("insideclass.inc");
>   
>   $obj = new InsideClass($data,"bob");  
>   
>   if (is_object($obj)) 
>   {
>   print("Yes"); // It will print this
>   }
>   else
>   {
>   print("No");
>   }
>   
>   / below we will see the status of the 
> result   
>   for($i=0;$i   { 
>   $nine = 
> $bob["Whatever_whaterver"][$i]->Whatever[0] . "\n"; 
>   }
> 
>   echo($nine); // Does not echo anything.
> 
>   } // end func
> 
>   } // end class
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] OOP Question in PHP

2002-06-05 Thread Scott Hurring

Depends ;-)

I'd say that the second way is probably "best", becuase
it avoids implied behaviour, which sometimes can cause
problems (lets say you want to init. a document object,
but not get anything from the DB).  If you want to create
a brand new Document, obviously it won't be in the DB
already, so you might not want to have the constructor
go and try to fetch it.

instead (with option #2), you could do something like:

// Create new document
$d = new Document();
// populate document
$d->save();

and

// Get existing doc
$d = new Document();
$d->get(ID);

But that's just my view... there are as many different
views on OO as there are programmers :)

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Henry Blackman [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 5:33 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] OOP Question in PHP
> 
> 
> Hello.
> 
> I have, what is probably a silly, question.
> 
> I want to convert my existing scripts to OO - because it's 
> the "way to go"
> in terms of the huge amount of functionality that they now 
> have (and since
> I've never done it before it would be interesting).  However 
> I have one
> thing that I don't understand.
> 
> My scripts manipulate documents and these documents are 
> stored in a MySQL
> database.
> 
> To create a new object is really easy.  However, since I have lots of
> documents already, how do I alter one?
> 
> Do I create a new document and pass the primary key as it's a 
> variable in
> the
> 
> $document = new Document(number);
> 
> and have the constructor retrieve the appropriate data from 
> MySQL and fill
> the attribute variables.
> 
> Or do I do something like:
> 
> $document = new Document;
> $document ->retrieve(number);
> 
> Which is the best and most "valid" way of doing things.
> 
> Cheers,
> Henry
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Passing variable to new page and pulling the rest of info from database

2002-06-05 Thread Scott Hurring

Sorry, i meant: mysql_escape_string( $value )

I use a class to handle accessing the database, and i
named the function $db->quote(...);  i keep forgetting
that the actual function call that the class is making ;-)

And yes, validating that it's an integer works also,
but even after pregging vars to all hell and back to
verify contents, i still quote.  i'm paranoid. :)

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 5:10 PM
> To: Scott Hurring; Php-General (E-mail)
> Subject: Re: [PHP] Passing variable to new page and pulling 
> the rest of
> info from database
> 
> 
> Or simply just validate it's an integer, like it should be, 
> like you would
> do with any user input...
> 
> There is no mysql_quote() function...or am I missing something?
> 
> ---John Holmes...
> 
> - Original Message -
> From: "Scott Hurring" <[EMAIL PROTECTED]>
> To: "Php-General (E-mail)" <[EMAIL PROTECTED]>
> Sent: Wednesday, June 05, 2002 4:30 PM
> Subject: RE: [PHP] Passing variable to new page and pulling 
> the rest of info
> from database
> 
> 
> > Ahhh! quote that ID number before using it in a query!  :)
> >
> > // for mysql
> > mysql_quote($_GET['ID']);
> >
> > ---
> > Scott Hurring
> > Systems Programmer
> > EAC Corporation
> > [EMAIL PROTECTED]
> > Voice: 201-462-2149
> > Fax: 201-288-1515
> >
> > > -Original Message-
> > > From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, June 05, 2002 4:29 PM
> > > To: Igor Portnoy; [EMAIL PROTECTED]
> > > Subject: Re: [PHP] Passing variable to new page and pulling
> > > the rest of
> > > info from database
> > >
> > >
> > > SELECT * FROM table WHERE ID = $_GET['ID']
> > >
> > > Then create a page to display all of that information. Look
> > > at the mysql
> > > functions and learn some PHP. We can't help you without
> > > knowing what's in
> > > your table and how you want it displayed, etc...
> > >
> > > So keep learning and reading and you'll figure out how to 
> do it. Your
> > > question is way to broad for any help...
> > >
> > > ---John Holmes...
> > >
> > > - Original Message -
> > > From: "Igor Portnoy" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Wednesday, June 05, 2002 2:40 PM
> > > Subject: [PHP] Passing variable to new page and pulling the
> > > rest of info
> > > from database
> > >
> > >
> > > Hello,
> > >
> > >
> > >
> > > I am passing a variable to the new page, when user clicks 
> on the link.
> > > Something like that:
> > >
> > > 
> > >
> > >
> > >
> > > How can I extract all other information out of my 
> database for that ID
> > > in the next page (showimage.php)?
> > >
> > >
> > >
> > > Thanks
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 

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




RE: [PHP] Retrieving data from a URL in PHP

2002-06-05 Thread Scott Hurring

To illustrate what's wrong with the code from the book,
the following code works... notice what's different.

But really, you should've just loaded the URL and noticed
there's no "$[0-9].[0-9]" and instead it was bold.
problem solved.


$symbol="ibm";
echo "Stock Quote for $symbol\n";
$theurl="http://finance.yahoo.com/q?s={$symbol}&d=v1";;
if (!($fp=fopen($theurl, "r")))
 {
  echo "Could not open the URL";
  exit;
 }
$contents= fread($fp, 100);
fclose($fp);

if (preg_match("/([0-9]+\.[0-9]+<\/b>)/",$contents, $quote))
 {
  echo "$symbol was sold at:  ";
  echo $quote[1];
 }
else
 {
  echo "No quote available.";
 }

echo ""."This information retrieved from"."$theurl"."on ".(date("l jS F Y g:i a T"));


---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Anthony Ritter [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 4:53 PM
> Subject: [PHP] Retrieving data from a URL in PHP
> 
> The code that follows is from Welling and Thomson's book on 
> PHP and mysql
> (page 372)
> 
> I've tried it on Apache/ MS Windows 98 / PHP and I get the 
> following line:
> 
> "No quote available."
> 
> My questions...
> 
> 1. Why can't I retrieve the present stock quote?
> 
> and
> 
> 2. What does the variable
> 
> $quote
> 
> represent in the script?
> 
> I cannot find what the variable -or array - $quote has been 
> assigned to.
> Please see:
> 
> echo $quote[1];
> 
> below
> 
> Thanking all in advance.
> Tony Ritter
> ..
> 
> 
> 
> 
> Stock Quote from NYSE
> 
> 
>  $symbol="IBM";
> echo "Stock Quote for $symbol";
> $theurl="http://finance.yahoo.com/q?s=ibm&d=v1";;
> if (!($fp=fopen($theurl, "r")))
>  {
>   echo "Could not open the URL";
>   exit;
>  }
> $contents= fread($fp, 100);
> fclose($fp);
> $pattern="(\\\$[0-9]+\\.[0-9]+)";
> if (eregi($pattern,$contents,$quote))
>  {
>   echo "$symbol was sold at:  ";
>   echo $quote[1];
>  }
> else
>  {
>   echo "No quote available.";
>  }
> echo ""."This information retrieved from"." href=\"$theurl\">$theurl"."on ".(date("l jS F Y g:i a T"));
> ?>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Passing variable to new page and pulling the rest of info from database

2002-06-05 Thread Scott Hurring

Ahhh! quote that ID number before using it in a query!  :)

// for mysql
mysql_quote($_GET['ID']);

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 4:29 PM
> To: Igor Portnoy; [EMAIL PROTECTED]
> Subject: Re: [PHP] Passing variable to new page and pulling 
> the rest of
> info from database
> 
> 
> SELECT * FROM table WHERE ID = $_GET['ID']
> 
> Then create a page to display all of that information. Look 
> at the mysql
> functions and learn some PHP. We can't help you without 
> knowing what's in
> your table and how you want it displayed, etc...
> 
> So keep learning and reading and you'll figure out how to do it. Your
> question is way to broad for any help...
> 
> ---John Holmes...
> 
> - Original Message -
> From: "Igor Portnoy" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, June 05, 2002 2:40 PM
> Subject: [PHP] Passing variable to new page and pulling the 
> rest of info
> from database
> 
> 
> Hello,
> 
> 
> 
> I am passing a variable to the new page, when user clicks on the link.
> Something like that:
> 
> 
> 
> 
> 
> How can I extract all other information out of my database for that ID
> in the next page (showimage.php)?
> 
> 
> 
> Thanks
> 
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] setup php apache

2002-06-05 Thread Scott Hurring

Were the php.net install instructions not sufficient?  

AFAIK, you only need to install mysql/apache/php as you
normally would, (./configure ; make ; make install)
then edit the httpd.conf and tell apache to parse .PHP
files using the PHP binary.

(At least that's the way you'd do it using CGI version
of PHP, using PHP as a module is a bit more involved,
but still very simple)

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Mac Ne [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 3:17 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] setup php apache
> 
> 
> Hi
> 
> I need help to setup php , apache and my sql on
> Freebsd 4.5...I am moving from windows 2000 to
> Freedbsd 4.5..I know basic stuff on Freebsd..can some
> please send me a step by step to install,setup and
> configure it
> 
> Thx
> 
> 
> 
> __
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] auto_increment

2002-05-28 Thread Scott Hurring

Look at Sequences for Postgres.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: webmaster [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 7:12 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] auto_increment
> 
> 
> I think this is any easy question, but I couldn't find an 
> answer in the
> php Black Book for PostgreSQL.  Does anyone know the equivilant of
> auto_increment for PostgreSQL?  This is the php code that I have:
> 
> $query = "CREATE table $tablename (id INT NOT NULL PRIMARY 
> KEY, ip TEXT,
> customer TEXT, dslphone TEXT, date TEXT, vpivci TEXT)";
> 
> This creates the table, but when I need to add data to the Database, I
> have to specify a unique id each time.  I need want the id to
> automatically increment each time data is added the the DataBase.  Is
> there a way to do this by adding an auto_increment option to the id
> field when the table is first created?
> 
> Thanks for any Help,
> -Elkan
> 
> PHP version: 4.0.6
> OS: RH 7.2
> PostgreSQL: v.7.1
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Regex Assistance

2002-05-28 Thread Scott Hurring

This should work for most cases:

function strip_key($key, $string)
{
  $string = preg_replace("/(&|\?)($key=(\w+)?)(&?)/", '$1', $string);
  return preg_replace('/(\?|&)$/', '', $string);
}

print strip_key("list", "yadda?bo=ra&list=XXX&two=three");
print strip_key("list", "yadda?bo=ra&list=&two=three");
print strip_key("list", "yadda?list=XXX");
print strip_key("list", "yadda?list=XXX&two=three");
print strip_key("list", "yadda?no=where&list=XXX");

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Scott Reismanis [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 27, 2002 10:00 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Regex Assistance
> 
> 
> Hey All,
> 
> I am just begining to learn regex functions in PHP. Anyhow I 
> am trying 
> to code a preg_replace function which basically cleans a URL.
> 
> What I mean is say a url is index.php?page=hello&list=10&start=4 you 
> pass that URL and say 'list' to the function (shown below) Anyhow I 
> want that to then return index.php?page=hello&start=4 (see how the 
> entire list reference is now gone)
> 
> Here is what I have come up with so far, though I am yet to 
> test it as 
> I am coding this at work :)
> 
> function stripUrl($url, $url_strip)
> {
> // Check that $url_strip is in the URL
>   if(strpos($url,'?') && strpos($url, $url_strip.'='))
>   {
> // Lets clean up the url
>   $url = preg_replace("/\?|&$url_strip=/", "", $url);
>   }
>   return $url;
> }
> 
> My problem is that, how do I make the preg_replace stop when it 
> encounters a & in the URL? If anyone could shed some light on this it 
> would be appreciated,
> 
>  - Regards, Scott
>  
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Re: Thread safe

2002-05-28 Thread Scott Hurring

I'm not sure if it's atomic, but (AFAIK) you can
do something like this with Mysql:

UPDATE table SET field=field+1 where ..... 

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: J Smith [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 27, 2002 12:49 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Thread safe
> 
> 
> 
> You could use a transaction block if your database supports 
> it, or just use 
> some sort of auto-numbering field, such as SERIAL in Postgres, 
> auto_increment in MySQL, etc. Then you wouldn't have to worry about 
> retrieving the next cno before inserting a new row.
> 
> J
> 
> 
> R wrote:
> 
> > Hi,
> > In java servlets I used to use  a "synchronised" block of 
> code to make 
> sure
> > it was thread safe...how do i do this in PHP?
> > 
> > Heres what should be thread safe
> > 
> > {
> > $r=select max(cno)+1 from MyTable;
> > (then i insert into the table the new cno plus my name)
> > insert into mytable ($r,'myname');
> > }
> > How to do this and make sure its thread safe?
> > 
> > Any help appreciated,
> > -Ryan
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] How can I remove the last character from a one line file?

2002-05-28 Thread Scott Hurring

TIMTOWTDI

$string = "Jacko";
print preg_replace('/.$/', '', $string);

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Ed Gorski [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 9:41 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] How can I remove the last character from a one line
> file? 
> 
> 
> Try:
> 
> $string="Jacko";
> $string=substr($string,0,(strlen($string)-1));
> echo $string;
> 
> ed
> 
> At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote:
> >Hi all,
> >
> > How can I remove the last character from a one line file?
> > i.e. I need to change Jacko to Jack
> >
> >
> >I would really appreciate a response on this!
> >
> >Thank you!
> >Dave
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> Edmund Gorski
> Programmer / Analyst
> WWW Coordinator Dept. @ District Office
> 727-341-3181
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Efficient PHP

2002-05-28 Thread Scott Hurring

> -Original Message-
> From: Ed Gorski [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 9:46 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Efficient PHP
> 
> 
> Anyone know any good links on papers/articles/reports on 
> creating efficient 
> PHP scripts (ie functions to stay away from, good practices, 
> etc).  As a C 
> programmer, I am a nut on efficiency and speed and I have 
> been trying to 
> read up on efficient PHP coding practices (besides obvious 
> general coding 
> practices).  So can anyone offer any links or experiences?
> 
> ed 

Depends what kind of efficiency you are looking for, and
the type of application you're writing.

Personally, i've always taken the view that my time is
worth a lot more than the CPU's time (unless i'm writing
a speed-critical app, which is not very often :), so i
code for human efficiency and ease of maintenence, even
if the code is a little bit slower than heavily optimized
code.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

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




RE: [PHP] voting using text files

2002-05-22 Thread Scott Hurring

file_append($file, $text);  ??

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Vail, Warren [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 22, 2002 3:46 PM
> To: 'Rasmus Lerdorf'; 1LT John W. Holmes
> Cc: Jason Soza; PHP-General
> Subject: RE: [PHP] voting using text files
> 
> 
> I see some real genious in this solution.  This would be a 
> great function
> addition to PHP, anybody?
> 
> Warren Vail
> Tools, Metrics & Quality Processes
> (415) 667-7814
> Pager (877) 774-9891
> 215 Fremont 02-658
> 
> 
> -Original Message-
> From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 22, 2002 11:19 AM
> To: 1LT John W. Holmes
> Cc: Jason Soza; PHP-General
> Subject: Re: [PHP] voting using text files
> 
> 
> I think you guys are making this way more complicated than it 
> needs to be.
> Anytime you start talking about locking files, you need to 
> apply a huge
> reality check to yourself and sit down and approach the problem from a
> different direction.
> 
> In this case could I suggest that you make use of the fact 
> that appends of
> less than a blocksize are atomic.  Therefore, why not simply append a
> single character to a text file for each vote?  If you are 
> voting for a
> list of things, assigning a character to each item and simply 
> append 'a',
> 'b', 'c' or 'd' to your file.  The size of the file instantly 
> gives you
> the number of votes cast.  Reading the file and counting the number of
> times each letter occurs using something like substr_count() 
> will give you
> the number of votes for each option.
> 
> That gives you a lockless and flexible system without the 
> risk of deadlock
> or missing votes due to race conditions.
> 
> -Rasmus
> 
> On Wed, 22 May 2002, 1LT John W. Holmes wrote:
> 
> > > A good structure would be to have one file for each 
> possible answer and
> > each
> > > file contains the number of votes it has recieved.
> > > Then:
> > > --> Open file for the chosen option as read only
> > > --> Read the value in the file
> > > --> Close the file
> > > --> Increase the value by one using ++
> > > --> Open the file again in write mode
> > > --> Lock the file
> > > --> Write the new value to the file - old one overwritten
> > > --> Unlock the file
> > > --> Close the file
> >
> >
> > That's a bad method. You have to have the lock around the 
> read and the
> > write. With your method, 5 users might read the file, all 
> getting 99 for
> the
> > count, and then each one will try to seperatly write 100 to 
> the file. So
> you
> > lose 4 actual counts. You want to open the file, read it, 
> update value,
> > write it, unlock, and close the file.
> >
> > Using multiple files would just be a waste of space in my opinion. A
> locked
> > file doesn't stop the script, it simply waits for the file 
> to be unlocked
> > and then continues on.
> >
> > ---John Holmes...
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] voting using text files

2002-05-22 Thread Scott Hurring

Another consdieration with using files written to disk
automatically.  if there's any chance that the user could
get some arbitrary value written to disk, then access the
file thru the web-browser, it's a HUGE security risk.

aside from all the file-locking and mucking about with
permissions and maintaining the filesystem that Miguel
mentioned.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Jason Soza [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 22, 2002 3:26 PM
> To: Miguel Cruz
> Cc: PHP-General
> Subject: Re: [PHP] voting using text files
> 
> 
> And this is why I'm not an expert!
> 
> I have a counter script on my page now that uses a flatfile to store 
> IP's, but it also stores a timestamp. When someone visits the 
> page, the 
> current time is compared to the stored timestamp for that IP 
> + whatever 
> timeout period I set. If it's less, then that IP is not 
> counted again. 
> If it's more, than the previous entry is deleted and a new 
> one written 
> with a new timestamp. I have it set for 15 minutes just to 
> keep people 
> from sitting and hitting 'reload' to run up my counter.
> 
> Anyway, I figured the same type of thing could be used here, I just 
> didn't explain it. Seems that someone else came up with a simpler 
> solution anyhow!
> 
> Thanks for pointing out my idea's flaws... I'm a little biased, so I 
> don't always see them myself.
> 
> Jason Soza
> 
> - Original Message -
> From: Miguel Cruz <[EMAIL PROTECTED]>
> Date: Wednesday, May 22, 2002 9:45 am
> Subject: Re: [PHP] voting using text files
> 
> > On Wed, 22 May 2002, Jason Soza wrote:
> > > Using file locking, if two people tried to use the script at the 
> > same 
> > > time, wouldn't there be an error for one of them?
> > 
> > The second session would just have to wait for the first to finish 
> > (which 
> > should be an infinitessimal amount of time).
> > 
> > > My first guess at defeating this is having the script write a 
> > file named
> > > after the voter's IP. Have the file written to a different 
> > directory for
> > > whatever choices they have, then use readdir() to count the 
> > files in
> > > each directory, i.e. the number of votes for each choice.  Then 
> > if that
> > > same IP tries to vote again, check it against votes already 
> > received and
> > > approve/deny it.
> > 
> > Using IPs is a pretty lousy way of uniquely identifying users, 
> > especially 
> > for a purpose like this:
> > 
> > 1. If I dial in with a modem, I probably get a new IP each time I 
> > connect, 
> > so I can vote as often as I like.
> > 
> > 2. Many companies, ISPs, and even countries use proxy servers that
> > aggregate thousands or millions of users behind a handful of IP 
> > addresses.  
> > One vote from China, Saudi Arabia or New Zealand and that could be 
> > it for
> > the country. Likewise AOL.
> > 
> > Try cookies or something. Still can be defeated by the determined 
> > ballot-box stuffer, but so can everything else that doesn't 
> > require human 
> > verification of identity.
> > 
> > miguel
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] OOP with PHP

2002-05-21 Thread Scott Hurring

Try it out for yourself. :-

class Test{
var $x = '';
function Test(){}
}

$x = new Test();
$y = new Test();
$x->x = "Way";
$y->x = "No";
print $y->x . $x->x;


---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Erik Price [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 21, 2002 2:14 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] OOP with PHP
> 
> 
> Yesterday, I read in the archives somewhere that in PHP, class 
> attributes are all static attributes (class variables), not instance 
> variables.  (Figures, I can't find it again, so I can't provide a 
> link.)  In other words, the attributes apply to every single 
> instance of 
> an object.  This contradicts my limited experience with OOP 
> in PHP, but 
> I hoped someone could confirm this before I write up this giant class 
> I'm working on.
> 
> Thanks!
> 
> 
> Erik
> 
> 
> 
> 
> 
> 
> 
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] substr....what does this mean? (newbie)

2002-05-21 Thread Scott Hurring

-1 is the index of the char number you want to examine.
http://www.php.net/manual/en/function.substr.php

So that code is checking the last char of the string
to see if its ".", if it is, it returns everything *except*
the ".".

Please consult the online manual in the future... 
it wants to be your friend.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: r [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 22, 2002 2:51 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] substrwhat does this mean? (newbie)
> 
> 
> Hi ppl,
> Can you tell me what does this mean?
> 
> if (substr($text, -1) == ".")
> {$test = substr($text, 0, -1);}
> 
> I know the if part searches the $text from the starting for the "."
> I am just confused about what the second and third arguement 
> does in the
> substr. (Second line)
> 
> I know that this is an easy question for you PHP guys out there,
>  and I know i will get an answer,
>  so I thank you all in advance.
> 
> Cheers
> -Ryan A.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Secure eval();

2002-05-21 Thread Scott Hurring

> -Original Message-
> From: Chris Boget [mailto:[EMAIL PROTECTED]]
> Subject: Re: [PHP] Secure eval();
> 
> > Are you sure you have to run it through eval()? It sounds 
> like you're
> > creating a query. Couldn't you just create the query 
> dynamically, then put
> > it in a mysql_query() function? (or whatever DB you're 
> using) Then, even if
> > they try some kung fu on you, it'll just result in a bad 
> query, not some
> > rogue code being executed.
> 
> Try some kung fu?  Never heard it put like that before. :P
> 
> I am kind of creating a query.  The equation is going to look 
> something like
> this:
> 
> (({table1.field1} * {table2.field2}) + {table3.field3})
> 
> Then I'm going to get the values in those fields and parse 
> the above as if they
> were macros (which, in a sense, they are).  That could yield 
> something like:
> 
> ((8 * 5) + 3)
> 
> and it is that equation that I'm going to need to eval.  So I 
> don't think I'll be able
> to do this in a query.
> 
> Chris

Make sure you check if the tables are valid and present
in the database.  But like others have suggested, you
should *really* look for a better way to do this.

Putting text into a database and then blindly eval()'ing
it later on is just begging for trouble.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

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




RE: [PHP] Text file

2002-05-20 Thread Scott Hurring

... so open up the text file and read it.

What problem are you having?  Are permissions set
correctly?  Are you making sure to escape "\" on Win?

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Rodrigo [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 20, 2002 4:57 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Text file
> 
> 
> Hi guys:
>  
> What I need is a php file that will read a text file and show it on a
> html file.
>  
> And it will also write to a text file, but at the end of the file.
>  
> Thanx, Rodrigo de Oliveira Costa.
>  
> 

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




RE: [PHP] Any Ideas "@" becomes "_Xy"

2002-05-20 Thread Scott Hurring

> -Original Message-
> From: Analysis & Solutions [mailto:[EMAIL PROTECTED]]
> Subject: Re: [PHP] Any Ideas "@" becomes "_Xy"
> 
> On Sat, May 18, 2002 at 11:45:49AM +0100, Henry wrote:
> > 
> > 
> http://GetResponse.com/k.cgi?a=blahblah&f=henry_Xyteacake.force9.co.uk
> > I subscribed using the email address [EMAIL PROTECTED]
> > They appear to have translated the "@" symbol to "_Xy".
> > Any guess why? Is there a PHP function that does this 
> translation for me? Is
> > it some sort of standard?
> 
> That's something they did manually to their own standard.  
> The standard 
> encoding for @ is %40.  Why?  Beats me.  They don't really need to.  
> Encoding URL's can be done via urlencode() and urldecode().
> 
> If you want to do the same thing they're doing, you can use
> str_replace(): http://www.php.net/manual/en/function.str-replace.php
> 
> Enjoy,
> 
> --Dan

Perhaps they did it to thwart "smart" spambots that can
translate "%40" to "@".

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

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




RE: [PHP] Expiring certain session data while keeping the session itself

2002-05-20 Thread Scott Hurring

What about something like this: (un-tested, just off the top
of my head)  It'll set a cookie the first time a user gets
to the page, and will then only re-load data every 75+ seconds
(from the time the user first loads data) -- and only updates
the cookie when data is re-loaded


if (date("U") > ($cookie_load+75)) {
print "fetch from DB";
SetCookie("cookie_load", date("U"));
}
else {
print "Loaded ($cookie_load), now ". date("U") ." -- NOT
fetching\n";
}

if (!$cookie_load)
SetCookie("cookie_load", date("U"));

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Chris Knipe [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 20, 2002 3:15 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Expiring certain session data while keeping the session
> itself
> 
> 
> Hiya, me again :-)
> 
> Is it possible to expire certain session data, while still keeping the
> session itself in tact?
> 
> Example...
> 
> $_SESSION['AlwaysTrue'] = "True";
> $_SESSION['ExpireThis'] = "10:20:00";
> 
> At 10:19:50 the session is registered.  AlwaysTrue must 
> remain True for as
> long as the session itself is true (as specified in the 
> documentation - this
> would be until the browser is closed, or after a certain 
> amount of inactive
> time).
> 
> However, at 10:20:00 (10 seconds later), I want the 
> ExpireThis value of the
> session, to be destroyed, without having to de-register the 
> entire session
> (this would then also destroy the AlwaysTrue value...
> 
> Am I right in presuming this cannot be done, and I'll have to 
> come up with
> my own little function to do this with?  If so, how can I see 
> at what time a
> session variable was written, or would I need to register the 
> time that the
> session variable was set to the session as well?  For instance
> 
> $_SESSION['AlwaysTrue'] = "True";
> $_SESSION['ExpireThis'] = "10:20:00";
> $_SESSION['ExpireThisTime'] = "10:19:50";
> 
> Then, just do a comparison, and if ExpireThisTime is past 
> 10:20:00, then
> just delete that one variable...
> 
> There's no easier / better way to do this ??
> 
> Basically, I'm needing something like this to bring down the number of
> possible database queries.  I have a application which will have new
> information in a database, every 75 seconds.  The queries are 
> performed on
> every single page that a user is logged in to on a site.  To 
> make sure that
> the same queries is not issued over and over on the database, 
> I want to
> implement some sort of caching where I will only need to do 
> another query
> after the database received new information (every 75 
> seconds).  It's all
> numbers (integers), so I was thinking It may well work if 
> I can save
> these values to session data, and then just "refresh" the 
> session data every
> 75 seconds  The problem is, there's lots of other 
> information saved to
> the session as well, which I cannot afford to loose with a possible
> session_destroy()..
> 
> --
> me
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] PHP & Excel

2002-05-20 Thread Scott Hurring

> -Original Message-
> From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
> Subject: Re: [PHP] PHP & Excel
> 
> I would think that you wouldn't need formulas. Isn't that the 
> idea of using
> PHP to create the Excel document? Have PHP compute the values of the
> "formulas" and print out the actual value. May not work for your case,
> though...
> 
> ---John Holmes...

What if the user opens up the sheet and changes a number
after PHP creates it?  Wouldn't you want formulas to
re-compute the sheet and keep it correct?  :)

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




RE: [PHP] PHP & Excel

2002-05-20 Thread Scott Hurring

Are you on a Win32 platform?

If so, use COM...

$cell = $sheet->Cells($row,$col);
$cell->activate;
$cell->formula = "your formula";

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: LeTortorec, Jean-Louis [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 20, 2002 2:42 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] PHP & Excel
> 
> 
> Hello every one:
> 
> I'm trying to create XLS files on the fly.
> I found BiffWriter. Looks great for adding texts and numbers, but not
> formulas.
> 
> Has anyone implemented something about formulas?
> 
> Thanks.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] Variable won't work in function, even when I global it?

2002-05-20 Thread Scott Hurring

Or why not just use include_once() or require_once() ??
That's their purpose.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Paul Roberts [mailto:[EMAIL PROTECTED]]
> Subject: Re: [PHP] Variable won't work in function, even when I global
> it?
> 
> try
> 
> eval("?>$footertext");
> 
> also take the code out of the function and try it, you may 
> need to global some more variables.
> 
> Paul Roberts
> [EMAIL PROTECTED]

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




RE: [PHP] Newbie - create image error URGENT

2002-05-17 Thread Scott Hurring

Probably don't have the GD extension enaabled.

On a win machine, it's easy, look in your php.ini
and set the extensions_dir to where your extensions
are then un-comment php_gd.dll

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Dani [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 17, 2002 7:40 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Newbie - create image error URGENT
> Importance: High
> 
> 
> Hi everyone!
> 
> I'm still learning PHP and MYSQL using windows98, MYSQL, PHP 4 in my
> local hard drive.
> 
> I want to learn uploading image and resizing image in my 
> local machine.
> 
> when I execute this code:
> 
>  //setup image
> $height = 200;
> $width = 200;
> 
> $im = ImageCreate($width,$height);
> $white = ImageCreateAllocate ($im, 255, 255, 255);
> $black = ImageCreateAllocate ($im, 0, 0, 0);
> 
> //Draw on image
> ImageFill($im, 0, 0, $black);
> ImageLine($im, 0, 0, $width, $height, $white);
> ImageString($im, 4, 50, 150, "Sales", $white);
> 
> //output image
> Header ("Content-type: image/png");
> ImagePng ($im);
> 
> //Clean up
> ImageDestroy($im);
> 
> I get error message: "Fatal error: Call to undefined function:
> imagecreate() in D:\graphic_practise\index.php on line 15"
> 
> What did I do wrong?
> 
> any advice/ help is greatly appriciated.
> 
> Thanks,
> 
> Ardani
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




RE: [PHP] $answers[answer$n]

2002-05-17 Thread Scott Hurring

Try $answers["answer".$n]

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: Jule [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 17, 2002 4:41 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] $answers[answer$n]
> 
> 
> Hey guys,
> i'm getting this error whe i try to access this variable. 
> $answers[answer$n]
> 
> Parse error: parse error, expecting `']'' in 
> /home/blindtheory/web/quiz/add_quiz/add_quiz_process_2.php on line 36
> 
> the variable $answer[answers$n] comes from a form on the 
> preceding page in 
> which a number of answers has been entered. the number of 
> answers is up to 
> the user and can vary from 2 to 15. not the $n comes from a 
> for loop whcih 
> enteres the answers into a database since i do not know how 
> many answers each 
> user has used.
> 
> why am i getting this error?
> and is there a way around it?
> following is the for() loop in which this story takes place.
> 
> thanks
> Jule
> 
> --SCRIPT--
> 
> for ($n = 1; $n <= $quiz[number_answers]; $n++) {
>   $table = "$quiz[code]_answers";
>   $value = "$answers[answer$n]";
>   $query_alter_table = "ALTER table 
> $table ADD answer$n TEXT NUT NULL";
>   $query_add_answers = "INSERT INTO 
> $table (answer$n) VALUES($value)";
>   if (mysql_db_query($database_glob, 
> $query_alter_table, $link_glob) AND 
> (mysql_db_query($database_glob, $query_add_answer, $link_glob));
>   echo "Answer $n has 
> successfully been added to the Quiz\n";
>   } else { 
>   echo mysql_error();
>   }
>   echo "Click here to continue";
> }
> 
> --SCRIPT--
> 
> -- 
> |\/\__/\/|
> |   Jule Slootbeek |
> |   [EMAIL PROTECTED]  |
> |   http://blindtheory.cjb.net |
> |   __ |
> |/\/\/\|
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




[PHP] Error compiling PHP-4.2.1 on linux

2002-05-17 Thread Scott Hurring

Hello everyone.

I have been using PHP since version 4.0.6 and always
compile from source.  I have not had a single problem
until now.  I'm trying to upgrade from php-4.1.2 to
php-4.2.1, and when i make install php-4.2.1, *any*
PHP page i access throws off a ton of errors that
i've never seen before.

I use the following ./configure options (i used the exact
same opts for 4.1.2 with no prob, and i know my system has
all the necessary libs and headers)

Any help is appreciated... google searches turned up nothing
on this, so i figured "who better to ask?"  :)  Thanks!!

./configure --enable-ftp --enable-memory-limit --enable-discard-path
--enable-wddx --enable-sockets --enable-force-cgi-redirect
--with-mysql=/usr/local/mysql/ --with-zlib --with-zlib-dir=../zlib/
--with-pear --with-openssl

This is what i get when trying to access *any* PHP page
(The specific page that threw these errors was )

Warning: Unexpected character in input: '' (ASCII=4) state=1 in
/usr/local/bin/php on line 3390

Warning: Unexpected character in input: ' in /usr/local/bin/php on line 3391

Warning: Unexpected character in input: '' (ASCII=4) state=1 in
/usr/local/bin/php on line 3391

Warning: Unexpected character in input: '' (ASCII=4) state=1 in
/usr/local/bin/php on line 3392

Warning: Unexpected character in input: '' (ASCII=27) state=1 in
/usr/local/bin/php on line 3393

Parse error: parse error, unexpected T_STRING in /usr/local/bin/php on line
3393

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

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