php-general Digest 7 May 2002 06:58:51 -0000 Issue 1330

Topics (messages 96302 through 96359):

Re: Grabbing ALL $_POST var at once.
        96302 by: Rasmus Lerdorf
        96303 by: Miguel Cruz
        96305 by: 1LT John W. Holmes
        96306 by: David J Jackson
        96307 by: David J Jackson
        96308 by: Miguel Cruz
        96309 by: Kevin Stone
        96310 by: 1LT John W. Holmes
        96316 by: Philip Olson

Re: function over loading?
        96304 by: J Smith

Sorting, sort of
        96311 by: Jason Soza
        96312 by: Analysis & Solutions
        96313 by: Austin Marshall
        96314 by: 1LT John W. Holmes
        96315 by: Tyler Longren
        96317 by: Jason Soza
        96318 by: 1LT John W. Holmes
        96337 by: David Freeman

question with sockets and XML
        96319 by: Michael Geier

escaping quotes in forms and redisplaying variables in form fields
        96320 by: John Hughes
        96321 by: Robert Cummings
        96322 by: 1LT John W. Holmes

Re: Very Large MySQL Query String
        96323 by: David Bouw
        96324 by: Javier

LDAP
        96325 by: J. Anderson Scarbrough
        96329 by: Jon Wahl

Alternate To Making Form Variables Global
        96326 by: Dr. Shim

Alternate To Making Form Variables Global (Clerified)
        96327 by: Dr. Shim
        96328 by: Julio Nobrega Trabalhando
        96330 by: Austin Marshall
        96334 by: Dr. Shim

Linux and permissions
        96331 by: Todd Cary
        96332 by: Craig Vincent
        96333 by: Todd Cary
        96342 by: Paras Mukadam

Re: Formatting Information in header? Gridlines in Excel
        96335 by: David Freeman
        96348 by: Paul Roberts

file_exists
        96336 by: Craig Westerman
        96343 by: Austin Marshall
        96344 by: Craig Westerman
        96345 by: Austin Marshall
        96347 by: Jonathan Rosenberg
        96351 by: Miguel Cruz
        96353 by: Rasmus Lerdorf
        96359 by: Stuart Dallas

Re: File upload problem
        96338 by: David Freeman
        96354 by: Jason Wong
        96358 by: David Freeman

Re: Redirect after submit
        96339 by: David Freeman

Re: --enabel-pnctl / php sockets
        96340 by: Barry Smoke

Is the browser still open? if not then I want to kill the script
        96341 by: Jarrad Kabral
        96346 by: 1LT John W. Holmes

Free Hosting /w PHP/MySQL  {!?}
        96349 by: Liam MacKenzie

Re: PHP compared to JSP
        96350 by: Manuel Lemos

Where is the file php_mssql.dll?
        96352 by: Jim Wentz

Re: Variables from XML Documents
        96355 by: Sebastian A.
        96356 by: Analysis & Solutions
        96357 by: Martin Towell

Administrivia:

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

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

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


----------------------------------------------------------------------
--- Begin Message ---
See either extract() or import_request_variables() in the manual.

-Rasmus

On Mon, 6 May 2002, David J Jackson wrote:

> The code below works (but its ugly), but I know there has to be a why to
> grab all the $_POST[] at once and then parse them out?
>
> Isn't there a why for me to access them directory without reassigning them?
>
> TIH,
> David
>
>
> <?php
> $From = $_POST['from'];
> $Two = $_POST['two'];
> $Subject = $_POST['sub_ject'];
> $Comments = $_POST['comments'];
> echo "<b>$From</b>";print "\n";
> echo $Two;print "\n";
> echo $Subject;print"\n";
> echo $Comments;print "\n";
> ?>
> <?php mail($Two,$Subject,$Comments) ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
On Mon, 6 May 2002, David J Jackson wrote:
> The code below works (but its ugly), but I know there has to be a why to 
> grab all the $_POST[] at once and then parse them out?
> 
> Isn't there a why for me to access them directory without reassigning them?

They're just variables. You can print them or use them as function 
arguments...

<? mail ($_GET['to'], $_GET['subject'], "Hey, {$_GET['comments']}") ?>

miguel

> <?php
> $From = $_POST['from'];
> $Two = $_POST['two'];
> $Subject = $_POST['sub_ject'];
> $Comments = $_POST['comments'];
> echo "<b>$From</b>";print "\n";
> echo $Two;print "\n";
> echo $Subject;print"\n";
> echo $Comments;print "\n";
> ?>
> <?php mail($Two,$Subject,$Comments) ?>
> 
> 
> 

--- End Message ---
--- Begin Message ---
> <?php
> $From = $_POST['from'];
> $Two = $_POST['two'];
> $Subject = $_POST['sub_ject'];
> $Comments = $_POST['comments'];
> echo "<b>$From</b>";print "\n";
> echo $Two;print "\n";
> echo $Subject;print"\n";
> echo $Comments;print "\n";
> ?>
> <?php mail($Two,$Subject,$Comments) ?>

Why do you waste time assigning a variable to a variable...Is it really that
hard to just use the $_POST array?

<?php
echo "<b>" . $_POST["from"] . "</b>\n";
echo $_POST["two"] . "\n";
echo $_POST["sub_ject"] . "\n";
echo $_POST["comments"] . "\n";
mail($_POST["two"],$_POST["sub_ject"],$_POST["comments"]);
?>

If that's too hard to understand, use extract().

---John Holmes...

--- End Message ---
--- Begin Message ---
Rasmus Lerdorf wrote:
> See either extract() or import_request_variables() in the manual.

Rasmus --
I appreciate you taking the time to reply to my posting.

David

--- End Message ---
--- Begin Message ---
John ---
Thanks for your reply, but let me rephase the question.
Let say I have a form with 50 fields on it do I have to:

echo $_POST['one']
....
.....
.....
echo $POST['fifty']


Or should I, could I use extract()?

Thanks in advance,
David

p.s I said it was UGLY :)


> ?>
> 
> If that's too hard to understand, use extract().
> 
> ---John Holmes...
> 



--- End Message ---
--- Begin Message ---
On Mon, 6 May 2002, David J Jackson wrote:
> Thanks for your reply, but let me rephase the question.
> Let say I have a form with 50 fields on it do I have to:
> 
> echo $_POST['one']
> ....
> .....
> .....
> echo $POST['fifty']
> 
> 
> Or should I, could I use extract()?

You can use extract if you want, but be careful, because it has security 
implications. Make sure you explicitly declare starting values for all 
non-user-supplied variables within that scope at some point after calling 
extract.

miguel

--- End Message ---
--- Begin Message ---
Do you simply need to view all of the values passed through the form?  In
that case try something like..

foreach ($_POST as $name => $value)
{
    echo $name." : ".$value."<br>";
}

-Kevin

----- Original Message -----
From: "David J Jackson" <[EMAIL PROTECTED]>
To: "1LT John W. Holmes" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 1:07 PM
Subject: Re: [PHP] Grabbing ALL $_POST var at once.


> John ---
> Thanks for your reply, but let me rephase the question.
> Let say I have a form with 50 fields on it do I have to:
>
> echo $_POST['one']
> ....
> .....
> .....
> echo $POST['fifty']
>
>
> Or should I, could I use extract()?
>
> Thanks in advance,
> David
>
> p.s I said it was UGLY :)
>
>
> > ?>
> >
> > If that's too hard to understand, use extract().
> >
> > ---John Holmes...
> >
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message ---
extract() wouldn't do you any good here, you'd still have to use echo $one,
echo $two, etc...so what are you gaining?

If you just want the values displayed, use the foreach() method someone
already posted. You can use implode() to combine the whole array in to a
single string...if you need something more than that, let us know. With that
many elements, maybe it's time to rethink your layout or naming conventions.

---John Holmes...

----- Original Message -----
From: "David J Jackson" <[EMAIL PROTECTED]>
To: "1LT John W. Holmes" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 3:07 PM
Subject: Re: [PHP] Grabbing ALL $_POST var at once.


> John ---
> Thanks for your reply, but let me rephase the question.
> Let say I have a form with 50 fields on it do I have to:
>
> echo $_POST['one']
> ....
> .....
> .....
> echo $POST['fifty']
>
>
> Or should I, could I use extract()?
>
> Thanks in advance,
> David
>
> p.s I said it was UGLY :)
>
>
> > ?>
> >
> > If that's too hard to understand, use extract().
> >
> > ---John Holmes...
> >
>
>
>

--- End Message ---
--- Begin Message ---

As you know, $_POST exists.  You can also assign
groups of names to an array through your HTML form
like so:

  <input type="text" name="bar[name]">
  <input type="text" name="bar[doh]">
  ...

And then play with them, for example:

  extract($_POST['bar']);
  print "I say $name and $doh";

  extract($_POST['bar'], EXTR_PREFIX_ALL, 'bar');
  print "I say $bar_name and $bar_doh";

extract() is a pretty cool function with many
options, read about extract here:

  http://www.php.net/extract

And as already stated by others,
import_request_variables() and $_REQUEST exist too.

Regards,
Philip Olson




On Mon, 6 May 2002, 1LT John W. Holmes wrote:

> extract() wouldn't do you any good here, you'd still have to use echo $one,
> echo $two, etc...so what are you gaining?
> 
> If you just want the values displayed, use the foreach() method someone
> already posted. You can use implode() to combine the whole array in to a
> single string...if you need something more than that, let us know. With that
> many elements, maybe it's time to rethink your layout or naming conventions.
> 
> ---John Holmes...
> 
> ----- Original Message -----
> From: "David J Jackson" <[EMAIL PROTECTED]>
> To: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Monday, May 06, 2002 3:07 PM
> Subject: Re: [PHP] Grabbing ALL $_POST var at once.
> 
> 
> > John ---
> > Thanks for your reply, but let me rephase the question.
> > Let say I have a form with 50 fields on it do I have to:
> >
> > echo $_POST['one']
> > ....
> > .....
> > .....
> > echo $POST['fifty']
> >
> >
> > Or should I, could I use extract()?
> >
> > Thanks in advance,
> > David
> >
> > p.s I said it was UGLY :)
> >
> >
> > > ?>
> > >
> > > If that's too hard to understand, use extract().
> > >
> > > ---John Holmes...
> > >
> >
> >
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---

Sort of. Look at the extension "overload" in the ext directory of the PHP 
source. Enable it and check out the docs:

http://www.php.net/manual/en/ref.overload.php

J



Kris Vose wrote:

> Can you practice function over-loading in php?
>  
> Kris

--- End Message ---
--- Begin Message ---
I have a 'name' field in a MySQL table that contains people's first and 
last names, i.e. "John Smith" - but some people may choose not to 
include their last name, so they're just "John" in the table, or they 
may choose to include themselves and someone else, but not the last 
name, "John and Jane".

I'm thinking the easiest way to sort by last name, which is what I want 
to do, is to just go into MySQL and make 'first_name' and 'last_name' 
fields, but if there's a way to do this with PHP that'd be great, so 
then I wouldn't have to mess with the table and data.

Anyhow, I've looked up sort() and asort() in the PHP manual, but I'm 
not sure how I'd go about this. I assume I'd use some kind of function 
to read the 'name' field to the first space, take what it finds after 
the space and put it into an array, then have some if/else statement to 
deal with the lack of a space or the presence of multiple spaces, then 
use sort() on that array. 

Just looking for some guidance, maybe a specific function or bit of 
code. Anything that'd help. Or if this would be more easily addressed 
by reconfiguring my MySQL table, just let me know.

Thanks,
Jason Soza

--- End Message ---
--- Begin Message ---
On Mon, May 06, 2002 at 11:25:03AM -0800, Jason Soza wrote:
> I have a 'name' field in a MySQL table that contains people's first and 
> last names,
> ... snip ...
> I'm thinking the easiest way to sort by last name, which is what I want 
> to do, is to just go into MySQL and make 'first_name' and 'last_name' 
> fields, but if there's a way to do this with PHP that'd be great

No, it wouldn't.  You'd be wasting a lot of time and memory.  Do the job 
right.  Separate the fields.

If you already have a large dataset, you can use PHP to do the initial
separation, but it'll be a pain.

--Dan

-- 
               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409
--- End Message ---
--- Begin Message ---
Jason Soza wrote:
> I have a 'name' field in a MySQL table that contains people's first and 
> last names, i.e. "John Smith" - but some people may choose not to 
> include their last name, so they're just "John" in the table, or they 
> may choose to include themselves and someone else, but not the last 
> name, "John and Jane".
> 
> I'm thinking the easiest way to sort by last name, which is what I want 
> to do, is to just go into MySQL and make 'first_name' and 'last_name' 
> fields, but if there's a way to do this with PHP that'd be great, so 
> then I wouldn't have to mess with the table and data.
> 
> Anyhow, I've looked up sort() and asort() in the PHP manual, but I'm 
> not sure how I'd go about this. I assume I'd use some kind of function 
> to read the 'name' field to the first space, take what it finds after 
> the space and put it into an array, then have some if/else statement to 
> deal with the lack of a space or the presence of multiple spaces, then 
> use sort() on that array. 
> 
> Just looking for some guidance, maybe a specific function or bit of 
> code. Anything that'd help. Or if this would be more easily addressed 
> by reconfiguring my MySQL table, just let me know.
> 
> Thanks,
> Jason Soza
> 

via MySQL you can search by and order/sort by a substring'ed result.  Of 
course, when someone only puts one name or they enter multiple first 
names, it doesn't work quite the way it's supposed to.

For what i do, the following query returns the first letter of the last 
name in alphabetical order.

SELECT substring(substring_index(fullname,' ',-1),1,1)
FROM user
GROUP BY substring(substring_index(fullname,' ',-1),1,1)
ORDER by substring_index(fullname,' ',-1) ASC

There is a demo at http://www.defconzero.com/user.php?op=view

Hope that provides some insight.

--- End Message ---
--- Begin Message ---
You _definetly_ want to do this in your database, not with PHP and arrays.
Databases are made to do this kind of sorting for you.

I would modify your table first, adding in another column for first_name,
then modify your form so that all data going in from now on is correct. The
hard part will be getting the data you have now into the correct format. How
big of a table are we talking?

---John Holmes...

----- Original Message -----
From: "Jason Soza" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 3:25 PM
Subject: [PHP] Sorting, sort of


> I have a 'name' field in a MySQL table that contains people's first and
> last names, i.e. "John Smith" - but some people may choose not to
> include their last name, so they're just "John" in the table, or they
> may choose to include themselves and someone else, but not the last
> name, "John and Jane".
>
> I'm thinking the easiest way to sort by last name, which is what I want
> to do, is to just go into MySQL and make 'first_name' and 'last_name'
> fields, but if there's a way to do this with PHP that'd be great, so
> then I wouldn't have to mess with the table and data.
>
> Anyhow, I've looked up sort() and asort() in the PHP manual, but I'm
> not sure how I'd go about this. I assume I'd use some kind of function
> to read the 'name' field to the first space, take what it finds after
> the space and put it into an array, then have some if/else statement to
> deal with the lack of a space or the presence of multiple spaces, then
> use sort() on that array.
>
> Just looking for some guidance, maybe a specific function or bit of
> code. Anything that'd help. Or if this would be more easily addressed
> by reconfiguring my MySQL table, just let me know.
>
> Thanks,
> Jason Soza
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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

I'd just get it over with and make first_name and last_name fields in your
table.  It will be so much easier to sort by last name that way.  I do it
this way everytime.  It won't take much time to implement either.

Good luck,
Tyler Longren
Captain Jack Communications
[EMAIL PROTECTED]
www.captainjack.com

----- Original Message -----
From: "Jason Soza" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 2:25 PM
Subject: [PHP] Sorting, sort of


> I have a 'name' field in a MySQL table that contains people's first and
> last names, i.e. "John Smith" - but some people may choose not to
> include their last name, so they're just "John" in the table, or they
> may choose to include themselves and someone else, but not the last
> name, "John and Jane".
>
> I'm thinking the easiest way to sort by last name, which is what I want
> to do, is to just go into MySQL and make 'first_name' and 'last_name'
> fields, but if there's a way to do this with PHP that'd be great, so
> then I wouldn't have to mess with the table and data.
>
> Anyhow, I've looked up sort() and asort() in the PHP manual, but I'm
> not sure how I'd go about this. I assume I'd use some kind of function
> to read the 'name' field to the first space, take what it finds after
> the space and put it into an array, then have some if/else statement to
> deal with the lack of a space or the presence of multiple spaces, then
> use sort() on that array.
>
> Just looking for some guidance, maybe a specific function or bit of
> code. Anything that'd help. Or if this would be more easily addressed
> by reconfiguring my MySQL table, just let me know.
>
> Thanks,
> Jason Soza
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
It's actually not that large of a table, but it'll still be a PITA to 
get all of the data reinserted.

I have about 50 records with the following fields:
'gen', 'year', 'color', 'name', 'email', 'location', 'misc', 'pic1', 'pi
c2', 'pic3', 'pic4'

So basically, I guess I want to rename 'name' to 'first_name', add 
another column for 'last name', then update each record to separate the 
first and last names into their respective columns, eh?

I suppose the easiest way is to save/export the table as a tab-
delimited txt file, make my first/last name changes that way, change 
the layout of the table, then update the table using the new txt file?

Sorry for the newbie (and MySQL) questions - I'm not a programmer or DB 
admin by trade, just volunteered to make a website and got caught up 
with PHP and MySQL. I'm learning, really I am! (And having fun too!)

Jason Soza

----- Original Message -----
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
Date: Monday, May 6, 2002 11:46 am
Subject: Re: [PHP] Sorting, sort of

> You _definetly_ want to do this in your database, not with PHP and 
> arrays.Databases are made to do this kind of sorting for you.
> 
> I would modify your table first, adding in another column for 
> first_name,then modify your form so that all data going in from 
> now on is correct. The
> hard part will be getting the data you have now into the correct 
> format. How
> big of a table are we talking?
> 
> ---John Holmes...

--- End Message ---
--- Begin Message ---
Yeah, just dump it, edit it, and import it back into a table. 50 records
shouldn't take you to long. You'll thank yourself later.. :)

---John Holmes...

----- Original Message -----
From: "Jason Soza" <[EMAIL PROTECTED]>
To: "1LT John W. Holmes" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 3:56 PM
Subject: Re: [PHP] Sorting, sort of


> It's actually not that large of a table, but it'll still be a PITA to
> get all of the data reinserted.
>
> I have about 50 records with the following fields:
> 'gen', 'year', 'color', 'name', 'email', 'location', 'misc', 'pic1', 'pi
> c2', 'pic3', 'pic4'
>
> So basically, I guess I want to rename 'name' to 'first_name', add
> another column for 'last name', then update each record to separate the
> first and last names into their respective columns, eh?
>
> I suppose the easiest way is to save/export the table as a tab-
> delimited txt file, make my first/last name changes that way, change
> the layout of the table, then update the table using the new txt file?
>
> Sorry for the newbie (and MySQL) questions - I'm not a programmer or DB
> admin by trade, just volunteered to make a website and got caught up
> with PHP and MySQL. I'm learning, really I am! (And having fun too!)
>
> Jason Soza
>
> ----- Original Message -----
> From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> Date: Monday, May 6, 2002 11:46 am
> Subject: Re: [PHP] Sorting, sort of
>
> > You _definetly_ want to do this in your database, not with PHP and
> > arrays.Databases are made to do this kind of sorting for you.
> >
> > I would modify your table first, adding in another column for
> > first_name,then modify your form so that all data going in from
> > now on is correct. The
> > hard part will be getting the data you have now into the correct
> > format. How
> > big of a table are we talking?
> >
> > ---John Holmes...
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---

 > -----Original Message-----
 > I have about 50 records with the following fields:
 > 'gen', 'year', 'color', 'name', 'email', 'location', 'misc', 
 > 'pic1', 'pi c2', 'pic3', 'pic4'
 > -----Original Message-----

If you're going to be changing your database, you might also consider
what to do with 'picX'.  As it stands you've got a max of four pics, but
what if you later decide on a max of 5 or reducing it to 3?

I'd actually separate them out to their own table and just have an ID
reference that points them to your user data and the 'picX' data as the
second field.

The you can use a join to get all the information and you aren't limited
by your database structure to any set number of 'pic' records.

...and now that I'm completely off-topic I think I'll finish here.

CYA, Dave


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

I have to do the following:
        open a socket to an external server
        authenticate on that server
        begin retrieving articles and write to local files

I am able to connect the server via Net/Sockets.php and authenticate.

Now the tricky part...the data is fed via an XML format...

I would like to say "start reading lines starting with <tag> until line
containing </tag>"
then, take that information and write it to a file.

The problem is that the articles are not fixed length.
Any help appreciated.

---
Michael

--- End Message ---
--- Begin Message ---
I'm stumbling over how to allow people to put single or double quotes
in a form text field. 

I am passing the form to itself ($PHP_SELF) and on the second time
through previewing what the form data will look like and also
re-creating the form with the data already filled in.

Here's an example of one text field:

$display_line .="<input type='text' name='signature'
value='$noslash_signature' size='35' maxlength='100'>";

(I have stripslashes() the $signature variable to create
$noslash_signature.)

If someone signs their name O'Brien, the preview shows O'Brien, but
all that shows in the form field is O. However, Joe "Bruiser" Jones
displays correctly in preview and the form.

If I change the code like this (adding the \" around the variable): 

$display_line .="<input type='text' name='signature'
value=\"$noslash_signature\" size='35' maxlength='100'>";

O'Brien will display OK, but Joe "Bruiser" Jones shows just Joe in
the form field.

One solution is to change the text form to textarea, but I'd prefer
to be able to redisplay at text form field if possible.

TIA,
John Hughes

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
--- End Message ---
--- Begin Message ---
See: http://www.php.net/manual/en/function.htmlspecialchars.php

John Hughes wrote:
> 
> I'm stumbling over how to allow people to put single or double quotes
> in a form text field.
> 
> I am passing the form to itself ($PHP_SELF) and on the second time
> through previewing what the form data will look like and also
> re-creating the form with the data already filled in.
> 
> Here's an example of one text field:
> 
> $display_line .="<input type='text' name='signature'
> value='$noslash_signature' size='35' maxlength='100'>";
> 
> (I have stripslashes() the $signature variable to create
> $noslash_signature.)
> 
> If someone signs their name O'Brien, the preview shows O'Brien, but
> all that shows in the form field is O. However, Joe "Bruiser" Jones
> displays correctly in preview and the form.
> 
> If I change the code like this (adding the \" around the variable):
> 
> $display_line .="<input type='text' name='signature'
> value=\"$noslash_signature\" size='35' maxlength='100'>";
> 
> O'Brien will display OK, but Joe "Bruiser" Jones shows just Joe in
> the form field.
> 
> One solution is to change the text form to textarea, but I'd prefer
> to be able to redisplay at text form field if possible.

-- 
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer  |
:----------------------------------------------:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109                 |
:----------------------------------------------:
| Website : http://www.webmotion.com           |
| Fax     : (613) 260-9545                     |
`----------------------------------------------'
--- End Message ---
--- Begin Message ---
Yeah, you have to convert the single and double quotes to html entities so
they are not mistaken for the end of the string.

If you look at your source code, you'll see why it's happening.

value = 'O'Bryan'
value = "Joe "Bruiser" Smith"

You can see how the 'O' is taken as the string, and the rest is ignored.
Same for the double quotes.

---John Holmes...

----- Original Message -----
From: "Robert Cummings" <[EMAIL PROTECTED]>
To: "John Hughes" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 5:06 PM
Subject: Re: [PHP] escaping quotes in forms and redisplaying variables in
form fields


> See: http://www.php.net/manual/en/function.htmlspecialchars.php
>
> John Hughes wrote:
> >
> > I'm stumbling over how to allow people to put single or double quotes
> > in a form text field.
> >
> > I am passing the form to itself ($PHP_SELF) and on the second time
> > through previewing what the form data will look like and also
> > re-creating the form with the data already filled in.
> >
> > Here's an example of one text field:
> >
> > $display_line .="<input type='text' name='signature'
> > value='$noslash_signature' size='35' maxlength='100'>";
> >
> > (I have stripslashes() the $signature variable to create
> > $noslash_signature.)
> >
> > If someone signs their name O'Brien, the preview shows O'Brien, but
> > all that shows in the form field is O. However, Joe "Bruiser" Jones
> > displays correctly in preview and the form.
> >
> > If I change the code like this (adding the \" around the variable):
> >
> > $display_line .="<input type='text' name='signature'
> > value=\"$noslash_signature\" size='35' maxlength='100'>";
> >
> > O'Brien will display OK, but Joe "Bruiser" Jones shows just Joe in
> > the form field.
> >
> > One solution is to change the text form to textarea, but I'd prefer
> > to be able to redisplay at text form field if possible.
>
> --
> .-----------------.
> | Robert Cummings |
> :-----------------`----------------------------.
> | Webdeployer - Chief PHP and Java Programmer  |
> :----------------------------------------------:
> | Mail  : mailto:[EMAIL PROTECTED] |
> | Phone : (613) 731-4046 x.109                 |
> :----------------------------------------------:
> | Website : http://www.webmotion.com           |
> | Fax     : (613) 260-9545                     |
> `----------------------------------------------'
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
Dear Kirk (and Julio)

Thanks for the response..

I don't want to use a link to the images because backing up my data and
porting it to another machine is much easier. (Replicating is also very
easy.) When storing the file separately this gets more complex, especially
when you want to get this data from another machine...

The stored data isn't retrieved very often, so speed isn't really an issue.
(Till now speed really never was an isse. When adding the right indexes
MySql + PHP does incredible things!!.)

I do though use the suggested 'linking' method for an website where the
images are needed on the website.. In the current situation though I store
PDF images of invoices which are basically only needed to look something up
if there is a problem...

Kirk, I already tried changing the properties of the column in which I
store the images.. (Currently it is an longtext, but before this I always
used an Longblob...)

I can't remember the exact sizes of MySQL, but I believe that an Mediumblob
can handle 16 Megabyte..  (I know have little more than a 1 MB..)

I will try some things tomorrow, but I can't find out what the problem is..
(Column size, PHP-Mysql string length limitation or maybe something I am
overlooking..)

I can though echo the query to screen and see that the uploaded file is
encoded to a very nice (large) text-string..

Any other suggestions are greatly appreciated.

With kind regards,
David Bouw




> If I use the link to the file, i.e.
>
>    file//C:\filedir\file.pdf or .txt or whatever
>
> how do I  insert/update/delete the file since MySQL is holding only the
> link?
>
> BTW David, what are the properties of the field you are inserting to?
> Could that be the problem?
>
> -Kirk
>
> "Julio Nobrega Trabalhando" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>>   Instead of uploading to Mysql, why don't you store the file at a
> directory
>> and on Mysql only the path to it?
>>
>>   Retrieving files from the hard drive is much faster than doing the
>>   same
> on
>> Mysql, and also access to manipulation (insert, update, delete,
>> etc...)
>>
>> --
>>
>> Julio Nobrega.
>>
>> Um dia eu chego lá:
>> http://sourceforge.net/projects/toca
>>
>> Ajudei? Salvei? Que tal um presentinho?
>> http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884
>>
>>
>> "David Bouw" <[EMAIL PROTECTED]> wrote in message
>> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> > I can't seem to figure out the following.
>> >
>> > I use the http upload functions a lot, works great!!..
>> > For some months now I have been using a small PHP program
>> > which I use to upload PDF files of scanned documents and
>> > insert them into a Mysql table..
>> >
>> > Normally these files are small (<250 kb), but I now have a
>> > PDF of 1 MB... When uploading files I run the
>> > function: chunk_split(base64_encode($binaryfile));
>> > to encode it, this to transform the binary file to text.. (Works
> great!!!)
>> >
>> > When the query was called to insert the data, nothing happens, also
>> > no error from mysql...  Only think I can think of is that the mysql
>> > query string is to long.. ??  (The data when encoded is about 1.3 MB
>> > of text)..
>> >
>> > This is the source code..
>> >
>> > if (!($userfile_size == 0))
>> >    {$fd = fopen ($userfile, "r");
>> >     $contents = fread ($fd, filesize ($userfile));
>> >     fclose ($fd);
>> >     unlink ($userfile);
>> >     echo "Eerste RAW: ".strlen($contents);
>> >     $encodes_data = chunk_split(base64_encode($contents));
>> >     $userfile_name = str_replace(" ", "", "$userfile_name");
>> >     echo strlen($encodes_data)." - Displays text size <BR>";
>> >     //Works
>> right!
>> >     mysql ($databasename_boekhoud, "insert mubo_boekhoud_images
>> >     (data,
>> > originalname, groep, type)
>> > values '$encodes_data', '$userfile_name', '$groep',
>> > '$userfile_type')");
>> //
>> >     mysql_error(); //No error given..?
>> >   }
>> >
>> > Any suggestions are very much appreciated...
>> >
>> > With kind regards,
>> > David Bouw
>> >
>> >
>>
>>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Hi, I think if you encode the file with base64 and store it in the
database the size of the document will be more than 1MB sure.

David Bouw wrote:
> Dear Kirk (and Julio)
> 
> Thanks for the response..
> 
> I don't want to use a link to the images because backing up my data and
> porting it to another machine is much easier. (Replicating is also very
> easy.) When storing the file separately this gets more complex, especially
> when you want to get this data from another machine...
> 
> The stored data isn't retrieved very often, so speed isn't really an issue.
> (Till now speed really never was an isse. When adding the right indexes
> MySql + PHP does incredible things!!.)
> 
> I do though use the suggested 'linking' method for an website where the
> images are needed on the website.. In the current situation though I store
> PDF images of invoices which are basically only needed to look something up
> if there is a problem...
> 
> Kirk, I already tried changing the properties of the column in which I
> store the images.. (Currently it is an longtext, but before this I always
> used an Longblob...)
> 
> I can't remember the exact sizes of MySQL, but I believe that an Mediumblob
> can handle 16 Megabyte..  (I know have little more than a 1 MB..)
> 
> I will try some things tomorrow, but I can't find out what the problem is..
> (Column size, PHP-Mysql string length limitation or maybe something I am
> overlooking..)
> 
> I can though echo the query to screen and see that the uploaded file is
> encoded to a very nice (large) text-string..
> 
> Any other suggestions are greatly appreciated.
> 
> With kind regards,
> David Bouw
> 
> 
> 
> 
> 
>>If I use the link to the file, i.e.
>>
>>   file//C:\filedir\file.pdf or .txt or whatever
>>
>>how do I  insert/update/delete the file since MySQL is holding only the
>>link?
>>
>>BTW David, what are the properties of the field you are inserting to?
>>Could that be the problem?
>>
>>-Kirk
>>
>>"Julio Nobrega Trabalhando" <[EMAIL PROTECTED]> wrote in message
>>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>>
>>>  Instead of uploading to Mysql, why don't you store the file at a
>>
>>directory
>>
>>>and on Mysql only the path to it?
>>>
>>>  Retrieving files from the hard drive is much faster than doing the
>>>  same
>>
>>on
>>
>>>Mysql, and also access to manipulation (insert, update, delete,
>>>etc...)
>>>
>>>--
>>>
>>>Julio Nobrega.
>>>
>>>Um dia eu chego lá:
>>>http://sourceforge.net/projects/toca
>>>
>>>Ajudei? Salvei? Que tal um presentinho?
>>>http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884
>>>
>>>
>>>"David Bouw" <[EMAIL PROTECTED]> wrote in message
>>>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>>>
>>>>I can't seem to figure out the following.
>>>>
>>>>I use the http upload functions a lot, works great!!..
>>>>For some months now I have been using a small PHP program
>>>>which I use to upload PDF files of scanned documents and
>>>>insert them into a Mysql table..
>>>>
>>>>Normally these files are small (<250 kb), but I now have a
>>>>PDF of 1 MB... When uploading files I run the
>>>>function: chunk_split(base64_encode($binaryfile));
>>>>to encode it, this to transform the binary file to text.. (Works
>>>
>>great!!!)
>>
>>>>When the query was called to insert the data, nothing happens, also
>>>>no error from mysql...  Only think I can think of is that the mysql
>>>>query string is to long.. ??  (The data when encoded is about 1.3 MB
>>>>of text)..
>>>>
>>>>This is the source code..
>>>>
>>>>if (!($userfile_size == 0))
>>>>   {$fd = fopen ($userfile, "r");
>>>>    $contents = fread ($fd, filesize ($userfile));
>>>>    fclose ($fd);
>>>>    unlink ($userfile);
>>>>    echo "Eerste RAW: ".strlen($contents);
>>>>    $encodes_data = chunk_split(base64_encode($contents));
>>>>    $userfile_name = str_replace(" ", "", "$userfile_name");
>>>>    echo strlen($encodes_data)." - Displays text size <BR>";
>>>>    //Works
>>>
>>>right!
>>>
>>>>    mysql ($databasename_boekhoud, "insert mubo_boekhoud_images
>>>>    (data,
>>>>originalname, groep, type)
>>>>values '$encodes_data', '$userfile_name', '$groep',
>>>>'$userfile_type')");
>>>
>>>//
>>>
>>>>    mysql_error(); //No error given..?
>>>>  }
>>>>
>>>>Any suggestions are very much appreciated...
>>>>
>>>>With kind regards,
>>>>David Bouw
>>>>
>>>>
>>>
>>>
>>
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
> 


--- End Message ---
--- Begin Message ---
Is it possible to modify the password attribute in LDAP?  I am the netscape 
directory server for authentication, but would like to allow the user to 
change their own password.  When I search for a user and get the attibutes 
for that user password is not available.  Am I missing something here?

Thanks.

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

--- End Message ---
--- Begin Message ---
Sounds like desired behavior to me.  I would think that you may be able to
change the password, but aren't allowed to retrieve its value.

Cheers

> -----Original Message-----
> From: J. Anderson Scarbrough [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 3:03 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] LDAP
>
>
> Is it possible to modify the password attribute in LDAP?  I am
> the netscape
> directory server for authentication, but would like to allow the user to
> change their own password.  When I search for a user and get the
> attibutes
> for that user password is not available.  Am I missing something here?
>
> Thanks.
>
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
Is there another way then to register form variables global? I just
downloaded, and instlaled the newest version of PHP, and now my form script
doesn't work anymore.  I had to register the form variables global in the
script. I'm asking, is there a better way of doing this? I've herd it can
lead to possible security hazards.

Thanks for any help.


--- End Message ---
--- Begin Message ---
Sorry, I'll have to clerify myself a bit. I'm rather tired. :)

I have a script that verifys and inserts (into and Access databse) form
values. I had to make the form variables "global", in order to use them in
my functions. Since the new PHP is out, the script doesn't work anymore. I
think its probably because of the fact that I had to make those variables
global (none of the variables are being read).
Does any of you have an idea about how I can fix this problem? Thanks in
advance.


"Dr. Shim" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Is there another way then to register form variables global? I just
downloaded, and instlaled the newest version of PHP, and now my form script
doesn't work anymore.  I had to register the form variables global in the
script. I'm asking, is there a better way of doing this? I've herd it can
lead to possible security hazards.

Thanks for any help.




--- End Message ---
--- Begin Message ---
  This is not the global that is meant on the update. Not the global $var
that you put inside your functions.

  That's scope, btw. You are making a variable available inside a different
scope (the function), by making it "global".

  The global you are searching for is, like when you submit a form, a field
name becomes a varible on the "action" page with the same name. So:

<input name="username"...

  Would create a $username variable. Not anymore :-)

  Now you need to specify where it came from, either with $_POST or
$HTTP_POST_VARS.

  So... action page again:

$username = $_POST['username'];

  But, if you don't want to convert your script (and I object btw, you
should ;-), you can modify a line at php.ini so variables are *globally
registered* again.

--

Julio Nobrega.

Um dia eu chego lá:
http://sourceforge.net/projects/toca

Ajudei? Salvei? Que tal um presentinho?
http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884


"Dr. Shim" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Sorry, I'll have to clerify myself a bit. I'm rather tired. :)
>
> I have a script that verifys and inserts (into and Access databse) form
> values. I had to make the form variables "global", in order to use them in
> my functions. Since the new PHP is out, the script doesn't work anymore. I
> think its probably because of the fact that I had to make those variables
> global (none of the variables are being read).
> Does any of you have an idea about how I can fix this problem? Thanks in
> advance.
>
>
> "Dr. Shim" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Is there another way then to register form variables global? I just
> downloaded, and instlaled the newest version of PHP, and now my form
script
> doesn't work anymore.  I had to register the form variables global in the
> script. I'm asking, is there a better way of doing this? I've herd it can
> lead to possible security hazards.
>
> Thanks for any help.
>
>
>
>


--- End Message ---
--- Begin Message ---
Dr. Shim wrote:
> Sorry, I'll have to clerify myself a bit. I'm rather tired. :)
> 
> I have a script that verifys and inserts (into and Access databse) form
> values. I had to make the form variables "global", in order to use them in
> my functions. Since the new PHP is out, the script doesn't work anymore. I
> think its probably because of the fact that I had to make those variables
> global (none of the variables are being read).
> Does any of you have an idea about how I can fix this problem? Thanks in
> advance.
> 
> 
> "Dr. Shim" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Is there another way then to register form variables global? I just
> downloaded, and instlaled the newest version of PHP, and now my form script
> doesn't work anymore.  I had to register the form variables global in the
> script. I'm asking, is there a better way of doing this? I've herd it can
> lead to possible security hazards.
> 
> Thanks for any help.
> 
> 
> 
> 

Look into the extract() function.  You could use it to turn the $_POST 
or $_GET arrays into local variables, whether you do it at the beginning 
of the script and make them global as you are currently doing or by 
doing it at the beginning of the functions that you use them, without 
globalizing anything.



For example... given the url http://localhost/foo.php?bar=banana

you'd have $_GET['bar']=="banana" instead of $bar=="banana";

at the beginning of the script you'd have extract($_GET); and $bar would 
exist with the value "banana"

--- End Message ---
--- Begin Message ---
Thank you so much Austin, and Julio! Your replies are an amazing help to me.
Thanks! Maybe I'll even get this project I'm working on done this week. =)

Anyhoo, Julio, you mean that option in the PHP.INI, is it
"register_globals"? Well, anyhow, I'm going to "convert" my script, as you
put it.

Again, thanks for your help, I'm going to definatly look up the "extract()"
function, Austin.



--- End Message ---
--- Begin Message ---
My PHP scripts are in a directory, "php".  The owner of the directory is "root"
and the group is "apache".  Other has no rights.

Group has rx rights.  All works well *except* the surfer can view the directory
of the php directory *and* copy the files.

What have I missed??

Todd

--
Todd Cary
Ariste Software
2200 D Street Extension
Petaluma, CA 94952
707-773-4523
[EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
> My PHP scripts are in a directory, "php".  The owner of the
> directory is "root"
> and the group is "apache".  Other has no rights.
>
> Group has rx rights.  All works well *except* the surfer can view
> the directory
> of the php directory *and* copy the files.

It means that DirectoryIndexing is enabled in apache =)  you can either
disable that (recommended) or as a quick fix put a blank index.htm (or .html
file) in that directory so when someone calls up just the directory they get
that blank page.

Sincerely,

Craig Vincent


--- End Message ---
--- Begin Message ---
Craig -

Thank you for the quick response.  I do not see an entry in httpd.conf for
DirectoryIndexing.  Am I missing something?

Todd

--
Todd Cary
Ariste Software
2200 D Street Extension
Petaluma, CA 94952
707-773-4523
[EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
search for "DirectoryIndex" and delete DirectoryIndex entry given below it.

"Todd Cary" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Craig -
>
> Thank you for the quick response.  I do not see an entry in httpd.conf for
> DirectoryIndexing.  Am I missing something?
>
> Todd
>
> --
> Todd Cary
> Ariste Software
> 2200 D Street Extension
> Petaluma, CA 94952
> 707-773-4523
> [EMAIL PROTECTED]
>
>


--- End Message ---
--- Begin Message ---

 > -----Original Message-----
 > Can someone tell me where to find the various options for 
 > the Header function as it relates to M$ Excel?
 > -----Original Message-----

As far as I know, you can't.  Headers are for html/http information not
for any particular "helper application".  If you want to have control
over the configuration of Excel you'll have to learn to output your data
as a valid Excel spreadsheet with the relevant formatting information
included - this would obviously involve knowing a fair bit about the
data structure and format of .xls files.

CYA, Dave


--- End Message ---
--- Begin Message ---
strange i just worked this out over the weekend.

I'm going to be use it to email data that will be inserted 
into an excel sheet you just tell it the html file is a xls file 
in the mime headers and it opens the file up in excel, 
no problem and no messing with csv files, comas,
xml support and all that.

ie
Content-Type: application/vnd.ms-excel;
 name="test.xls" 
Content-Transfer-Encoding: base64
Content-Disposition: attachment; 
 filename="test.xls";

if it's excel 2002 (xp) you can use styles and edit the doc properties.
have a look for <x:DisplayGridlines/> or <x:DoNotDisplayGridlines/>
in the file. If it's 97 then you need the border=1 in the table though.

have fun.

Paul Roberts
[EMAIL PROTECTED]
++++++++++++++++++++++++
----- Original Message ----- 
From: "Jay Blanchard" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 3:25 PM
Subject: RE: [PHP] Formatting Information in header? Gridlines in Excel


> [snip]
> This is intriguing me, are you opening up excel in a browser window or just
> printing out html tables?? I am confused.
> [/snip]
> 
> I am using PHP to query a database and create an HTML table based on the
> information in the database (in this case it it a large crosstab query).
> This is set up to open Excel in a broswer window (inline) and display the
> data in a worksheet. All normal Excel functions can be performed on the
> worksheet without changing the data in the database. These worksheets then
> can be saved to the user's local disk. They can always run the original
> query again by requesting the worksheet/page again.
> 
> Link pointed to php page that will send to browser <a
> href="test.php/test.xls"> Stupid IE trick, the .xls file does not 'exist',
> but will fake out Excel to open the .php 'page' in a worksheet. Also, make
> sure to include header information listed in previous e-mail at the top of
> the PHP page.
> 
> The steps are;
> 1. Create a PHP file with the header info
> 2. Do a PHP request to the database.
> 3. Use the results to create an HTML table within the PHP
> 4. Open this table in a spreadsheet
> 
> HTH!
> 
> Jay Blanchard
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 


--- End Message ---
--- Begin Message ---
What am I doing wrong? I get parse error between first echo statement and
else.

Thanks

Craig ><>
[EMAIL PROTECTED]


<?php
$fn = "image.gif";
if (!file_exists($fn)) {
echo "<img src=noimageexists.gif>";
else
echo "<img src=$fn>";
}
?>

--- End Message ---
--- Begin Message ---
Craig Westerman wrote:
> What am I doing wrong? I get parse error between first echo statement and
> else.
> 
> Thanks
> 
> Craig ><>
> [EMAIL PROTECTED]
> 
> 
> <?php
> $fn = "image.gif";
> if (!file_exists($fn)) {
> echo "<img src=noimageexists.gif>";
> else
> echo "<img src=$fn>";
> }
> ?>
> 

You've got your semicolons in the wrong spots. Try:

<?php
$fn = "image.gif";
if (!file_exists($fn))
{
echo "<img src=noimageexists.gif>";
}
else
{
echo "<img src=$fn>";
}

?>



--- End Message ---
--- Begin Message ---
I found my problem.

>From manual:
"file_exists() will not work on remote files; the file to be examined must
be accessible via the server's filesystem. "

File is on another server. Is there a way to check if file exists on another
server?

Craig ><>
[EMAIL PROTECTED]


-----Original Message-----
From: Craig Westerman [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 7:58 PM
To: php-general-list
Subject: [PHP] file_exists


What am I doing wrong? I get parse error between first echo statement and
else.

Thanks

Craig ><>
[EMAIL PROTECTED]


<?php
$fn = "image.gif";
if (!file_exists($fn)) {
echo "<img src=noimageexists.gif>";
else
echo "<img src=$fn>";
}
?>


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

--- End Message ---
--- Begin Message ---
Craig Westerman wrote:
> I found my problem.
Try fopen() if it fails it will return false, otherwise it will return 
an integer file pointer.  You get use it to fetch files via http://, 
https://, ftp://, and more.

> 
> From manual:
> "file_exists() will not work on remote files; the file to be examined must
> be accessible via the server's filesystem. "
> 
> File is on another server. Is there a way to check if file exists on another
> server?
> 
> Craig ><>
> [EMAIL PROTECTED]
> 
> 
> -----Original Message-----
> From: Craig Westerman [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 7:58 PM
> To: php-general-list
> Subject: [PHP] file_exists
> 
> 
> What am I doing wrong? I get parse error between first echo statement and
> else.
> 
> Thanks
> 
> Craig ><>
> [EMAIL PROTECTED]
> 
> 
> <?php
> $fn = "image.gif";
> if (!file_exists($fn)) {
> echo "<img src=noimageexists.gif>";
> else
> echo "<img src=$fn>";
> }
> ?>
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



--- End Message ---
--- Begin Message ---
Does fopen() actually work for https connections?  I thought this
implementation was not yet released.

> -----Original Message-----
> From: Austin Marshall [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 9:40 PM
> To: Craig Westerman
> Cc: php-general-list
> Subject: Re: [PHP] file_exists
>
>
> Craig Westerman wrote:
> > I found my problem.
> Try fopen() if it fails it will return false,
> otherwise it will return
> an integer file pointer.  You get use it to fetch
> files via http://,
> https://, ftp://, and more.
>
> >
> > From manual:
> > "file_exists() will not work on remote files; the
> file to be examined must
> > be accessible via the server's filesystem. "
> >
> > File is on another server. Is there a way to check
> if file exists on another
> > server?
> >
> > Craig ><>
> > [EMAIL PROTECTED]
> >
> >
> > -----Original Message-----
> > From: Craig Westerman [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, May 06, 2002 7:58 PM
> > To: php-general-list
> > Subject: [PHP] file_exists
> >
> >
> > What am I doing wrong? I get parse error between
> first echo statement and
> > else.
> >
> > Thanks
> >
> > Craig ><>
> > [EMAIL PROTECTED]
> >
> >
> > <?php
> > $fn = "image.gif";
> > if (!file_exists($fn)) {
> > echo "<img src=noimageexists.gif>";
> > else
> > echo "<img src=$fn>";
> > }
> > ?>
> >
> >
> > --
> > 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
>
>

--- End Message ---
--- Begin Message ---
On Mon, 6 May 2002, Craig Westerman wrote:
> What am I doing wrong? I get parse error between first echo statement and
> else.
> 
> <?php
> $fn = "image.gif";
> if (!file_exists($fn)) {
> echo "<img src=noimageexists.gif>";
> else
> echo "<img src=$fn>";
> }
> ?>

You open the brace for the positive branch of the if and then leave it 
open surrounding the else condition.

WRONG:

if (condition)
{ do something;
else
  do something else;
}

RIGHT:

if (condition)
{ do something; }
else { do something else; }

As for "finding the problem" with file_exists' limitation to local files, 
that's a different problem.

miguel

--- End Message ---
--- Begin Message ---
Not until 4.3.

On Mon, 6 May 2002, Jonathan Rosenberg wrote:

> Does fopen() actually work for https connections?  I thought this
> implementation was not yet released.
>
> > -----Original Message-----
> > From: Austin Marshall [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, May 06, 2002 9:40 PM
> > To: Craig Westerman
> > Cc: php-general-list
> > Subject: Re: [PHP] file_exists
> >
> >
> > Craig Westerman wrote:
> > > I found my problem.
> > Try fopen() if it fails it will return false,
> > otherwise it will return
> > an integer file pointer.  You get use it to fetch
> > files via http://,
> > https://, ftp://, and more.
> >
> > >
> > > From manual:
> > > "file_exists() will not work on remote files; the
> > file to be examined must
> > > be accessible via the server's filesystem. "
> > >
> > > File is on another server. Is there a way to check
> > if file exists on another
> > > server?
> > >
> > > Craig ><>
> > > [EMAIL PROTECTED]
> > >
> > >
> > > -----Original Message-----
> > > From: Craig Westerman [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, May 06, 2002 7:58 PM
> > > To: php-general-list
> > > Subject: [PHP] file_exists
> > >
> > >
> > > What am I doing wrong? I get parse error between
> > first echo statement and
> > > else.
> > >
> > > Thanks
> > >
> > > Craig ><>
> > > [EMAIL PROTECTED]
> > >
> > >
> > > <?php
> > > $fn = "image.gif";
> > > if (!file_exists($fn)) {
> > > echo "<img src=noimageexists.gif>";
> > > else
> > > echo "<img src=$fn>";
> > > }
> > > ?>
> > >
> > >
> > > --
> > > 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
>

--- End Message ---
--- Begin Message ---
On 6 May 2002 at 20:30, Craig Westerman wrote:
> File is on another server. Is there a way to check if file exists on
> another server?

I wrote the following function a while ago to do this. It works with http URLs and 
should also 
work with https and ftp, but I have only tested http. I hope it's useful to you.

function RemoteFileExists($url, $referer)
{
    $url_parts = parse_url($url);

    if ($url_parts["scheme"] != "http" && $url_parts["scheme"] != "https" && 
$url_parts["scheme"] != "ftp")
    {
        // Don't currently handle shemes other than HTTP and HTTPS, so assume the file 
exists for now
        return TRUE;
    }

    $ch = curl_init();
    $urltoget = $url_parts["scheme"]."://".$url_parts["host"].$url_parts["path"];
    if (isset($url_parts["query"])) $urltoget .= "?".$urltoget["query"];
    curl_setopt ($ch, CURLOPT_URL, $urltoget);
    if ($url_parts["scheme"] == "http" || $url_parts["scheme"] == "https")
    {
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_NOBODY, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_REFERER, $referer);
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $reply = curl_exec($ch);
    curl_close($ch);
    
    if ($url_parts["scheme"] == "http" || $url_parts["scheme"] == "https")
    {
        $result = explode(" ", $reply);
        $reply = ($result[1] == "200");
    }

    return $reply;
}

-- 
Stuart
--- End Message ---
--- Begin Message ---

 > -----Original Message-----
 > D'oh!  You're right, I went back and checked php.ini and 
 > found upload_max_filesize but it's already set to 200M, I'm 
 > assuming that means 200 MegaBytes.  So I don't think that's 
 > the problem.  I don't have the hidden tag set in the page 
 > code so that shouldn't be a factor either, right? I'm a real 
 > rooky at php programming.
 > -----Original Message-----

 > <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="2048000">

You actually _need_ that hidden tag set AFAIK.

CYA, Dave


--- End Message ---
--- Begin Message ---
On Tuesday 07 May 2002 09:01, David Freeman wrote:
>  > -----Original Message-----
>  > D'oh!  You're right, I went back and checked php.ini and
>  > found upload_max_filesize but it's already set to 200M, I'm
>  > assuming that means 200 MegaBytes.  So I don't think that's
>  > the problem.  I don't have the hidden tag set in the page
>  > code so that shouldn't be a factor either, right? I'm a real
>  > rooky at php programming.
>  > -----Original Message-----
>  >
>  > <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="2048000">
>
> You actually _need_ that hidden tag set AFAIK.

I'm curious, I keep seeing people say that that tag is /necessary/, but I've 
never had to use it in the upload forms that I've built and they work just 
fine in Opera, NN & IE. 

Can anyone explain /why/ it's needed? 

AFAICT from the manual that tag is only to advise the browser to limit the 
size of the file being uploaded, nothing to suggest that the absence of the 
tag would prevent uploading. But if that was indeed the case then what 
browsers does it affect?

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

/*
The value of a program is proportional to the weight of its output.
*/
--- End Message ---
--- Begin Message ---

 > -----Original Message-----
 > I'm curious, I keep seeing people say that that tag is 
 > /necessary/, but I've never had to use it in the upload forms 
 > that I've built and they work just fine in Opera, NN & IE. 

Good question.  To be honest it's been a while since I looked, I built a
file upload function as part of a standard set of functions that I
include in projects and then stopped worrying about it.  As a result
it's been a some time since I looked at that sort of thing.  I recall
including it for a reason but don't exactly recall the reason.

 > AFAICT from the manual that tag is only to advise the 
 > browser to limit the size of the file being uploaded, 
 > nothing to suggest that the absence of the 
 > tag would prevent uploading.

I guess that anything that causes this sort of thing to happen on the
browser is going to help.  I know I'd be fairly unimpressed if I sat
waiting for a 2MB file to upload only to find that the limit is 1.5MB or
some such.  At least if a client-side limit is given the browser can do
something about it.

Not that I actually recall testing that either - I've so far only used
file upload capabilities on intranet projects where I have fully
switched 100MB and the like.

CYA, Dave


--- End Message ---
--- Begin Message ---

 > -----Original Message-----
 > I have a page that contains multi If ElseIf statements.  I 
 > want to redirect right after a user submits gets a message 
 > (echo "Entry Added to Database. \n"; )  would you like to 
 > add another. then prompts for an alert.  Would you like 
 > another ???  and redirects to a page based on selection.
 > -----Original Message-----

The moment you output anything to your page you can't do an automated
redirect using the header() function.

If you need to output something and then do a redirect automatically
then you're going to have to start fiddling quite a bit.  The first
thing that springs to mind would be inserting a meta refresh in your
<head> but this won't help if you have a conditional redirect.  The
second would be to do it in javascript where your alert box determines
what url to go to and you use that javascript to do the navigation
(perhaps by simulating a form submission).

CYA, Dave


--- End Message ---
--- Begin Message ---
After further research, (reading the redhat php spec file completely)
I discovered how they were making it, so that php binaries, and apache
php module was working at the same time...

The rpm builds the cgi root, and installs it, and the builds the apache
root, and installs that over the cgi installation, which overwrites some
things, but fortunately(as the spec file documents) they are
compatible...

So, I simply went to the spec file, where it built the cgi tree, and
 --enable-pcntl \

and rpm -ba phpxxxxx.spec,
and viola, pcntl support in the php binary!

Hope this helps others....

Barry Smoke
Project Leader
Vispman.org


-----Original Message-----
From: Barry Smoke [mailto:[EMAIL PROTECTED]] 
Sent: Monday, May 06, 2002 1:07 PM
To: [EMAIL PROTECTED]
Subject: [PHP] --enabel-pnctl / php sockets

I have recently discovered php's binary capabilities, and am using it to
write a virtual isp management system, so that a php binary will listen
to a port, and spit out an interface, such as webmin,
etc...(http://vispman.org)

This interface will be able to add virtual domains, restart dns, qmail,
etc...

I have seen a couple of other php binary projects(using php sockets),
such as phserv, where an entire web server (like apache) has been
written in nothing but php.

I tried to install these, and they wouldn't run without php compiled
with 
--enable-pcntl


Now, it is my understanding that --enable-pcntl  is for process control,
and it only works if you are compiling php as a cgi module, and not as
an apache add-on. 
(at least that is the error I got , when taking a redhat php rpm, and
editing the spec file to include the --enable-pcntl)
 

Is there any way to get that to compile, while maintaining all original
functionality in the redhat php rpm?


What I am really looking for here, is a php binary, that will spit out a
web control interface(standard web page, with forms on the client side)
That will listen on a non-apache port, and if a connections is detected,
lock it in securely...

But...still allow other connections, (like apache listens to
minservers/maxservers....multiple sessions on one port)

The idea being that one isp might have multiple admins/staff entering in
domain information.

Any help on this is much appreciated.
Barry Smoke
Project Leader
Vispman.org



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


--- End Message ---
--- Begin Message ---
Hi all

I have a script that does a lot of harddrive access and runs for a while, at
the moment if the user closes his/her browser half way through, the script
continues and the harddrive keeps going crazy.....is there a way like in ASP
to check that the browser is still open and connected??


Regards
Jarrad Kabral
--- End Message ---
--- Begin Message ---
Yep...

http://www.php.net/manual/en/features.connection-handling.php

---John Holmes...

> -----Original Message-----
> From: Jarrad Kabral [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 6:16 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Is the browser still open? if not then I want to kill
the
> script
> 
> Hi all
> 
> I have a script that does a lot of harddrive access and runs for a
while,
> at
> the moment if the user closes his/her browser half way through, the
script
> continues and the harddrive keeps going crazy.....is there a way like
in
> ASP
> to check that the browser is still open and connected??
> 
> 
> Regards
> Jarrad Kabral
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
Free hosting for PHP Developers.

As many MySQL Databases as you need
PHP with all the bits http://scripts.operationenigma.net/phpinfo.php
FTP Access
Subdomain or Your own Domain
Tech Support over MSN if needed
98% Uptime
512/512 Connection based in Brisbane, Australia


Only catch is that I can't have downloads on my servers.  
I have a 3 Gig Monthty transfer limit, so no MP3s or 
thereabouts please.

Contact me if you're interested.


--- End Message ---
--- Begin Message ---
Hello,

SP wrote:
> Thanks dude I'll take a look at it.  How do you get around caching only certain 
>parts of a
> page?

No problem, just capture all the page output in a variable and feed it 
to the class.

Regards,
Manuel Lemos


> 
> -----Original Message-----
> From: Manuel Lemos [mailto:[EMAIL PROTECTED]]
> Sent: May 5, 2002 4:01 PM
> To: Sp
> Cc: Miguel Cruz; Pag; Luc Saint-Elie
> Subject: Re: [PHP] PHP compared to JSP
> 
> 
> Hello,
> 
> Sp wrote:
> 
>>Does anyone think caching should be built into php for it to edge out the 
>competition?
>>(like what smarty is doing)
>>
>>I mean a static page will always serve up faster then a dynamic one.  Also even if 
>you
> 
> are
> 
>>getting 100 pages/sec on your database, you could cache it for 5 seconds and you save
> 
> 500
> 
>>accesses to your database.  Yeah the page would be at most 5 seconds old but no one
> 
> would
> 
>>know.
> 
> 
> I have been doing that for quite some time and I can tell that it is not
> worthy to cache just database query results but rather the pages that
> are generated with the data that is returned with such queries.
> 
> For that I have developed of a robust class that caches pages in files
> while it prevents that concurrent accesses update the cache files
> simultaneously to prevent corrupting the cached data.
> 
> You may want to try getting it here:
> 
> http://www.phpclasses.org/browse.html/package/313.html
> 
> Regards,
> Manuel Lemos
> 
> 
> .
> 



--- End Message ---
--- Begin Message ---
I want to add the extension to the PHP server and I realize that I need to modify the 
php.ini file for that extension. However, I cannot find that file. Also, where should 
that file be placed?
--- End Message ---
--- Begin Message ---
The parsing is not the problem. I am already using the PHP XML parser, but
the problem is that it I cannot get the content of elements into variables
like I already stated. Does no one know how to do this?

-----Original Message-----
From: Analysis & Solutions [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 8:25 PM
To: PHP List
Subject: Re: [PHP] Variables from XML Documents

On Mon, May 06, 2002 at 08:20:46PM +0200, Sebastian A. wrote:
> <me>
>       <name>
>               Foo-Bar
>       </name>
> </me>
>
> What would I need to do, so that I can get the contents of the <name> tag
> (Foo-Bar) into a variable?

Check out my "PHP XML Parsing Basics" at
http://www.analysisandsolutions.com/code/phpxml.htm

--Dan

--
               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

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

--- End Message ---
--- Begin Message ---
Sebastian:

On Tue, May 07, 2002 at 07:06:18AM +0200, Sebastian A. wrote:

> The parsing is not the problem. I am already using the PHP XML parser, but
> the problem is that it I cannot get the content of elements into variables
> like I already stated. Does no one know how to do this?

You are doing something wrong.  Exactly WHAT, I don't know.  

Since your XML data sample was on multiple lines, I could guess that the
problem is you're only getting the last line from the Character Data
handler.  And, since the last line is blank, you get, blank back in the 
variable.

Dude, like I said, go check out "PHP XML Parsing Basics" at
   http://www.analysisandsolutions.com/code/phpxml.htm

End of problem,

--Dan

--
               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409
--- End Message ---
--- Begin Message ---
look at xml_set_character_data_handler()
it works fine for me

<?
class xml_class
{
  ...
  function xml_class()
  {
    $this->xml_parser = xml_parser_create();
    xml_set_object($this->xml_parser, $this);
    xml_set_element_handler($this->xml_parser, "start_element",
"end_element");
    xml_set_character_data_handler($this->xml_parser, "character_data");
  }
  ...
  function character_data($p, $d)
  {
    $d = trim(ereg_replace("\n", "", $d));
    if (!$d)  return;
    $this->curr_tag->data[] = $d;
  }
  ...
}
?>

-----Original Message-----
From: Sebastian A. [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 07, 2002 3:06 PM
To: PHP General List (PHP.NET)
Subject: RE: [PHP] Variables from XML Documents


The parsing is not the problem. I am already using the PHP XML parser, but
the problem is that it I cannot get the content of elements into variables
like I already stated. Does no one know how to do this?

-----Original Message-----
From: Analysis & Solutions [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 8:25 PM
To: PHP List
Subject: Re: [PHP] Variables from XML Documents

On Mon, May 06, 2002 at 08:20:46PM +0200, Sebastian A. wrote:
> <me>
>       <name>
>               Foo-Bar
>       </name>
> </me>
>
> What would I need to do, so that I can get the contents of the <name> tag
> (Foo-Bar) into a variable?

Check out my "PHP XML Parsing Basics" at
http://www.analysisandsolutions.com/code/phpxml.htm

--Dan

--
               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

--
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
--- End Message ---

Reply via email to