Re: [PHP] dynamicly generating a transparent truecolor image

2004-01-16 Thread Peter Vertes
If you want to create a transparent image don't forget it must be a 
GIF.  At least that's what my graphics guys have been telling me all 
these years :)

-Pete

On Jan 16, 2004, at 04:41, Michel van der Breggen wrote:

hi,
i have a problem, i would like to dynamicly generete a transparent 
truecolor
image in php. The problem is that imagecreatetruecolor standard 
creates a
black image. Does anybody have a solution for this?

Thanks in advance,
Michel van der Breggen
[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] simple mod_rewrite question

2004-01-16 Thread Justin French
On Saturday, January 17, 2004, at 10:04  AM, Scott Taylor wrote:

What is the simplist way to do change 
http://username:[EMAIL PROTECTED]/protected/archive/$file to 
http://miningstocks.com/protected/archive/$file  where $file is a 
variable (indicating any file in that directory or any subdirectory)?
That's entirely an Apache question, not PHP... unless of course you 
were hoping that $file was a PHP variable (which can't be done, because 
the rewrite happens before PHP parses anything).

Try an Apache list, and modify your query to:

rewrite:
http://username:[EMAIL PROTECTED]/protected/archive/(.*)
to:
http://miningstocks.com/protected/archive/$1
The rewrite is EASY, but I've never dealt with domains and http auth 
stuff sorry.



Justin French

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


[PHP] spelling without aspell/pspell?

2004-01-16 Thread Justin French
Hi,

I just found a really nice set of javascripts for spell-checking a 
textarea before submitting, which is really nice, BUT is shell_exec()'s 
to aspell, which neither my host or my staging server has installed.  
It works with both PHP and Perl too.

There's a demo here:
http://www.netjs.com/speller/
What I'd like to know is if there's any other PHP-oriented solutions to 
spell checking that I might be able to integrate (with a fair amount of 
hacking) into this solution -- or perhaps a complete solution that 
doesn't require any compiling or libraries exists

Justin French

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


Re: [PHP] [GD] Circlediagram

2004-01-16 Thread John W. Holmes
Simon Fredriksson wrote:

Does anyone out there have any idea on how to create circlediagrams, 
using GD? Preferably something to set that x% of the circle is filled 
with one color and the rest with some other. Thinking about it, doesn't 
sound like an easy task with the current functions. :-\
Take a look at jpgraph: http://www.aditus.nu/jpgraph/ or search around 
hotscripts.com or phpclasses.org for some other premade scripts that'll 
make it easy to do this.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] Image Header Issues

2004-01-16 Thread Bob Eldred
Grr.that's *not* the problem.  IE saves JPGs just fine, so long as they
are not passed through this particular script.  Which is why I think it has
something to do with the headers.

Bob

- Original Message - 
From: "Arthur Pelkey" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 6:29 AM
Subject: RE: [PHP] Image Header Issues


> I've had this same problem, and it was not related to any script I
> wrote, ie just stopped saving in any other format(for images), besides
> bmp, I  am sure there would be something on ms's knowledge base, but it
> escapes me what I did to fix it, or updated.

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



[PHP] [GD] Circlediagram

2004-01-16 Thread Simon Fredriksson
Does anyone out there have any idea on how to create circlediagrams, 
using GD? Preferably something to set that x% of the circle is filled 
with one color and the rest with some other. Thinking about it, doesn't 
sound like an easy task with the current functions. :-\

//Simon

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


[PHP] Trying again: Random(?) blank pages when using sessions

2004-01-16 Thread Matt Grimm
Can anyone think of ways I can troubleshoot this problem?  I still haven't
found a solution.

> I'm using non-cookie-based sessions for authentication on a page.  The
> session is set like so, which works (these values, along with the SID, are
> always retrievable):
>
> $_SESSION['user'] = $_POST['UserName'];
> $_SESSION['time'] = time();
>
> My problem is when I get to the protected site area, in which a header
> script calls session_start() at the top (first line).  Seemingly randomly,
> while navigating links within this area, I get blank white pages.  If I
> comment out the session_start() line, it doesn't happen.  If I spit out
the
> session variables in the resulting page, they are echoed, but that's it -- 
> it's a blank white page otherwise.
>
> The apache error log is silent, and the access log is normal.  No php
errors
> are displayed or written to the log.  Here's the real kicker -- if I
refresh
> the page, it loads correctly.  What is going on?
>
> Thank you,
> --
> Matt Grimm
> Web Developer
> The Health TV Channel, Inc.
> (a non - profit organization)
> 3820 Lake Otis Parkway
> Anchorage, AK 99508
> 907.770.6200 ext. 686
> 907.336.6205 (fax)
> E-mail: [EMAIL PROTECTED]
> Web: www.healthtvchannel.org

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



RE: [PHP] Returning Newbie (Disoriented)

2004-01-16 Thread Chris W. Parker
Freedomware 
on Monday, January 12, 2004 5:47 PM said:

> Now I just have to get it hooked up to Dreamweaver. But I'll take your
> advice and find out what programs my host is running.

I don't think you "hook up" Dreamweaver to anything in the way that
Frontpage "hooks up" to an IIS server. With Dreamweaver (I think) it's
just an FTP thing.


Chris.

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



[PHP] Documentation on features not in current release (SimpleXML PHP5 Beta 3)

2004-01-16 Thread Jonathan
Where would I be able to find a function reference or documentation on
new features that are not documented in the official manual?  Preferably
in a format that can be read/browsed offline.
Thanks, Jonathan
P.S. Sorry if this is a repeat, I thought this went through but just got
a bounce back.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Can you recommend a good PHP includes tutorial?

2004-01-16 Thread Chris W. Parker
Freedomware 
on Wednesday, January 14, 2004 5:17 AM said:

> Wow, that is a lot simpler than I imagined. Thanks for the tip!

Imagined? What did the book tell you to do?



Chris.

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



RE: [PHP] pass output of php scripts through command line programor cgi

2004-01-16 Thread Roger B.A. Klorese
Sorry, but what command line are you talking about?

He didn't say he'd like to execute his PHP scripts from a shell prompt.

He said that he'd like the output of his PHP scripts to be filtered before
httpd outputs them.

> on the commandline you need to have the php executable on your
> path...then run 
> 
> php -f [filename]
> 
> so 
> 
> php -f index.php
> 
> that will do it for you.
> 
> --
> Ray
> 
> On Sat, 2004-01-17 at 05:44, Paul William wrote:
> > Hi,
> > 
> > I want to run the output of all the php scripts running on my apache
> > server through a command line or CGI program. I do not want 
> to modify
> > any of the php scripts.Has anyone done this? Is this possible?
> > 
> > For example (this is a stupid example and I am not using it 
> for this):
> > 
> > The output of "index.php" is:
> > 
> > 
> > ...
> > 
> > 
> > 
> > 
> > then that output is run through "addfooter" (a command line script)
> > which results in:
> > 
> > 
> > ...
> > 
> > The footer is inserted here.
> > 
> > 
> > 
> > Then apache outputs the above html.
> > 
> > Any ideas?
> > 
> > Thanks
> > 
> > Paul
> > 
> > 
> > 
> > -- 
> > 
> >  .''`. Paul William
> > : :'  :Debian admin and user
> > `. `'`
> >   `-  Debian - when you have better things to do than 
> fixing a system
> 
> -- 
> 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] pass output of php scripts through command line program or cgi

2004-01-16 Thread Ray Hunter
on the commandline you need to have the php executable on your
path...then run 

php -f [filename]

so 

php -f index.php

that will do it for you.

--
Ray

On Sat, 2004-01-17 at 05:44, Paul William wrote:
> Hi,
> 
> I want to run the output of all the php scripts running on my apache
> server through a command line or CGI program. I do not want to modify
> any of the php scripts.Has anyone done this? Is this possible?
> 
> For example (this is a stupid example and I am not using it for this):
> 
> The output of "index.php" is:
> 
> 
> ...
> 
> 
> 
> 
> then that output is run through "addfooter" (a command line script)
> which results in:
> 
> 
> ...
> 
> The footer is inserted here.
> 
> 
> 
> Then apache outputs the above html.
> 
> Any ideas?
> 
> Thanks
> 
> Paul
> 
> 
> 
> -- 
> 
>  .''`. Paul William
> : :'  :Debian admin and user
> `. `'`
>   `-  Debian - when you have better things to do than fixing a system

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



[PHP] pass output of php scripts through command line program or cgi

2004-01-16 Thread Paul William
Hi,

I want to run the output of all the php scripts running on my apache
server through a command line or CGI program. I do not want to modify
any of the php scripts.Has anyone done this? Is this possible?

For example (this is a stupid example and I am not using it for this):

The output of "index.php" is:


...




then that output is run through "addfooter" (a command line script)
which results in:


...

The footer is inserted here.



Then apache outputs the above html.

Any ideas?

Thanks

Paul



-- 

 .''`. Paul William
: :'  :Debian admin and user
`. `'`
  `-  Debian - when you have better things to do than fixing a system

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



[PHP] simple mod_rewrite question

2004-01-16 Thread Scott Taylor


What is the simplist way to do change 
http://username:[EMAIL PROTECTED]/protected/archive/$file to 
http://miningstocks.com/protected/archive/$file  where $file is a 
variable (indicating any file in that directory or any subdirectory)?

Best Regards and thank you for all the help,

Scott Taylor

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


[PHP] Ip Tracking Utilities

2004-01-16 Thread Rolf Brusletto
Hey all - I've heard mention of Ip database/tracking utilities in the
lists before, but I can't seem to find any mention when googling... does
anybody know of a good app to track multiple Class C spaces or larger?

Thanks,


Rolf Brusletto
--
http://www.phpExamples.net
http://www.emailfeeds.com
--

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



Re: [PHP] SOLVED - LOAD_FILE and PHP

2004-01-16 Thread Jough P
Thank you everyone for you fabulous help!!!

btw,
the FILE privilege is a global privilege, and as such needs to be in 
the *.* context. It does not work on a db-level.

On Jan 16, 2004, at 4:08 PM, Jough P wrote:

OMG I'm sure that's why I'm having problems.  Do you know the syntax 
for granting the file_priv?  The following doesn't seem to work:

mysql> GRANT file ON bs.table1 TO [EMAIL PROTECTED] IDENTIFIED BY 
'password123';

On Jan 16, 2004, at 3:15 PM, Jason Wong wrote:

On Saturday 17 January 2004 03:44, Jough P wrote:
On Jan 16, 2004, at 9:12 AM, Jough P wrote:
Greetings all, I can't get LOAD_FILE to work in an INSERT statement
from PHP.  The generated sql works when you're in mysql but won't 
work
from PHP.
Are you using the same user in both cases? The use of LOAD_FILE() 
requires
that the user has the 'FILE' privilege.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development 
*
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
If God hadn't wanted you to be paranoid, He wouldn't have given you 
such
a vivid imagination.
*/

--
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] Can I do this? If so why wont it work

2004-01-16 Thread Alex Hogan
Thanks..

> -Original Message-
> From: John W. Holmes [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 16, 2004 4:29 PM
> To: Alex Hogan
> Cc: PHP General list
> Subject: Re: [PHP] Can I do this? If so why wont it work
> 
> Alex Hogan wrote:
> > I am wanting to read in several session values at once.
> >
> >
> >
> > This is what I have so far;
> >
> >
> >
> > $_SESSION['obj[1]'] = $_REQUEST['txtObj1'];
> >
> > $_SESSION['obj[2]'] = $_REQUEST['txtObj2'];
> >
> > $_SESSION['obj[3]'] = $_REQUEST['txtObj3'];
> >
> > $_SESSION['obj[4]'] = $_REQUEST['txtObj4'];
> >
> > $_SESSION['obj[5]'] = $_REQUEST['txtObj5'];
> >
> >
> >
> > $i = 1;
> >
> > while ($i <= 5) {
> >
> > $obj_ar[$i] = $_SESSION['obj[$i]']$i++;
> >
> > }
> > I keep getting this error;
> >
> > Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24
> 
> Well, first your error is because you have $i++ on that last line. It
> should be separated like someone else mentioned. Second, using
> "['obj[$i]']" as the key is not going to work because $i is not
> evaluated between single quotes.
> 
> Third, you really need to change how you do all of this and understand
> arrays a little better.
> 
> First thing to do is instead of naming things "txtObj1" and "txtObj2",
> etc, name them "txtObj[]". Name every one of them that. Now, when the
> form is submitted, you'll have a $_REQUEST['txtObj'] array containing
> all of your data. $_REQUEST['txtObj'][0] will be the first value,
> $_REQUEST['txtObj'][1] will be the second, etc.
> 
> To save that in the session, you can simply do:
> 
> $_SESSION['txtObj'] = $_REQUEST['txtObj'];
> 
> Now, $_SESSION['txtObj'][0] is the first one, $_SESSION['txtObj'][1] is
> the second, etc.
> 
> Any time you're naming things _1, _2, _3, etc, you're doing it the hard
> way instead of using an array.
> 
> Hope this helps.
> 
> --
> ---John Holmes...
> 
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
> 
> php|architect: The Magazine for PHP Professionals - www.phparch.com
> 
> 
> 



** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




Re: [PHP] Please help me retrieving data from a PHP file!!???

2004-01-16 Thread John W. Holmes
SASSINC Internet Solutions - Arabic Department wrote:

How to retrieve data from a PHP file? 
(The value that will be retrieved of course 
it is echoed in the PHP file, and it will be 
shown in a TextBox in my VB program.. so I want 
to retrieve it to my EXE VB program that will 
put it inside a TextBox or something like that..)
So you have a PHP file that does (for example)



And you want to retrieve it's results, i.e. the "Hello" string?

Like someone else said, you need to ask this on a VB list. You need to 
determine how to run a program from within VB to run php from the 
command line or open a web interface and retrieve the results of a web 
file. This is not a PHP specific problem.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread John W. Holmes
Alex Hogan wrote:
I am wanting to read in several session values at once.

 

This is what I have so far;

 

$_SESSION['obj[1]'] = $_REQUEST['txtObj1'];

$_SESSION['obj[2]'] = $_REQUEST['txtObj2'];

$_SESSION['obj[3]'] = $_REQUEST['txtObj3'];

$_SESSION['obj[4]'] = $_REQUEST['txtObj4'];

$_SESSION['obj[5]'] = $_REQUEST['txtObj5'];

 

$i = 1;

while ($i <= 5) {

$obj_ar[$i] = $_SESSION['obj[$i]']$i++;

}
I keep getting this error;
Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24 
Well, first your error is because you have $i++ on that last line. It 
should be separated like someone else mentioned. Second, using 
"['obj[$i]']" as the key is not going to work because $i is not 
evaluated between single quotes.

Third, you really need to change how you do all of this and understand 
arrays a little better.

First thing to do is instead of naming things "txtObj1" and "txtObj2", 
etc, name them "txtObj[]". Name every one of them that. Now, when the 
form is submitted, you'll have a $_REQUEST['txtObj'] array containing 
all of your data. $_REQUEST['txtObj'][0] will be the first value, 
$_REQUEST['txtObj'][1] will be the second, etc.

To save that in the session, you can simply do:

$_SESSION['txtObj'] = $_REQUEST['txtObj'];

Now, $_SESSION['txtObj'][0] is the first one, $_SESSION['txtObj'][1] is 
the second, etc.

Any time you're naming things _1, _2, _3, etc, you're doing it the hard 
way instead of using an array.

Hope this helps.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


[PHP] Re: Please help me retrieving data from a PHP file!!???

2004-01-16 Thread Ben Ramsey
> How to retrieve data from a PHP file? (The value that will
> be retrieved of course it is echoed in the PHP file, and it
> will be shown in a TextBox in my VB program.. so I want to
> retrieve it to my EXE VB program that will put it inside a
> TextBox or something like that..)
From within a PHP file, you may use exec() or passthru() to execute an 
external program and return the results to the PHP script.  Seems to me 
like VB should have something similar to execute a PHP script (perhaps 
through HTTP or something).

At any rate, I think you would probably need to ask this question on a 
VB mailing list, since they may be able to help you better.  If your PHP 
script just echos something, then you'll need to find out what VB 
function there is to execute the PHP script and grab the value that is 
echoed.

-Ben

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


Re: [PHP] mysql question

2004-01-16 Thread Christian Calloway
Hey Mike,

That is almost exactly what I am doing. I have a table, lets say
"product_fields" which describes each characteristic/field of a product
(with N possible fields). A definition of a field includes, its name (as the
customer see's it), its type, a named-reference to the field in the data
table, and of course the id of the particular product.  The "products_data"
table is composed of fields sequentially labeled from f1 to fn, and contains
the actual data. The only difference being that I am creating a new
"products_data" table for each product (so something like
"products_data_$productid"), as opposed to storing all field data in a
singular large table. So the real question is, is it favorable to have one
large table with N number of fields (products * fields), or N number of
smaller tables (N products). I have absolutely no idea, but I will do some
digging myself. Thanks for the help

Christian

"Miles Thompson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Christian,
>
> I did a bit of digging in the MySQL docs to try and find the limits on
> number of fields in a table, etc. Didn't have much luck. I would not worry
> about thousands, or even hundreds of thousands of rows in a table for two
> reasons. First MySQL is becoming a heavier-duty database, and second, when
> the proper indexes are used it is blindingly fast at retrievals.
Apparently
> the database engine also handles a large number of tables quite well.
>
> When tables will be multiplying like bunnies, as you posit here, I foresee
> major code headaches.
>
> I've thought about following type of design but have never implemented it.
> Might it work in your situation? Maybe this is what you are already doing,
> and I've just  relabelled it. If so, please accept my apologies.
>
> Have standard tables for the basic stuff.: company, with co_key, address
> fields etc; products with prod_key, co_key, prod_name, etc.
>
> Have two other tables, let's call them prod_descriptors and prod_data.
> We're violating one of Codd's principles here because the prod_data table
> has meaningless field names, just f1, f2, f3, f4 ... fn. How you sort out
> which data types to use is your business.
>
> Prod_descriptors contains the meta information which makes prod_data
> useful. Its fields, at a minimum, would be prod_key, prod_characteristic,
> prod_data_field. For a given prod_key "M56H" there would be a record for
> each product characteristic which you have to track, and the field used in
> prod_data.
>
> This may be a somewhat extreme example, as it is highly likely that there
> are a common characteristics for all products, so things would not have to
> be totally generalized. This design is also somewhat wasteful of disk
> space, but MySQL does a remarkable job, internally, of conserving space so
> it is used efficiently. The thorny issue of which data types to use in
what
> columns hasn't been addressed either.
>
> The crunch is whether or not you can ask questions of these tables and
> fetch the data you need.
>
>
>
>
>
> At 12:52 PM 1/16/2004 +, Christian Calloway wrote:
> >Well let me try and describe a simplified version of what I am doing. I
work
> >for a group of analysts, and they analyse technical products. Each
products
> >has about 300+ fields associated with it, and each product is vastly
> >different from the other. Let's say the product "foo" has a table
"fields"
> >associated with it, which describes each field in foo (its name,
> >description, type[float,boolean,text], order) and another table called
> >"data_foo" which is 300+ fields in length. Each record in "data_foo"
> >represents the technical specfiications of a single company/manufacturer.
So
> >if there are 200+ companies, there will be at least one data_foo record
> >associated with it (in reality there is a one to many association between
a
> >company and the number of technical specifications they have
defined).There
> >are many different applications designed around the tables "foo" and
> >"data_foo", and course the relationships are slightly more involved, but
I
> >digress. Each new product specification requires that I create a new
table
> >to hold that data, and with new product specifications being created
every
> >month, you see that the N number of tables will increase. If I store that
> >data in the "fields" table or create a table that has 1-many relationship
> >with it, I endup with thousands and thousands of records (Remember, each
> >product has 300+ fields associated with it, and each company has at least
on
> >product specfication, and the N number of products continues to
increase).
> >Any ideas?
> >
> >"Miles Thompson" <[EMAIL PROTECTED]> wrote in message
> >news:[EMAIL PROTECTED]
> > > Christian,
> > >
> > > A red flag is flying.
> > >
> > > Usually, when people start talking about how the number of tables will
> > > multiply in an application, there is a problem with the design of data
> > > structures. If that's the case, now is the time

Re: [PHP] LOAD_FILE and PHP

2004-01-16 Thread Jough P
OMG I'm sure that's why I'm having problems.  Do you know the syntax 
for granting the file_priv?  The following doesn't seem to work:

mysql> GRANT file ON bs.table1 TO [EMAIL PROTECTED] IDENTIFIED BY 
'password123';

On Jan 16, 2004, at 3:15 PM, Jason Wong wrote:

On Saturday 17 January 2004 03:44, Jough P wrote:
On Jan 16, 2004, at 9:12 AM, Jough P wrote:
Greetings all, I can't get LOAD_FILE to work in an INSERT statement
from PHP.  The generated sql works when you're in mysql but won't 
work
from PHP.
Are you using the same user in both cases? The use of LOAD_FILE() 
requires
that the user has the 'FILE' privilege.

--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
If God hadn't wanted you to be paranoid, He wouldn't have given you 
such
a vivid imagination.
*/

--
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] readfile() and 401 pages

2004-01-16 Thread Vince LaMonica
Hi all,

I'm attempting to use readfile() to redirect the user to a .htaccess
protected page:

https://www.foo.edu/cgi-bin/stats/awstats?config=more.foo.here";);
?>

The stats/ directory is .htaccess'ed. [and the URL is even longer, with a
lot of other options tagged onto the awstats call]. I would like to be
able to redirect users to a simplier URL:

https://www.foo.edu/stats/site

and have the 'authorization required' browser dialog box pop up when going
there [like it does when they visit the long/normal URL].

Instead, what I'm getting back is a PHP error stating that HTTP/1.1
Authorization Required in line 2 of the above page. Does readfile() not
pass along 401s to the browser? I know I can do an alias in apache's
setup, which is what I plan on doing if readfile() can't be made to work.
But I am curious if this is a limitation or design in readfile().

TIA,

/vjl/

-- 
Vince LaMonica   UC Irvine,  School  of  Social Ecology
 W3 Developer   <*>  116 Social Ecology I, Irvine, CA 92697
 [EMAIL PROTECTED]  http://www.seweb.uci.edu/techsupport

 Information wants to be free.
Rent wants to be paid.

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



[PHP] Please help me retrieving data from a PHP file!!???

2004-01-16 Thread SASSINC Internet Solutions - Arabic Department
Hi all..

I hope you can help me..

How to retrieve data from a PHP file? (The value that will be retrieved of course it 
is echoed in the PHP file, and it will be shown in a TextBox in my VB program.. so I 
want to retrieve it to my EXE VB program that will put it inside a TextBox or 
something like that..)

I'm waiting your replies guys..

Best regards and cheers..
Hadi Aladdin


Re: [PHP] odd and even numbers

2004-01-16 Thread Jake McHenry
- Original Message - 
From: "joel boonstra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 4:54 PM
Subject: Re: [PHP] odd and even numbers


> Jake,
>
> > This worked.. somewhat.. here is what I want to do though.
> >
> > I have two people checking the same email address. I want to break up
the
> > emails 50/50 to each person. What values can I put into the random
number
> > generator so that I can get closer to 50/50. I just set up a test page
with:
> >
> > $rand = rand(1, 501);
> >
> > echo $rand;
> >
> > if ($rand % 2 == 0)
> >   echo "even";
> > else
> >   echo "odd";
> >
> >
> > and I'm getting a lot more evens than odds, so the one person would get
more
> > emails than the other. Is there any substitution to rand that I could
use to
> > get one message to go to one person, then the next to the other? I'd
like it
> > to be as close to 50/50 as possible.
>
> Is there any way you can save state?  That is, can you keep track of who
> got the last one, and use that to determine who should get the next one?
>
> Otherwise, why not just rand() between 1 and 2?   rand(1,2) will, on
> average, give you as many 1s as 2s (like flipping a coin).  There will
> likely be runs of 1 or 2, but over time, doing rand() with two possible
> values versus rand() with 501 values will not be significantly
> different.
>
> In fact, since there is one more odd than even between 1 and 501
> (inclusive), you will be getting slightly more odds than evens with that
> range than you will with a range of 1 and 2.
>
> Also, which PHP version are you using?  If before 4.2.0, you should seed
> the random number generator with srand().  If you are using 4.2.0 or
> greater, and still seeing non-random behavior, I don't really have an
> answer.
>
> -- 
> [ joel boonstra | gospelcom.net ]
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>





version 4.2.2

Jake


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



Re: [PHP] odd and even numbers

2004-01-16 Thread Jake McHenry
- Original Message - 
From: "Katie Dewees" <[EMAIL PROTECTED]>
To: "Jake McHenry" <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 4:44 PM
Subject: RE: [PHP] odd and even numbers


> Can you just set a value somewhere (in a flat file, or a database) to 1 or
> 2. 1 can represent person number 1, 2 person number 2. Check the value
every
> time you deliver an e-mail to see who gets it, and then switch it to the
> other one.
>
> Katie Dewees
> Web Developer
> E-mail: [EMAIL PROTECTED]
>
> -Original Message-
> From: Jake McHenry [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 16, 2004 3:42 PM
> To: joel boonstra
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] odd and even numbers
>
>
> - Original Message -
> From: "joel boonstra" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, January 16, 2004 3:35 PM
> Subject: Re: [PHP] odd and even numbers
>
>
> > On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote:
> > > function isOdd ($value) {
> > > return (int)$value % 2 ? true : false;
> > > }
> > >
> > > Returns true/false if the value is odd. Also rounds down floating
point
> numbers given as the test value.
> >
> > No need to explicitly state "true" and "false".  Just negate the result
> > of your modulus operator, and take advantage of the fact that "0" is
> > false, and "1" is true:
> >
> > function isOdd ($value) {
> >   return !((int)$value % 2);
> > }
> >
> > --
> > [ joel boonstra | gospelcom.net ]
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> This worked.. somewhat.. here is what I want to do though.
>
> I have two people checking the same email address. I want to break up the
> emails 50/50 to each person. What values can I put into the random number
> generator so that I can get closer to 50/50. I just set up a test page
with:
>
> $rand = rand(1, 501);
>
> echo $rand;
>
> if ($rand % 2 == 0)
>   echo "even";
> else
>   echo "odd";
>
>
> and I'm getting a lot more evens than odds, so the one person would get
more
> emails than the other. Is there any substitution to rand that I could use
to
> get one message to go to one person, then the next to the other? I'd like
it
> to be as close to 50/50 as possible.
>
> any questions, let me know
>
> Thanks,
> Jake
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


I could, but I didn't really want to. I just wanted a quick fix... I was
going to do that before, just wanted to see if anyone knew of another route.

Thanks,
Jake

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



Re: [PHP] odd and even numbers

2004-01-16 Thread joel boonstra
Jake,

> This worked.. somewhat.. here is what I want to do though.
> 
> I have two people checking the same email address. I want to break up the
> emails 50/50 to each person. What values can I put into the random number
> generator so that I can get closer to 50/50. I just set up a test page with:
> 
> $rand = rand(1, 501);
> 
> echo $rand;
> 
> if ($rand % 2 == 0)
>   echo "even";
> else
>   echo "odd";
> 
> 
> and I'm getting a lot more evens than odds, so the one person would get more
> emails than the other. Is there any substitution to rand that I could use to
> get one message to go to one person, then the next to the other? I'd like it
> to be as close to 50/50 as possible.

Is there any way you can save state?  That is, can you keep track of who
got the last one, and use that to determine who should get the next one?

Otherwise, why not just rand() between 1 and 2?   rand(1,2) will, on
average, give you as many 1s as 2s (like flipping a coin).  There will
likely be runs of 1 or 2, but over time, doing rand() with two possible
values versus rand() with 501 values will not be significantly
different.

In fact, since there is one more odd than even between 1 and 501
(inclusive), you will be getting slightly more odds than evens with that
range than you will with a range of 1 and 2.

Also, which PHP version are you using?  If before 4.2.0, you should seed
the random number generator with srand().  If you are using 4.2.0 or
greater, and still seeing non-random behavior, I don't really have an
answer.

-- 
[ joel boonstra | gospelcom.net ]

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



RE: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread Alex Hogan
Tried it now I get;

Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 22

Line 22 is $i++;

> Try this:
> 
> while ($i <= 5) {
> $obj_ar[$i] = $_SESSION['obj[$i]'];
> $i++;
> }


** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




RE: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread Alex Hogan

Line 24 is: $obj_ar[$i] = $_SESSION['obj[$i]']$i++;


Alex

> -Original Message-
> From: Jake McHenry [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 16, 2004 3:31 PM
> To: Alex Hogan
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Can I do this? If so why wont it work
> 
> 
> - Original Message -
> From: "Alex Hogan" <[EMAIL PROTECTED]>
> To: "PHP General list" <[EMAIL PROTECTED]>
> Sent: Friday, January 16, 2004 4:20 PM
> Subject: [PHP] Can I do this? If so why wont it work
> 
> 
> > I am wanting to read in several session values at once.
> >
> >
> >
> > This is what I have so far;
> >
> >
> >
> > $_SESSION['obj[1]'] = $_REQUEST['txtObj1'];
> >
> > $_SESSION['obj[2]'] = $_REQUEST['txtObj2'];
> >
> > $_SESSION['obj[3]'] = $_REQUEST['txtObj3'];
> >
> > $_SESSION['obj[4]'] = $_REQUEST['txtObj4'];
> >
> > $_SESSION['obj[5]'] = $_REQUEST['txtObj5'];
> >
> >
> >
> > $i = 1;
> >
> > while ($i <= 5) {
> >
> > $obj_ar[$i] = $_SESSION['obj[$i]']$i++;
> >
> > }
> >
> >
> >
> > I keep getting this error;
> >
> > Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24
> >
> >
> >
> > Where am I making the mistake?
> >
> >
> >
> > alex hogan
> >
> >
> >
> >
> >
> > **
> > The contents of this e-mail and any files transmitted with it are
> > confidential and intended solely for the use of the individual or
> > entity to whom it is addressed.  The views stated herein do not
> > necessarily represent the view of the company.  If you are not the
> > intended recipient of this e-mail you may not copy, forward,
> > disclose, or otherwise use it or any part of it in any form
> > whatsoever.  If you have received this e-mail in error please
> > e-mail the sender.
> > **
> >
> >
> >
> 
> 
> 
> What is on line 24?
> 
> 
> 
> Try this:
> 
> while ($i <= 5) {
> $obj_ar[$i] = $_SESSION['obj[$i]'];
> $i++;
> }
> 
> 
> Jake


** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




Re: [PHP] odd and even numbers

2004-01-16 Thread Jake McHenry
- Original Message - 
From: "joel boonstra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 3:35 PM
Subject: Re: [PHP] odd and even numbers


> On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote:
> > function isOdd ($value) {
> > return (int)$value % 2 ? true : false;
> > }
> >
> > Returns true/false if the value is odd. Also rounds down floating point
numbers given as the test value.
>
> No need to explicitly state "true" and "false".  Just negate the result
> of your modulus operator, and take advantage of the fact that "0" is
> false, and "1" is true:
>
> function isOdd ($value) {
>   return !((int)$value % 2);
> }
>
> -- 
> [ joel boonstra | gospelcom.net ]
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


This worked.. somewhat.. here is what I want to do though.

I have two people checking the same email address. I want to break up the
emails 50/50 to each person. What values can I put into the random number
generator so that I can get closer to 50/50. I just set up a test page with:

$rand = rand(1, 501);

echo $rand;

if ($rand % 2 == 0)
  echo "even";
else
  echo "odd";


and I'm getting a lot more evens than odds, so the one person would get more
emails than the other. Is there any substitution to rand that I could use to
get one message to go to one person, then the next to the other? I'd like it
to be as close to 50/50 as possible.

any questions, let me know

Thanks,
Jake

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



Re: [PHP] Can I do this? If so why wont it work

2004-01-16 Thread Jake McHenry

- Original Message - 
From: "Alex Hogan" <[EMAIL PROTECTED]>
To: "PHP General list" <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 4:20 PM
Subject: [PHP] Can I do this? If so why wont it work


> I am wanting to read in several session values at once.
> 
>  
> 
> This is what I have so far;
> 
>  
> 
> $_SESSION['obj[1]'] = $_REQUEST['txtObj1'];
> 
> $_SESSION['obj[2]'] = $_REQUEST['txtObj2'];
> 
> $_SESSION['obj[3]'] = $_REQUEST['txtObj3'];
> 
> $_SESSION['obj[4]'] = $_REQUEST['txtObj4'];
> 
> $_SESSION['obj[5]'] = $_REQUEST['txtObj5'];
> 
>  
> 
> $i = 1;
> 
> while ($i <= 5) {
> 
> $obj_ar[$i] = $_SESSION['obj[$i]']$i++;
> 
> }
> 
>  
> 
> I keep getting this error;
> 
> Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24 
> 
>  
> 
> Where am I making the mistake?
> 
>  
> 
> alex hogan
> 
>  
> 
> 
> 
> ** 
> The contents of this e-mail and any files transmitted with it are 
> confidential and intended solely for the use of the individual or 
> entity to whom it is addressed.  The views stated herein do not 
> necessarily represent the view of the company.  If you are not the 
> intended recipient of this e-mail you may not copy, forward, 
> disclose, or otherwise use it or any part of it in any form 
> whatsoever.  If you have received this e-mail in error please 
> e-mail the sender. 
> ** 
> 
> 
> 



What is on line 24?



Try this:

while ($i <= 5) {
$obj_ar[$i] = $_SESSION['obj[$i]'];
$i++;
}


Jake

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



Re: [PHP] odd and even numbers

2004-01-16 Thread Brian V Bonini
On Fri, 2004-01-16 at 15:17, Jake McHenry wrote:
> I have a random number being generated from 1 to 501, is there an easy way for me to 
> tell if the result is an odd or even number?


(1 & number) ? odd : even;

E.g.

';
while($i < 10) {
(1 & $i) ? print($i . ' is odd') : print($i . ' is even');
echo "\n";
$i++;
}
echo '';
?>

 

-- 
BrianGnuPG -> KeyID: 0x04A4F0DC | URL: www.gfx-design.com/keys
  Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
GnuPG: http://gnupg.org
http://www.biglumber.com/x/web?qs=0x2C35011004A4F0DC
Linux Registered User #339825 at http://counter.li.org


signature.asc
Description: This is a digitally signed message part


[PHP] Can I do this? If so why wont it work

2004-01-16 Thread Alex Hogan
I am wanting to read in several session values at once.

 

This is what I have so far;

 

$_SESSION['obj[1]'] = $_REQUEST['txtObj1'];

$_SESSION['obj[2]'] = $_REQUEST['txtObj2'];

$_SESSION['obj[3]'] = $_REQUEST['txtObj3'];

$_SESSION['obj[4]'] = $_REQUEST['txtObj4'];

$_SESSION['obj[5]'] = $_REQUEST['txtObj5'];

 

$i = 1;

while ($i <= 5) {

$obj_ar[$i] = $_SESSION['obj[$i]']$i++;

}

 

I keep getting this error;

Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24 

 

Where am I making the mistake?

 

alex hogan

 



** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




Re: [PHP] LOAD_FILE and PHP

2004-01-16 Thread Jason Wong
On Saturday 17 January 2004 03:44, Jough P wrote:
> On Jan 16, 2004, at 9:12 AM, Jough P wrote:
> > Greetings all, I can't get LOAD_FILE to work in an INSERT statement
> > from PHP.  The generated sql works when you're in mysql but won't work
> > from PHP.

Are you using the same user in both cases? The use of LOAD_FILE() requires 
that the user has the 'FILE' privilege.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
If God hadn't wanted you to be paranoid, He wouldn't have given you such
a vivid imagination.
*/

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



Re: [PHP] Re: alternative to protecting files through http auth.

2004-01-16 Thread Jason Wong
On Saturday 17 January 2004 04:03, Scott Taylor wrote:

> >Alternately, if you aren't able to create directories or access files
> >outside the DocumentRoot for your site, you can create an unbrowsable
> >storage directory protected with a .htaccess file.  If the filesystem
> >permissions are correct, your PHP script will be able to read content
> >from that directory, because PHP code isn't subject to .htaccess rules.
>
> It actually does not work. 

Could you explain what, exactly, does not work?

> I am trying to load a PDF file.  I've tried
> to load it from a protected directory loading it with headers, but this
> fails if the protection is on.  Does this make sense to you?

The above outlines a scheme which is workable. Could you describe the steps 
you took to implement said scheme which lead you to the conclusion that "It 
actually does not work" ?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
It is not good for a man to be without knowledge,
and he who makes haste with his feet misses his way.
-- Proverbs 19:2
*/

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



Re: [PHP] Syntax Error -> This is WEIRD!

2004-01-16 Thread Dagfinn Reiersøl
Donald Tyler wrote:

Yes that is true. But I would strongly recommend against doing that.

You should never include anything over HTTP. Its extremely messy, 100%
insecure and just a very very bad idea.
 

My spontaneous reaction is to agree with you. On the other hand, are 
SOAP or XML-RPC over
HTTP any more secure in principle? You would need some kind of 
authentication, of course,
unless you just love exposing your code.

It's a weird concept, but I was trying to give the guy who started the 
thread the benefit of the doubt. Maybe
he has a good reason for doing it. Maybe the people who implemented this 
feature in PHP had a good reason for
implementing it.

You should have all the files you need to include located on your web
server.
 

Yes, I don't know why you would want to keep them on a remote server.

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


Re: [PHP] odd and even numbers SOLVED

2004-01-16 Thread Jake McHenry
- Original Message - 
From: "joel boonstra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 16, 2004 3:35 PM
Subject: Re: [PHP] odd and even numbers


> On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote:
> > function isOdd ($value) {
> > return (int)$value % 2 ? true : false;
> > }
> >
> > Returns true/false if the value is odd. Also rounds down floating point
numbers given as the test value.
>
> No need to explicitly state "true" and "false".  Just negate the result
> of your modulus operator, and take advantage of the fact that "0" is
> false, and "1" is true:
>
> function isOdd ($value) {
>   return !((int)$value % 2);
> }
>
> -- 
> [ joel boonstra | gospelcom.net ]
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>








Thanks everyone for the fast replys!

Jake

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



Re: [PHP] Syntax Error -> This is WEIRD!

2004-01-16 Thread Dagfinn Reiers?l
Jason Wong wrote:

>On Saturday 17 January 2004 01:50, Dagfinn Reiersøl wrote:
>
>  
>
>>Yes. I read the manual which provides no clear explanation (I suspect
>>that whoever wrote it didn't actually know how it works). So I decided
>>to test it. It does exactly what you say it does. I made an include file
>>like this:
>>
>>
>
>In defence of the manual writers, the manual says:
>
>... the script is actually being run on the remote server and the *result* is 
>then being included into the local script.
>
>What is not clear about that?
>
>  
>
E...

Well...

Reading that one sentence and knowing for sure what the correct answer
is, it's crystal clear. When I read the whole explanation the first
time and was slightly confused already, it was like a wandering through
a foggy night. This sentence, for instance:

"If the target server interprets the target file as PHP code, variables
may be passed to the included file
using an URL request string as used with HTTP GET. "

I read "as used with" as meaning that "this is not quite the same thing
as an HTTP GET", whereas
in fact it is an HTTP GET. And thinking about it now, I realize that it
could hardly be anything else.

Which also means that the phrase about interpreting the file as PHP code
is slightly misleading, since
presumably the same comment would apply to a JSP or any other dynamic
Web page, as long as its *output* is PHP
code.

I think that's enough linguistics for now.

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



Re: [PHP] odd and even numbers

2004-01-16 Thread joel boonstra
On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote:
> function isOdd ($value) {
>   return (int)$value % 2 ? true : false;
> }
> 
> Returns true/false if the value is odd. Also rounds down floating point numbers 
> given as the test value.

No need to explicitly state "true" and "false".  Just negate the result
of your modulus operator, and take advantage of the fact that "0" is
false, and "1" is true:

function isOdd ($value) {
  return !((int)$value % 2);
}

-- 
[ joel boonstra | gospelcom.net ]

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



RE: [PHP] odd and even numbers

2004-01-16 Thread Jeremy
function isOdd ($value) {
return (int)$value % 2 ? true : false;
}

Returns true/false if the value is odd. Also rounds down floating point numbers given 
as the test value.

-Jeremy

-Original Message-
From: Jake McHenry [mailto:[EMAIL PROTECTED]
Sent: Friday, January 16, 2004 2:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] odd and even numbers


I have a random number being generated from 1 to 501, is there an easy way for me to 
tell if the result is an odd or even number?

Thanks,
Jake

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



Re: [PHP] odd and even numbers

2004-01-16 Thread Brad Pauly
On Fri, 2004-01-16 at 13:17, Jake McHenry wrote:
> I have a random number being generated from 1 to 501, is there an easy way for me to 
> tell if the result is an odd or even number?

Yep. The modulus operator (%). Your number mod 2 will be 1 if it is odd
and 0 if it is even.

http://us4.php.net/manual/en/language.operators.arithmetic.php

if ($your_number % 2) {
  echo 'odd';
} else {
  echo 'even';
}

- Brad

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



[PHP] odd and even numbers

2004-01-16 Thread Jake McHenry
I have a random number being generated from 1 to 501, is there an easy way for me to 
tell if the result is an odd or even number?

Thanks,
Jake

[PHP] Re: alternative to protecting files through http auth.

2004-01-16 Thread Scott Taylor
Paul Chvostek wrote:

On Wed, Jan 14, 2004 at 04:17:06PM -0500, Scott Taylor wrote:
 

Is there no other way to protect your (non PHP) files than through 
authentication?  I've been trying to set up a system that will protect 
files.  Those trying to access the files would only be able to do so 
after entering their email address.  So I set up a form that submits the 
email to my database.  But then the problem is: how to access the files?
   

Put the files in a directory somewhere outside the DocumentRoot of the
web site in which the PHP code lives.  Have the PHP code do whatever
"authentication" you want (even if it's just collecting an email
address), and upon success, use file() or readfile() or include() or
file_get_contents() or equivalent to pull the file contents from their
location on the server.
Alternately, if you aren't able to create directories or access files
outside the DocumentRoot for your site, you can create an unbrowsable
storage directory protected with a .htaccess file.  If the filesystem
permissions are correct, your PHP script will be able to read content
from that directory, because PHP code isn't subject to .htaccess rules.
 



It actually does not work.  I am trying to load a PDF file.  I've tried 
to load it from a protected directory loading it with headers, but this 
fails if the protection is on.  Does this make sense to you? 

Unfortunately, I do not have access to the .htaccess file (I am on a 
shared server where I am not the administrator) and I can not store 
documents outside of my http document directory.

Scott Taylor

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


Re: [PHP] Sessions: strange behaviour in 4.3.3 ?

2004-01-16 Thread Chris Shiflett
--- Dino Tsoumakis <[EMAIL PROTECTED]> wrote:
> If you hve a close look at the code
> http://www.serv-int.de/class.session.txt you will find the
> session_start() in the constructor of the class prior to any output.

This is apparently not the case, else this error message would not appear.

> The thing is, that session_start() calls the user defined session
> functions (defined in session_set_save_handler()) and that's what
> breaks the whole thing.

Keep in mind that an error message can count as output (if it's not logged
instead).

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



Re: [PHP] LOAD_FILE and PHP

2004-01-16 Thread Jough P
Greetings all, I'm still having problems with LOAD_FILE.  If anyone is 
using it and could post some examples that would be fabulous.

Thanks tons!!!

On Jan 16, 2004, at 9:12 AM, Jough P wrote:

Greetings all, I can't get LOAD_FILE to work in an INSERT statement 
from PHP.  The generated sql works when you're in mysql but won't work 
from PHP.

BSDB is my database object.
sql_query basically just does a mysql_query and some error outputting 
stuff.  There error is:
Column 'photo' cannot be null

My SQL statement is:
INSERT INTO photo VALUES('', 
LOAD_FILE("/Library/WebServer/Documents/var/tmp/default_smiley.png"))

The first column is an auto-increment id, the second column is the 
photo.

Here's a code snippet:

   $uploaddir = '/Library/WebServer/Documents/var/tmp/';
   $uploadfile = $uploaddir . $_FILES['userfile']['name'];
   if ($_FILES['userfile']['type'] == "image/jpeg" ||
   $_FILES['userfile']['type'] == "image/png" ||
   $_FILES['userfile']['type'] == "image/gif" )
   {
  if (move_uploaded_file($_FILES['userfile']['tmp_name'], 
$uploadfile))
  {
 print "File is valid, and was successfully uploaded. ";
 print "Here's some more debugging info:\n";
 print "";
 print_r($_FILES);
 print "";
 echo "";
 $bsdb = new BSDB();
 $sql = "INSERT INTO photo VALUES('', 
LOAD_FILE(\"$uploadfile\"))";
 echo "$sql\n";
 chmod($uploadfile,0755);
 $result = $bsdb->sql_query($sql);
  }
  else
  {
 print "Possible file upload attack! Here's some debugging 
info:\n";
 print "";
 print_r($_FILES);
 print "";
  }
   }

Thanks for your help!!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Syntax Error -> This is WEIRD!

2004-01-16 Thread Donald Tyler
Yes that is true. But I would strongly recommend against doing that.

You should never include anything over HTTP. Its extremely messy, 100%
insecure and just a very very bad idea.

You should have all the files you need to include located on your web
server.

-Original Message-
From: Dagfinn Reiersøl [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 16, 2004 11:50 AM
To: PHP General
Subject: Re: [PHP] Syntax Error -> This is WEIRD!

Donald Tyler wrote:

>Yes your right, that’s exactly the problem. I didn’t even realize he was
>doing that.
>
>By including the PHP file via HTTP, you are including the OUTPUT of the PHP
>file, not the actual PHP file itself.
>
>e.g.
>
>by including a file with the following code:
>
>
>   print 'Hello';
>
>?>
>
>you would be including the word "Hello" as PHP code, which is obviously
>going to cause a syntax error.
>  
>
Yes. I read the manual which provides no clear explanation (I suspect 
that whoever wrote it didn't actually know how it works). So I decided 
to test it. It does exactly what you say it does. I made an include file 
like this:

';
?>

If you inlude that using HTTP, it outputs "Hello world!"

Seems like a strange thing to do, outputting PHP code on a Web page, but 
it's not without conceivable usefulness.

>-Original Message-
>From: Dagfinn Reiersøl [mailto:[EMAIL PROTECTED] 
>Sent: Friday, January 16, 2004 10:18 AM
>To: PHP General
>Subject: Re: [PHP] Syntax Error -> This is WEIRD!
>
>Nick Wilson wrote:
>
>  
>
>>if a script calls antohter like 'include('http://site.com/index.php');
>>
>>Why would I get a syntax error on line 1 of index.php when it looks like
>>this:
>>
>>>// line one above this one
>>
>>
>>What's the deal there?
>>
>>Many thanks for any insight ;-)
>> 
>>
>>
>>
>I've never tried to do an include via HTTP, so maybe I'm clueless, but
>it occurs to me that it might be a good idea to try doing a plain old
>file include, using exactly the same file. I have the feeling it would
>be interesting to know whether that would work or not.
>
>  
>

-- 
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: server hanging on php site

2004-01-16 Thread Ben Ramsey
BK> PHP page causes the whole httpd to stop responding momentarily;
BK> no sites will load, those that are loading stop in the middle.
BK> But after say 30-45 seconds it continues just fine
> BR> First of all, make sure that display_errors in your php.ini
> BR> file is set to On.  I believe that the distribution file that
> BR> comes with PHP has it set to Off by default.  Once it's set
> BR> to On, see if you can get it to generate an error and post it.
>> BK> I've just tried setting that. I get absolutely no errors
>> BK> whatsoever. Could this be more of an Apache error?
I included part of your original message in here because it must've been 
a part that I skimmed over.  I didn't realize that you meant the entire 
httpd was stalling.  During that 30-45 seconds, no site pages will load 
at all?  What about after the 30-45 seconds?  Does the page that caused 
the stall continue processing, or does it time out?  It sounds to me 
like Apache is rebooting itself.

There're several factors here that need to be addressed: 1) is it a code 
problem (if so, what code is causing the problem and what's the 
error--perhaps check Apache's error log); 2) is it only happening on one 
page, several specific pages running similar code, or random pages; 3) 
does the code connect to a database (if so, what kind of database)?

I think you need to try to address these issues before you can continue 
debugging.  As it stands, it could be a problem with your code, with 
Apache, with a database, etc.  There're really no leads (that I can see) 
to give us a clue as to where the problem is.  Your best bet is to check 
the Apache error logs and see if an error is being generated and saved 
there.

Perhaps someone else could offer some better suggestions than I?

-Ben

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


Re: [PHP] mysql question

2004-01-16 Thread Miles Thompson
Christian,

I did a bit of digging in the MySQL docs to try and find the limits on 
number of fields in a table, etc. Didn't have much luck. I would not worry 
about thousands, or even hundreds of thousands of rows in a table for two 
reasons. First MySQL is becoming a heavier-duty database, and second, when 
the proper indexes are used it is blindingly fast at retrievals. Apparently 
the database engine also handles a large number of tables quite well.

When tables will be multiplying like bunnies, as you posit here, I foresee 
major code headaches.

I've thought about following type of design but have never implemented it. 
Might it work in your situation? Maybe this is what you are already doing, 
and I've just  relabelled it. If so, please accept my apologies.

Have standard tables for the basic stuff.: company, with co_key, address 
fields etc; products with prod_key, co_key, prod_name, etc.

Have two other tables, let's call them prod_descriptors and prod_data. 
We're violating one of Codd's principles here because the prod_data table 
has meaningless field names, just f1, f2, f3, f4 ... fn. How you sort out 
which data types to use is your business.

Prod_descriptors contains the meta information which makes prod_data 
useful. Its fields, at a minimum, would be prod_key, prod_characteristic, 
prod_data_field. For a given prod_key "M56H" there would be a record for 
each product characteristic which you have to track, and the field used in 
prod_data.

This may be a somewhat extreme example, as it is highly likely that there 
are a common characteristics for all products, so things would not have to 
be totally generalized. This design is also somewhat wasteful of disk 
space, but MySQL does a remarkable job, internally, of conserving space so 
it is used efficiently. The thorny issue of which data types to use in what 
columns hasn't been addressed either.

The crunch is whether or not you can ask questions of these tables and 
fetch the data you need.





At 12:52 PM 1/16/2004 +, Christian Calloway wrote:
Well let me try and describe a simplified version of what I am doing. I work
for a group of analysts, and they analyse technical products. Each products
has about 300+ fields associated with it, and each product is vastly
different from the other. Let's say the product "foo" has a table "fields"
associated with it, which describes each field in foo (its name,
description, type[float,boolean,text], order) and another table called
"data_foo" which is 300+ fields in length. Each record in "data_foo"
represents the technical specfiications of a single company/manufacturer. So
if there are 200+ companies, there will be at least one data_foo record
associated with it (in reality there is a one to many association between a
company and the number of technical specifications they have defined).There
are many different applications designed around the tables "foo" and
"data_foo", and course the relationships are slightly more involved, but I
digress. Each new product specification requires that I create a new table
to hold that data, and with new product specifications being created every
month, you see that the N number of tables will increase. If I store that
data in the "fields" table or create a table that has 1-many relationship
with it, I endup with thousands and thousands of records (Remember, each
product has 300+ fields associated with it, and each company has at least on
product specfication, and the N number of products continues to increase).
Any ideas?
"Miles Thompson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Christian,
>
> A red flag is flying.
>
> Usually, when people start talking about how the number of tables will
> multiply in an application, there is a problem with the design of data
> structures. If that's the case, now is the time to fix it.
>
> Miles
>
> At 05:35 PM 1/15/2004 +, Christian Calloway wrote:
> >Hey,
> >
> >Sorry to post a mysql question here, but I wanted an answer from a PHP
> >perspective. I am currently working on a database (for work) which
contains
> >40 tables, and will continue to expand. The reason for expansion of
tables
> >is to obscure to get into, but the relationships all do make sence. I
have
> >never worked on anything over like 50 tables, and I was wondering if I
> >should expect a performance hit, when say, I have 100 tables, 200 tables,
> >etc. Would it be wiser to break up the logical sections into there own
> >databases? Wouldn't that cause a bigger hit (to performance) with
multiple
> >tables from multiple databases being opened on every user query? Thanks
in
> >advance
> >
> >Christian
> >
> >--
> >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] Re: server hanging on php site

2004-01-16 Thread Bryan Koschmann - GKT
On Thu, 15 Jan 2004, Ben Ramsey wrote:
> First of all, make sure that display_errors in your php.ini file is set
> to On.  I believe that the distribution file that comes with PHP has it
> set to Off by default.  Once it's set to On, see if you can get it to
> generate an error and post it.

Ben,

I've just tried setting that. I get absolutely no errors whatsoever. Could
this be more of an Apache error?

Thanks,

Bryan

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



Re: [PHP] a clean way to upload

2004-01-16 Thread David T-G
Matt --

...and then Matt Hedges said...
% 
% Hello all,
% After playing around with the options, I've found that the following method
% for uploading something with constraints is the easiest...

I don't get it...  You have to upload in order to get to the server, so
all you're doing is returning the page saying "hey, you blew it; try
again".  Where is the 'ease of uploading'?


TIA & HTH & HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] PHP Apache Build Problem (Correction to original question)

2004-01-16 Thread pw


> /apache/source/path/src/modules/php4/
> /apache/source/path/src/include/ap_config.h:77:28: ap_config_auto.h: No
such
> file or directory

This goes away if I run 'configure' once for apache.
Then I carry on as in the previous post.

Sorry about my editing.

Peter

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



Re: [PHP] a clean way to upload

2004-01-16 Thread David T-G
Matt --

...and then Matt Hedges said...
% 
% ?

He's telling you to search the list archives.  This is not new ground
you're breaking here.

Just call getimagesize() on the temp file and see what type it reports
back.


HTH & HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


[PHP] PHP Apache Build Problem

2004-01-16 Thread pw
Hello,

I am trying to build php-4.3.3 into apache_1.3.28 as a module.
I configure php

--with-apache=/apache/source/path

and the php make process puts the source for mod_php4 into

/apache/source/path/src/modules/php4/
/apache/source/path/src/include/ap_config.h:77:28: ap_config_auto.h: No such
file or directory
I then configure apache with:

./configure --prefix=/usr/local/apache --add-module=src/modules/php4/mod_php
4.c

The apache autoconf configure script generates a Makefile with no errors.

When I try to build apache with 'make' everything compiles fine until the
build of mod_php4 comes up.

Make complains that it can't find headers:

===> src/modules/extra
gcc -c  -I../../os/unix -I../../include   -DLINUX=22 -DUSE_HSREGEX -DUSE_EXP
AT -I../../lib/expat-lite -DNO_DL_NEEDED `../../apaci` mod_php4.c
mod_php4.c:22:29: php_apache_http.h: No such file or directory
In file included from mod_php4.c:23:

What's wrong with my build?

Thanks for any info.

Peter

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



Re: [PHP] Syntax Error -> This is WEIRD!

2004-01-16 Thread Jason Wong
On Saturday 17 January 2004 01:50, Dagfinn Reiersøl wrote:

> Yes. I read the manual which provides no clear explanation (I suspect
> that whoever wrote it didn't actually know how it works). So I decided
> to test it. It does exactly what you say it does. I made an include file
> like this:

In defence of the manual writers, the manual says:

... the script is actually being run on the remote server and the *result* is 
then being included into the local script.

What is not clear about that?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The difficult we do today; the impossible takes a little longer.
*/

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



Re: [PHP] Regular Expression for Search/Replace

2004-01-16 Thread Tobias Engelhardt
Thanks, that solved the problem...



Mike Migurski wrote:

i hope someone can help me out... i have to replace


with

any ideas? thank you!


PCRE style:
'//'
replaced by ''.
-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

--

Teamnet GmbH

Technologiepark 20
33100 Paderborn
Tel.: 0 52 51 / 68 77 22
Fax: 0 52 51 / 68 77 21
www.teamnet.de
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] sorting multi-dimensional arrays

2004-01-16 Thread Mike Migurski
>I've read the manual several times on sorting multi-dimensional arrays,
>but I can't seem to wrap my mind around what I need to do to accomplish
>my goal.
>
>//this is what I'm doing: (stepping through a result set, and putting it
>into a multi-dimensional array.
>
>while ($row = mysql_fetch_array($result)) {
>   $docs[$counter][doc_id] = $row[doc_id];
>   $docs[$counter][doc_name] = $row[doc_name];
>   $docs[$counter][clinic_id] = $row[clinic_id];
>   $docs[$counter][clinic_name] = $row[clinic_name];
>   $counter++;
>} //end while
>
>//now, I want that array sorted by the clinic_name, and then doc_name.

Not to be a stinker, but why not just do the sorting in your mysql query?

select * from your_table order by clinic_name, doc_name;

If sorting in PHP is what you really need to do, the answer is to not use
array_multisort. Use usort() instead, with a function that compares
arguments based on clinic_name and doc_name (code untested):

function compare_docs($a, $b)
{
if($a['clinic_name'] === $b['clinic_name'])
return(strcmp($a['doc_name'], $b['doc_name']);
return(strcmp($a['clinic_name'], $b['clinic_name']);
}
while($row = mysql_fetch_array($result))
$docs[$counter++] = $row;
usort($docs, 'compare_docs');

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

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



[PHP] Re: sorting multi-dimensional arrays

2004-01-16 Thread Ben Ramsey
> //now, I want that array sorted by the clinic_name, and then
> doc_name.
>
> Can someone who has more currently active brain cells than me
> figure out what the array_multisort function call should look like?
In the documentation, I've found plenty of examples to do a 
multi-dimensional sort on one column, but not on two at the same time. 
My advice would be to do this sorting in your SQL statement.  "ORDER BY 
clinic_name, doc_name ASC" would accomplish the same thing.  Then, when 
you're in your while loop, it'll be added to the array in the proper 
order and you won't have to sort the array.

-Ben

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


Re: [PHP] mysql question

2004-01-16 Thread Christian Calloway
Well let me try and describe a simplified version of what I am doing. I work
for a group of analysts, and they analyse technical products. Each products
has about 300+ fields associated with it, and each product is vastly
different from the other. Let's say the product "foo" has a table "fields"
associated with it, which describes each field in foo (its name,
description, type[float,boolean,text], order) and another table called
"data_foo" which is 300+ fields in length. Each record in "data_foo"
represents the technical specfiications of a single company/manufacturer. So
if there are 200+ companies, there will be at least one data_foo record
associated with it (in reality there is a one to many association between a
company and the number of technical specifications they have defined).There
are many different applications designed around the tables "foo" and
"data_foo", and course the relationships are slightly more involved, but I
digress. Each new product specification requires that I create a new table
to hold that data, and with new product specifications being created every
month, you see that the N number of tables will increase. If I store that
data in the "fields" table or create a table that has 1-many relationship
with it, I endup with thousands and thousands of records (Remember, each
product has 300+ fields associated with it, and each company has at least on
product specfication, and the N number of products continues to increase).
Any ideas?

"Miles Thompson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Christian,
>
> A red flag is flying.
>
> Usually, when people start talking about how the number of tables will
> multiply in an application, there is a problem with the design of data
> structures. If that's the case, now is the time to fix it.
>
> Miles
>
> At 05:35 PM 1/15/2004 +, Christian Calloway wrote:
> >Hey,
> >
> >Sorry to post a mysql question here, but I wanted an answer from a PHP
> >perspective. I am currently working on a database (for work) which
contains
> >40 tables, and will continue to expand. The reason for expansion of
tables
> >is to obscure to get into, but the relationships all do make sence. I
have
> >never worked on anything over like 50 tables, and I was wondering if I
> >should expect a performance hit, when say, I have 100 tables, 200 tables,
> >etc. Would it be wiser to break up the logical sections into there own
> >databases? Wouldn't that cause a bigger hit (to performance) with
multiple
> >tables from multiple databases being opened on every user query? Thanks
in
> >advance
> >
> >Christian
> >
> >--
> >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] Sessions: strange behaviour in 4.3.3 ?

2004-01-16 Thread Dino Tsoumakis

"Chris Shiflett" <[EMAIL PROTECTED]> wrote
news:[EMAIL PROTECTED]
> --- Dino Tsoumakis <[EMAIL PROTECTED]> wrote:
> > Warning: session_start(): Cannot send session cache limiter - headers
> > already sent (output started at XX/class.session.php:61) in
> > XX/class.session.php on line 38
>
> You need to either put session_start() prior to any output (my preference)
> or use output buffering by putting ob_start() prior to any output.

If you hve a close look at the code http://www.serv-int.de/class.session.txt
you will find the session_start() in the constructor of the class prior to
any output.
The thing is, that session_start() calls the user defined session functions
(defined in session_set_save_handler()) and that's what breaks the whole
thing.
This is not a problem of session_start(), I'm pretty sure.
The problem is, the session id is not set in the open function, but it is
set in the read function.

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



Re: [PHP] Syntax Error -> This is WEIRD!

2004-01-16 Thread Dagfinn Reiersøl
Donald Tyler wrote:

Yes your right, that’s exactly the problem. I didn’t even realize he was
doing that.
By including the PHP file via HTTP, you are including the OUTPUT of the PHP
file, not the actual PHP file itself.
e.g.

by including a file with the following code:



	print 'Hello';

?>

you would be including the word "Hello" as PHP code, which is obviously
going to cause a syntax error.
 

Yes. I read the manual which provides no clear explanation (I suspect 
that whoever wrote it didn't actually know how it works). So I decided 
to test it. It does exactly what you say it does. I made an include file 
like this:

';
?>
If you inlude that using HTTP, it outputs "Hello world!"

Seems like a strange thing to do, outputting PHP code on a Web page, but 
it's not without conceivable usefulness.

-Original Message-
From: Dagfinn Reiersøl [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 16, 2004 10:18 AM
To: PHP General
Subject: Re: [PHP] Syntax Error -> This is WEIRD!

Nick Wilson wrote:

 

if a script calls antohter like 'include('http://site.com/index.php');

Why would I get a syntax error on line 1 of index.php when it looks like
this:

What's the deal there?

Many thanks for any insight ;-)

   

I've never tried to do an include via HTTP, so maybe I'm clueless, but
it occurs to me that it might be a good idea to try doing a plain old
file include, using exactly the same file. I have the feeling it would
be interesting to know whether that would work or not.
 

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


[PHP] sorting multi-dimensional arrays

2004-01-16 Thread Katie Dewees
Hi All,

I've read the manual several times on sorting multi-dimensional arrays, but
I can't seem to wrap my mind around what I need to do to accomplish my goal.

//this is what I'm doing: (stepping through a result set, and putting it
into a multi-dimensional array.

while ($row = mysql_fetch_array($result)) {
$docs[$counter][doc_id] = $row[doc_id];
$docs[$counter][doc_name] = $row[doc_name];
$docs[$counter][clinic_id] = $row[clinic_id];
$docs[$counter][clinic_name] = $row[clinic_name];
$counter++;
} //end while

//now, I want that array sorted by the clinic_name, and then doc_name.

Can someone who has more currently active brain cells than me figure out
what the array_multisort function call should look like?

Thanks in advance for any help proffered! It is greatly appreciated!

Katie Dewees
Web Developer
E-mail: [EMAIL PROTECTED]

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



Re: [PHP] Regular Expression for Search/Replace

2004-01-16 Thread Brad Pauly
On Fri, 2004-01-16 at 10:21, Brad Pauly wrote:
> On Fri, 2004-01-16 at 10:07, Tobias Engelhardt wrote:
> > That is not possible because the id's are hard-coded in thousands of 
> > html-pages. Not a very good idea, i know. It wasn't mine... I *have* to 
> > use search/replace. (A script processes each file in the directory)
> 
> Ah, I see. I think you could use str_replace (untested):
> 
> $a = 'order.php?order_id=';
> $b = 'order_';
> $c = '';
> 
> $new = str_replace($a, $b, $c).'.html';

Whewps. I just realized I didn't pull the '>' off the end.

- Brad

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



RE: [PHP] Syntax Error -> This is WEIRD!

2004-01-16 Thread Donald Tyler
Yes your right, that’s exactly the problem. I didn’t even realize he was
doing that.

By including the PHP file via HTTP, you are including the OUTPUT of the PHP
file, not the actual PHP file itself.

e.g.

by including a file with the following code:



you would be including the word "Hello" as PHP code, which is obviously
going to cause a syntax error.

-Original Message-
From: Dagfinn Reiersøl [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 16, 2004 10:18 AM
To: PHP General
Subject: Re: [PHP] Syntax Error -> This is WEIRD!

Nick Wilson wrote:

>if a script calls antohter like 'include('http://site.com/index.php');
>
>Why would I get a syntax error on line 1 of index.php when it looks like
>this:
>
>// line one above this one
>
>
>What's the deal there?
>
>Many thanks for any insight ;-)
>  
>
I've never tried to do an include via HTTP, so maybe I'm clueless, but
it occurs to me that it might be a good idea to try doing a plain old
file include, using exactly the same file. I have the feeling it would
be interesting to know whether that would work or not.

-- 
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] Regular Expression for Search/Replace

2004-01-16 Thread Brad Pauly
On Fri, 2004-01-16 at 10:07, Tobias Engelhardt wrote:
> That is not possible because the id's are hard-coded in thousands of 
> html-pages. Not a very good idea, i know. It wasn't mine... I *have* to 
> use search/replace. (A script processes each file in the directory)

Ah, I see. I think you could use str_replace (untested):

$a = 'order.php?order_id=';
$b = 'order_';
$c = '';

$new = str_replace($a, $b, $c).'.html';

- Brad

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



Re: [PHP] Regular Expression for Search/Replace

2004-01-16 Thread Mike Migurski
>i hope someone can help me out... i have to replace
>
>
>with
>
>
>any ideas? thank you!

PCRE style:
'//'
replaced by ''.

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

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



Re: [PHP] Regular Expression for Search/Replace

2004-01-16 Thread Tobias Engelhardt
That is not possible because the id's are hard-coded in thousands of 
html-pages. Not a very good idea, i know. It wasn't mine... I *have* to 
use search/replace. (A script processes each file in the directory)

Brad Pauly wrote:

What about just using the variable to build the name?

$file_name = 'order_'.$_GET['order_id'].'.html';

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


Re: [PHP] Regular Expression for Search/Replace

2004-01-16 Thread Brad Pauly
On Fri, 2004-01-16 at 09:49, Tobias Engelhardt wrote:
> Hi list,
> i hope someone can help me out... i have to replace
> 
> 
> with
> 
> 
> any ideas? thank you!

What about just using the variable to build the name?

$file_name = 'order_'.$_GET['order_id'].'.html';

- Brad

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



[PHP] Regular Expression for Search/Replace

2004-01-16 Thread Tobias Engelhardt
Hi list,
i hope someone can help me out... i have to replace

with

any ideas? thank you!

Tobias

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


Re: [PHP] getimagesize() to find type?

2004-01-16 Thread Matt Matijevich
[snip]
(1)  How would I do that (use getimagesize() instead to find type)?
[/snip]

http://php.net/getimagesize


[snip]
(2)  Stupid question:  how do I say

if ($_FILES['imagefile']['type'] != "image/pjpeg")

and add "image/jpeg" to that constraint?
[/snip]

there are many ways, I will show you an easy one

if ($_FILES['imagefile']['type'] != "image/pjpeg" &&
$_FILES['imagefile']['type'] != "image/jpeg")

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



Re: [PHP] Sessions: strange behaviour in 4.3.3 ?

2004-01-16 Thread Chris Shiflett
--- Dino Tsoumakis <[EMAIL PROTECTED]> wrote:
> Warning: session_start(): Cannot send session cache limiter - headers
> already sent (output started at XX/class.session.php:61) in
> XX/class.session.php on line 38

You need to either put session_start() prior to any output (my preference)
or use output buffering by putting ob_start() prior to any output.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



Re: [PHP] a clean way to upload

2004-01-16 Thread Matt Hedges
?


"Jason Wong" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Friday 16 January 2004 23:55, Matt Hedges wrote:
>
> > How would I do that?  I mean, what would I put instead of
> >
> > > > if ($_FILES['imagefile']['type'] != "image/pjpeg")
>
> > > the browser sets, it is more reliable to get the image type from
> > > getimagesize().
>
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> --
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> --
> /*
> Q: What is purple and commutes?
> A: An Abelian grape.
> */

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



Re: [PHP] LOAD_FILE and PHP

2004-01-16 Thread Jough P
I've tried a couple different paths and double checked them.  
Permissions are 755.  Like I said that exact same SQL statement inserts 
the correct record from the mysql command line.

mysql> INSERT INTO photo VALUES('', 
LOAD_FILE("/Library/WebServer/Documents/var/tmp/default_smiley.png"));

does what I want it to do.

On Jan 16, 2004, at 9:38 AM, John W. Holmes wrote:

Jough P wrote:

Greetings all, I can't get LOAD_FILE to work in an INSERT statement 
from PHP.  The generated sql works when you're in mysql but won't 
work from PHP.
BSDB is my database object.
sql_query basically just does a mysql_query and some error outputting 
stuff.  There error is:
Column 'photo' cannot be null
My SQL statement is:
INSERT INTO photo VALUES('', 
LOAD_FILE("/Library/WebServer/Documents/var/tmp/default_smiley.png"))
You're inserting two columns in your query, which one is "photo"? I 
assume the second, which means LOAD_FILE() is returning a NULL? (from 
your error message at least). The file must be world readable in order 
for MySQL to read it and insert it into the table. I assume you've 
doublechecked the path, also?? :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] Syntax Error -> This is WEIRD!

2004-01-16 Thread Dagfinn Reiersøl
Nick Wilson wrote:

if a script calls antohter like 'include('http://site.com/index.php');

Why would I get a syntax error on line 1 of index.php when it looks like
this:

What's the deal there?

Many thanks for any insight ;-)
 

I've never tried to do an include via HTTP, so maybe I'm clueless, but
it occurs to me that it might be a good idea to try doing a plain old
file include, using exactly the same file. I have the feeling it would
be interesting to know whether that would work or not.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] a clean way to upload

2004-01-16 Thread Jason Wong
On Friday 16 January 2004 23:55, Matt Hedges wrote:

> How would I do that?  I mean, what would I put instead of
>
> > > if ($_FILES['imagefile']['type'] != "image/pjpeg")

> > the browser sets, it is more reliable to get the image type from
> > getimagesize().

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Q:  What is purple and commutes?
A:  An Abelian grape.
*/

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



[PHP] getimagesize() to find type?

2004-01-16 Thread Matt Hedges
>On Friday 16 January 2004 10:32, Matt Hedges wrote:
>
>>> if ($_FILES['imagefile']['type'] != "image/pjpeg")
>
>The 'type' in $_FILES is provided by the browser. IIRC only IE uses
>"image/pjpeg" whilst other browsers use  "image/jpeg". But regardless of
what
>the browser sets, it is more reliable to get the image type from
>getimagesize().


(1)  How would I do that (use getimagesize() instead to find type)?



(2)  Stupid question:  how do I say

if ($_FILES['imagefile']['type'] != "image/pjpeg")

and add "image/jpeg" to that constraint?


thanks
Matt




-- 


-- 

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



Re: [PHP] dynamic array creation from form elements

2004-01-16 Thread Jon Bennett
nice one, solves my next problem as well if any elements are empty!

Cheers,

Jon

jon bennett  |  [EMAIL PROTECTED]
new media creative
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
J   b   e   n   .   n   e   t

91 Gloucester Rd,  Trowbridge,  Wilts,  BA14 0AD
t: +44 (0) 1225 341039 w: http://www.jben.net/
On 16 Jan 2004, at 15:47, John W. Holmes wrote:

Jon Bennett wrote:
Hi,
I've got a dynamically generated form and once it's submitted I need 
to _push the data from my form elements into an array so I can ad 
them to the db. My form elements are created like so:

$i = 1;
while ($i <= $iListItems){
?>

List Item :

Why don't you just skip the whole "$i" counter thing and name your 
input elements as "listItem[]" ? Name every one of them that; the same 
thing. Now when you submit your form, you'll already have an array, 
$_POST['listItem']. $_POST['listItem'][0] will be what was in the 
first one, $_POST['listItem'][1] in the second, etc.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.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] dynamic array creation from form elements

2004-01-16 Thread John W. Holmes
Jon Bennett wrote:
Hi,

I've got a dynamically generated form and once it's submitted I need to 
_push the data from my form elements into an array so I can ad them to 
the db. My form elements are created like so:



$i = 1;

while ($i <= $iListItems){

?>


List Item :

Why don't you just skip the whole "$i" counter thing and name your input 
elements as "listItem[]" ? Name every one of them that; the same thing. 
Now when you submit your form, you'll already have an array, 
$_POST['listItem']. $_POST['listItem'][0] will be what was in the first 
one, $_POST['listItem'][1] in the second, etc.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] Combining results - is there better way?

2004-01-16 Thread Miles Thompson
John,
Perfect. Don't know where my head was.
Miles
At 10:29 AM 1/16/2004 -0500, John W. Holmes wrote:
Miles Thompson wrote:
   } // foreach
My question is if there is a faster, cleaner way to do this? I did try 
array_search, but as it looks for any matching value anywhere in the 
target array the results it returned were not reliable.
If I'm understanding you correctly, I think this'll work:

SELECT c.nClassKey, c.Classification, COUNT(s.nClassKey) FROM 
classifications c LEFT JOIN subscribers s ON c.nClassKey = s.nClassKey 
GROUP BY c.nClassKey

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


Re: [PHP] a clean way to upload

2004-01-16 Thread Matt Hedges
Thanks Jason.

How would I do that?  I mean, what would I put instead of
> > if ($_FILES['imagefile']['type'] != "image/pjpeg")

thanks



"Jason Wong" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Friday 16 January 2004 10:32, Matt Hedges wrote:
>
> > if ($_FILES['imagefile']['type'] != "image/pjpeg")
>
> The 'type' in $_FILES is provided by the browser. IIRC only IE uses
> "image/pjpeg" whilst other browsers use  "image/jpeg". But regardless of
what
> the browser sets, it is more reliable to get the image type from
> getimagesize().
>
> -- 
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> --
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> --
> /*
> Pecor's Health-Food Principle:
> Never eat rutabaga on any day of the week that has a "y" in it.
> */

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



Re: [PHP] LOAD_FILE and PHP

2004-01-16 Thread John W. Holmes
Jough P wrote:

Greetings all, I can't get LOAD_FILE to work in an INSERT statement from 
PHP.  The generated sql works when you're in mysql but won't work from PHP.

BSDB is my database object.
sql_query basically just does a mysql_query and some error outputting 
stuff.  There error is:
Column 'photo' cannot be null

My SQL statement is:
INSERT INTO photo VALUES('', 
LOAD_FILE("/Library/WebServer/Documents/var/tmp/default_smiley.png"))
You're inserting two columns in your query, which one is "photo"? I 
assume the second, which means LOAD_FILE() is returning a NULL? (from 
your error message at least). The file must be world readable in order 
for MySQL to read it and insert it into the table. I assume you've 
doublechecked the path, also?? :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


[PHP] SOLVED => is ' or " different in MS-Word then ascII?

2004-01-16 Thread Roger Spears
Here is a real code solution instead of my original posted client 
solution

My original problem involved text submitted via the good old fashion 
 in a web form.  If a visitor created their text in MS-Word 
and then cut and paste their text over to the web form and submitted, 
any place within their text that they used ' or " would be turned into 
little white boxes.

After spending a day researching this problem, I realized I could just 
inform the visitors to turn off Smart Quotes in their word processor 
application.

Overcome with frustration and exhaustion, I posted this to the list as 
SOLVED and provided my client solution.  As many of you pointed out 
(thank you), it's not a valid solution for a large user base.  And as 
some pointed out (thank you), it's not a solution by any means...

Tom Rogers explained the problem and provided a code solution:
The problem is that Microsoft uses a non standard Latin-1 code for their 
"smart" quotes and a lot of programs don't know what to do with them as 
a few are actually control codes in other languages.


function clean_ms_word($text){
$crap = array( 
chr(0x82),chr(0x83),chr(0x84),chr(0x85),chr(0x86),chr(0x87),chr(0x88),chr(0x89), 

chr(0x8a),chr(0x8b),chr(0x8c),chr(0x91),chr(0x92),chr(0x93),chr(0x94),chr(0x95), 

chr(0x96),chr(0x97),chr(0x98),chr(0x99),chr(0x9a),chr(0x9b),chr(0x9c),chr(0x9f)
);
$clean = array( 
'‚','ƒ','„','&ldots;','†','‡','','‰', 

'Š','‹','Œ','‘','’','“','”','•', 

'–','—','˜','™','š','›','œ','Ÿ'
);
$content = str_replace($crap,$clean,$text);
return $content;
}
$string = chr(0x93).'Test'.chr(0x94);

echo clean_ms_word($string).'';

Thanks Tom!  Works like a charm!!  Also, thanks to everyone who offered 
tips, suggestions, and solutions...

R

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


Re: [PHP] Re: dynamic array creation from form elements

2004-01-16 Thread Jon Bennett
Hi Ben,

Sorry, it does work - so I can safely say you can concat the name of a 
associ array :-)

Thanks,

Jon

jon bennett  |  [EMAIL PROTECTED]
new media creative
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
J   b   e   n   .   n   e   t

91 Gloucester Rd,  Trowbridge,  Wilts,  BA14 0AD
t: +44 (0) 1225 341039 w: http://www.jben.net/
On 16 Jan 2004, at 15:38, Ben Ramsey wrote:

Try using $_POST["listItem$i"] instead of $_POST["listItem" . $i]
or do something like this:
$post_var_name = 'listItem' . $i;

this do $_POST[$post_var_name];

I don't think you can do any evaluation within the brackets.  Thus, 
you couldn't use the concatenating dot.

-Ben

--
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: dynamic array creation from form elements

2004-01-16 Thread Ben Ramsey
I don't think you can do any evaluation within the brackets.  Thus, you 
couldn't use the concatenating dot.
Nevermind... I am wrong on this.  But, I also completely missed that the 
code you have posted doesn't set $iListItems as Richard suggested.  So, 
go with his suggestion. :)

-Ben

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


Re: [PHP] dynamic array creation from form elements

2004-01-16 Thread Jon Bennett
Hi Rich,

$iListItems is set when a user chooses how many list elements they 
require (this is for the example pages I was asking about) and is 
always greater than 0 (we don't get this far in the script if it's 
not!).

Anyway, it was my silly fault, I had changed the name of my form 
elements whilst trying to fix it but hadn't gone back to the very 
begining in my browser so my loop was looking for the wrong post names! 
Doh!

Thanks,

Jon

jon bennett  |  [EMAIL PROTECTED]
new media creative
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
J   b   e   n   .   n   e   t

91 Gloucester Rd,  Trowbridge,  Wilts,  BA14 0AD
t: +44 (0) 1225 341039 w: http://www.jben.net/
On 16 Jan 2004, at 15:36, Richard Davey wrote:

Hello Jon,

Friday, January 16, 2004, 3:29:07 PM, you wrote:

JB> And after the form is submitted I assumed I could do this...

JB> $aListItems = array();

JB> $i = 1;

JB> while ($i <= $iListItems) {

JB>  $tempItem = $_POST["listItem" . $i];
JB>  array_push($aListItems, $tempItem);
JB>  ++$i;
JB> }
JB> print_r ($aListItems);

JB> but nothing appears to be added to the db, how can I access the 
$_POST
JB> vars within a loop ??

I can't see the whole script, so this is just guess work - but your
loop is checking to see if $i (1) is less than $iListItems, but as far
as I can see this isn't defined anywhere in your code, so the loop
will never actually go through because it's saying 1 <= 0.
Where is $iListItems set and to what value?

Your loop will work, but it's not obvious it's getting the chance to.

Also you don't need to array_push it, you could just do:

$aListItems[] = $tempItem;

--
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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


[PHP] Re: dynamic array creation from form elements

2004-01-16 Thread Ben Ramsey
Try using $_POST["listItem$i"] instead of $_POST["listItem" . $i]
or do something like this:
$post_var_name = 'listItem' . $i;

this do $_POST[$post_var_name];

I don't think you can do any evaluation within the brackets.  Thus, you 
couldn't use the concatenating dot.

-Ben

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


Re: [PHP] dynamic array creation from form elements

2004-01-16 Thread Richard Davey
Hello Jon,

Friday, January 16, 2004, 3:29:07 PM, you wrote:

JB> And after the form is submitted I assumed I could do this...

JB> $aListItems = array();

JB> $i = 1;

JB> while ($i <= $iListItems) {

JB> $tempItem = $_POST["listItem" . $i];
JB> array_push($aListItems, $tempItem);
JB> ++$i;
JB> }

JB> print_r ($aListItems);

JB> but nothing appears to be added to the db, how can I access the $_POST
JB> vars within a loop ??

I can't see the whole script, so this is just guess work - but your
loop is checking to see if $i (1) is less than $iListItems, but as far
as I can see this isn't defined anywhere in your code, so the loop
will never actually go through because it's saying 1 <= 0.

Where is $iListItems set and to what value?

Your loop will work, but it's not obvious it's getting the chance to.

Also you don't need to array_push it, you could just do:

$aListItems[] = $tempItem;

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] Combining results - is there better way?

2004-01-16 Thread John W. Holmes
Miles Thompson wrote:
This code works, but are there alternate, more efficient ways of doing 
it. A count of subscribers, by classification, has to be provided, where 
the classification definitions are in one table (class) with this 
structure:

   nClassKey - unique, numeric, autoincrement
   Classification - text ,name of the classification
   ClassDesc - text, description of the classification
and a nClassKey value is stored in each subscriber record.

As the version of MySQL used by my ISP lacks UNION capability, I'm 
fetching the necessary data with two SELECTS. The first retrieves 
nClassKey and Classification from the class table, and the results are 
put in an array, $arClass, where the $key is nClassKey and $value is 
Classification. Pretty straightforward, resulting in [1]=>Development, 
[2]=>Retailing ... [13]=>Agriculture.

For the count of classifications I used the following SELECT:

   select nClassKey, count(nClassKey) as classcount from subscriber 
group by nClassKey

and stick it in the array $arCount with this code:

   while ($myrow = mysql_fetch_array($result)) {
$arCount[$myrow["nClassKey"]] = $myrow["classcount"];
   }   

All of this works. Note that $arCount can be a sparse array; there may 
be instances of nClassKey missing from the subscriber table simply 
because no one happens to fall in the "aerospace" category, for example.

To generate a listing for display, I am using the following code to 
traverse the $arClass array, searching in the $arCount for a matching 
key, leaving out all the HTML stuff:

   foreach($arClass as $key => $value){
  print( $value .  ":  ");
  if (array_key_exists($key, $arCount)){
 print( $arCount[$key] );
  } else {
print( 0 );
  }
   } // foreach
My question is if there is a faster, cleaner way to do this? I did try 
array_search, but as it looks for any matching value anywhere in the 
target array the results it returned were not reliable.
If I'm understanding you correctly, I think this'll work:

SELECT c.nClassKey, c.Classification, COUNT(s.nClassKey) FROM 
classifications c LEFT JOIN subscribers s ON c.nClassKey = s.nClassKey 
GROUP BY c.nClassKey

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] dynamic array creation from form elements

2004-01-16 Thread Jon Bennett
Hi,

Sorry for the double post, meant to say 'but nothing appears to be 
added to the array' not the db!

Thanks,

Jon

jon bennett  |  [EMAIL PROTECTED]
new media creative
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
J   b   e   n   .   n   e   t

91 Gloucester Rd,  Trowbridge,  Wilts,  BA14 0AD
t: +44 (0) 1225 341039 w: http://www.jben.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


Re: [PHP] Schedule an Event with PHP

2004-01-16 Thread Jason Wong
On Friday 16 January 2004 23:25, Alex Pilson wrote:

> BTW. I didn't get what Stuart said about replying to an existing
> thread, did something screw up when I sent to the list?

He means:

You have started a new thread by taking an existing posting and replying to
it while you changed the subject.

That is bad, because it breaks threading. Whenever you reply to a message,
your mail client generates a "References:" header that tells all recipients
which posting(s) your posting refers to. A mail client uses this information
to build a threaded view ("tree view") of the postings.

With your posting style you successfully torpedoed this useful feature; your
posting shows up within an existing thread it has nothing to do with.

Always do a fresh post when you want to start a new thread. To achieve this,
click on "New message" instead of "Reply" within your mail client, and enter
the list address as the recipient. You can save the list address in your
address book for convenience.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Stock's Observation:
You no sooner get your head above water but what someone pulls
your flippers off.
*/

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



[PHP] dynamic array creation from form elements

2004-01-16 Thread Jon Bennett
Hi,

I've got a dynamically generated form and once it's submitted I need to 
_push the data from my form elements into an array so I can ad them to 
the db. My form elements are created like so:



$i = 1;

while ($i <= $iListItems){

?>


List Item :




++$i;
?>

And after the form is submitted I assumed I could do this...

$aListItems = array();

$i = 1;

while ($i <= $iListItems) {

$tempItem = $_POST["listItem" . $i];
array_push($aListItems, $tempItem);
++$i;
}
print_r ($aListItems);

but nothing appears to be added to the db, how can I access the $_POST 
vars within a loop ??

Thanks,

Jon

jon bennett  |  [EMAIL PROTECTED]
new media creative
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
J   b   e   n   .   n   e   t

91 Gloucester Rd,  Trowbridge,  Wilts,  BA14 0AD
t: +44 (0) 1225 341039 w: http://www.jben.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] /VAR is driving me crazy - SOLVED

2004-01-16 Thread Boaz Yahav
Actually i just found the problem.
My sysadmin recently added MOD Security and one of the lines that 
my conf file had was : 

SecFilter /var

Security people can drive me crazy :)

Sincerely
 
berber
 
Visit http://www.weberdev.com/ & http://www.weberblog.com/ Today!!!
To see where PHP might take you tomorrow.
Share your code : http://addexample.weberdev.com
Search for PHP Code from your browser http://toolbar.weberdev.com
Share your thoughts : http://www.weberblog.com/submit.php?type=story


-Original Message-
From: John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 16, 2004 5:07 PM
To: Boaz Yahav
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] /VAR is driving me crazy


Boaz Yahav wrote:
> Hi
> 
> Does anyone have an idea what is so special about the string "/VAR" ? 
> If i create a form that submits to a php file and in the form i put 
> the string /VAR anywhere in the text or just /VAR I get an 404 error 
> from apache on an existing
> file. If i take the same form and remove the /VAR string all is ok.
> 
> I'm not sure if this is an apache issue or PHP. Did anyone encounter 
> such a behavior?

The only thing I can think of is that if you're using GET as your form 
method and end up with something like:

www.domain.com/file.php?v=/VAR

then maybe for some odd reason you're web server is actually looking for

a path of "file.php?v=" and "VAR" instead of realizing the "/VAR" is in 
a query string. That shouldn't be happening, though.

-- 
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals - www.phparch.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] Syntax Error -> This is WEIRD!

2004-01-16 Thread Jeremy
Did the script accidently get saved in MS-DOS text format?

-Original Message-
From: Donald Tyler [mailto:[EMAIL PROTECTED]
Sent: Friday, January 16, 2004 8:53 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Syntax Error -> This is WEIRD!


There could be something you're not seeing and assuming it's correct.
But
typing your code into the email we aren't getting the full story.

Can you actually attach your scripts to an email and send that? Copying
and
pasting then into the email won't necessarily provide all the info
needed to
solve your problem.

For example: I once uploaded a PHP script to the server and for some
reason
on the way up extra character were placed in the document that did not
show
up in most text editors. I had to use a very basic terminal text editor
to
see the added characters.

-Original Message-
From: Nick Wilson [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 16, 2004 8:17 AM
To: php-general
Subject: [PHP] Syntax Error -> This is WEIRD!

if a script calls antohter like 'include('http://site.com/index.php');

Why would I get a syntax error on line 1 of index.php when it looks like
this:

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] Schedule an Event with PHP

2004-01-16 Thread Alex Pilson
At 9:44 AM -0500 1/16/04, John W. Holmes wrote:
Alex Pilson wrote:
Say I want a MySQL database to have a table that holds certain 
events, the Event table. And in the event table, one of the records 
is an event that has a startdate of today, I want to check against 
that date, if it equals now, then do this

Besides using CRON to hit that particular event table, is there any 
other method I am not thinking of that can be used with PHP? I want 
to check that event table every 5 minutes.
I guess you could write a PHP script that'll run continuously and 
check the database every 5 minutes, but you'd be better off (and 
probably use less resources) if you just used Cron/Task Scheduler.


Awesome feedback guys. And quick too. No I am not opposed to using 
cron, just was curious if there was anything else to use. With 
regards to ISPs that host PHP clients, what is the common practice to 
allow users to run cron scripts?

BTW. I didn't get what Stuart said about replying to an existing 
thread, did something screw up when I sent to the list?

Thanks for the help.
--
<--->
Alex Pilson
FlagShip Interactive, Inc.
[EMAIL PROTECTED]
<--->
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: PHP Includes and Echoes (From the top...)

2004-01-16 Thread Ford, Mike [LSS]
On 16 January 2004 13:54, Freedomware wrote:

> Thanks for all the tips. It's getting generally getting
> clearer, but I'm
> a little confused somewhere.

[SNIP] 

> I inserted one of the functions you suggested - $includea1 = TRUE; -
> after the include, but I'm sure I did it wrong.

Just like before -- put it *before* the include, otherwise the included file
won't see it.

[SNIP]

> //-->
> ';
> echo ' type="text/css" />'; if ($includea1) echo ' />'; 
> echo ' type="text/css" />'; echo ' title="Peace" />'; 
> echo '';
> echo ' href="../../../../us/aaa/favicon.ico" />'
> > 
> 
> Note that two of my style sheets are named css/a1.css and
> css/na/a1.css (na is short for North America). Maybe I should rename
> the 
> second a1 to
> avoid confusion, though I'd prefer to tackle it head on and
> learn how to
> deal with this situation. (Does $includea1 = TRUE; refer to css/a1.css
> or css/na/a1.css?)

Well, which one is controlled by the if ($includea1) test?

> 
> So here's what I have at present:
> 

Apart from the above points, looks ok for what you're trying to do.  Keep
plugging away and you'll get there -- a couple of years ago I was a complete
PHP beginner (although an experienced programmer), and now I have several
thousand lines of code in production use!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



[PHP] LOAD_FILE and PHP

2004-01-16 Thread Jough P
Greetings all, I can't get LOAD_FILE to work in an INSERT statement 
from PHP.  The generated sql works when you're in mysql but won't work 
from PHP.

BSDB is my database object.
sql_query basically just does a mysql_query and some error outputting 
stuff.  There error is:
Column 'photo' cannot be null

My SQL statement is:
INSERT INTO photo VALUES('', 
LOAD_FILE("/Library/WebServer/Documents/var/tmp/default_smiley.png"))

The first column is an auto-increment id, the second column is the 
photo.

Here's a code snippet:

   $uploaddir = '/Library/WebServer/Documents/var/tmp/';
   $uploadfile = $uploaddir . $_FILES['userfile']['name'];
   if ($_FILES['userfile']['type'] == "image/jpeg" ||
   $_FILES['userfile']['type'] == "image/png" ||
   $_FILES['userfile']['type'] == "image/gif" )
   {
  if (move_uploaded_file($_FILES['userfile']['tmp_name'], 
$uploadfile))
  {
 print "File is valid, and was successfully uploaded. ";
 print "Here's some more debugging info:\n";
 print "";
 print_r($_FILES);
 print "";
 echo "";
 $bsdb = new BSDB();
 $sql = "INSERT INTO photo VALUES('', 
LOAD_FILE(\"$uploadfile\"))";
 echo "$sql\n";
 chmod($uploadfile,0755);
 $result = $bsdb->sql_query($sql);
  }
  else
  {
 print "Possible file upload attack! Here's some debugging 
info:\n";
 print "";
 print_r($_FILES);
 print "";
  }
   }

Thanks for your help!!


Re: [PHP] /VAR is driving me crazy

2004-01-16 Thread John W. Holmes
Boaz Yahav wrote:
Hi

Does anyone have an idea what is so special about the string "/VAR" ?
If i create a form that submits to a php file and in the form i put the
string /VAR
anywhere in the text or just /VAR I get an 404 error from apache on an
existing
file. If i take the same form and remove the /VAR string all is ok.
I'm not sure if this is an apache issue or PHP. Did anyone encounter
such a behavior?
The only thing I can think of is that if you're using GET as your form 
method and end up with something like:

www.domain.com/file.php?v=/VAR

then maybe for some odd reason you're web server is actually looking for 
a path of "file.php?v=" and "VAR" instead of realizing the "/VAR" is in 
a query string. That shouldn't be happening, though.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] Non American strtotime

2004-01-16 Thread Bogdan Stancescu
John W. Holmes wrote:

Tom wrote:

The end user gets to chose their date format, and so if I cannot 
reverse their arbitrary date format into a timestamp then I have no 
chance of ensuring that dates are correct.

This seems like a really fundamentally bad thing about PHP :(


Seems like a fundamental flaw in your program. If the user enteres 
01/02/03, what date is that? 2003? January? February? 1st or 2nd?
February. 1st. It's assumed in his environment that the format is 
dd/mm/yy, just like it's probably assumed in your environment that it's 
mm/dd/yy (I presume that based on your time zone). If you're developing 
for an intranet for instance, then you can work with such assumptions.

What I find upsetting in Tom's attitude is his generosity in harsh 
words: "a really fundamentally bad thing about PHP" would be not being 
able to cope with this problem at all, but let's be serious, writing a 
short function (as previously exemplified for free via e-mail by 
third-parties) is not /such/ a big deal. It may be just me, but I never 
considered copy/pasting such a nauseating experience.

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


Re: [PHP] R: [PHP][PEAR] PEAR::DB_Common::nextId()

2004-01-16 Thread John W. Holmes
[EMAIL PROTECTED] wrote:

Hello

Not sure if you thought of it or if it even applies to you but when you 
use
PEAR::DB::getOnce("SELECT LAST_INSERT_ID()"); to retrieve the id do 
consider concurrent access to the database when using it for inserting 
stuff. Been there and its a hassle to resolve this little huge bug ; )
Consider the following situation:

Two users ( A and B) make simultaniouse access to your server. 
A queries the Database for an id
B queries the Database for an id
A writes stuff into the database using the retrieved id.
Now A and B both have the same id and if B wants to insert something into 
the db using id it will fail if id has to be unique (like in a primary 
key, foreign key, etc...)
B has to querie the database for the correct id again. 

So make sure you read lock the table for the query and the insert or make 
sure you never use the retrieved id for inserting stuff. 
You are very confused. User A and User B are on different connections 
and LAST_INSERT_ID() is connection specific _and_ you only use it 
_after_ you make an INSERT. It will return the last auto_increment 
generated number on a _per connection_ basis.

So User A INSERTS, User B INSERTS, then they each call LAST_INSERT_ID(), 
they'll get their own number from their own INSERT. You then use the 
number in subsequent INSERTs to maintain relationships.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


Re: [PHP] Non American strtotime

2004-01-16 Thread John W. Holmes
Tom wrote:
Is there a way I can force PHP's time functions not to read date strings
in the American MM-DD- format?
If you read the strtotime() manual page, there is a link to this page: 
http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html which 
gives you all of the formats that are accepted. If your format isn't 
listed, then you're out of luck or modifying source code to the 
strtotime() function (more than likely).

I am using strtotime and strftime and date at various points (mainlty to
avoid some niggly 0/NULL problems between PHP and mySQL
and datefields).
Give an example of your queries... why are 0/NULL rows causing problems? 
You should be able to do everything in your query or use TO_UNIXTIME().

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


[PHP] aggregate, parent::

2004-01-16 Thread Veres Lajos
Hello,

When I use an aggregated variable, how parent:: is defined?
(in perl: SUPER:: or NEXT::)
parent of the current classes, or parent of the original class?

(PS: I'm not in list, please CC: me)

Veres Lajos
[EMAIL PROTECTED]
+36 20 438 5909

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



  1   2   >