php-general Digest 5 Sep 2004 12:36:29 -0000 Issue 2978

Topics (messages 195888 through 195906):

Re: !!Urgent .. Session Problem Solved ... But not completely
        195888 by: Dennis Gearon
        195906 by: Torn

arrow values in command line php
        195889 by: weston.leary.csoft.net

Re: PHP IDE for OS X
        195890 by: Chris Martin
        195891 by: Eric Marden

Re: HTTP Authentication in include()
        195892 by: Chris Shiflett

Re: installing PHP on winXP
        195893 by: Chris Martin

Re: Does any one else get this?
        195894 by: Chris Martin
        195896 by: Jack Gates
        195904 by: Paul Waring

PHP5 - How Do I Let Users Download Music Files?
        195895 by: php-list.xenonsolutions.com
        195900 by: Anders Ossowicki
        195905 by: Daniel Schierbeck

htmlentities and foreign characters from MS Word
        195897 by: Monty
        195902 by: I2eptileX

Re: PHP site ?
        195898 by: Lester Caine

Re: !!Urgent .. Session Problem
        195899 by: Nick Wilson

array_merge changed behaviour in Php5??
        195901 by: I2eptileX
        195903 by: M. Sokolewicz

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 ---
It has to be in SOME file. Probably in your prepend file or one of the files that it 
includes.

"Dre" <[EMAIL PROTECTED]> wrote:

<quote ----------------------------------------------------------------->
believe me the FIRST line in the file is <?php session_start();
NOTHING AT ALL exists before it.
but I still have the same error

"M. Sokolewicz" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

I think you didn't read all instructions we gave. One of them was to
remove all spaces and/or newlines BEFORE the first <?php tag in your
file, to save it and try again.

anything before the <?php tag is considered HTML and thus output. Since
headers are always sent before the output is, they will be sent the
moment PHP notices the spaces and/or newlines. So, what happens is:

PHP starts processing
PHP encounters spaces and/or newlines
PHP sends headers to the browser
PHP sends those spaces and/or newlines to the browser
PHP notices the <?php tag, and such swithed to "parsing-mode"
PHP notices session_start(); and thus tries to send a cookie (a cookie
is actually one of the headers)
PHP notices that headers have already been sent! So it gives an error,
because it can't "get them back and send them after the cookie again".
<snip lots>
</quote ------------------------------------------------------------------>

--- End Message ---
--- Begin Message ---
Message-ID: <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Reply-To: "Dre" <[EMAIL PROTECTED]>
From: "Dre" <[EMAIL PROTECTED]>
Date: Sat, 4 Sep 2004 16:10:32 +0300
Subject: Re: !!Urgent .. Session Problem Solved ... But not completely


> > the errors are as follows
> > //=====================================================
> > Warning: session_start(): Cannot send session cookie - headers already
sent
> > by (output started at C:\Program Files\Apache
> > Group\Apache2\htdocs\ELBA\logme_in.php:1) in C:\Program Files\Apache
> > Group\Apache2\htdocs\ELBA\logme_in.php on line 2
> >
> > Warning: session_start(): Cannot send session cache limiter - headers
> > already sent (output started at C:\Program Files\Apache
> > Group\Apache2\htdocs\ELBA\logme_in.php:1) in C:\Program Files\Apache
> > Group\Apache2\htdocs\ELBA\logme_in.php on line 2
> >
> > //=====================================================
> >>//============================================================
> >>
> >> <?php
> >>  session_start();
> >>  include("db.php");
Does db.php starts with:
session_start()
?

--- End Message ---
--- Begin Message ---
A while back I decided I wanted a simple interactive interpreter for PHP.
So I wrote a little PHP script that essentially did a read from stdin,
and ran eval on that. Worked for most situations I was in.

I'm trying to add some more features now, namely recalling a list of commands
using the up and down arrow, and making each line left/right arrow editable.
But I'm not sure exactly how to read the input from the arrow characters.
Could someone tell me how or point me to a good resource on doing this
kind of thing?

Thanks,

        Weston

--- End Message ---
--- Begin Message --- Justin French wrote:
Can anyone suggest a PHP editor/IDE for OS X other than:

- BBEdit (already using it)
- Zend Studio (it's Java, not OS X native)

What I'm hoping for is:
- some form of auto-complete text for functions/constants/etc,
- integrated testing/debugging
- integration with local install of PHP
- anything else that will make my life easier without 'getting in the way'.

My guess is it doesn't exist, but it's worth a shot.

PLEASE, no "On Windows I use..." or "I just use 'Text Editor X'" -- I'm looking for something more than a basic text editor, and it has to be OS X native (not some ugly, sluggish Java thing).

---
Justin French
http://indent.com.au


I don't run OSX, so I don't know how easy this is, but it's definately worth the mention.


OSX has a unix core. I saw a bit on TechTV saying if you install the developer tools, you can run virtually any *nix app.
See these for more info
http://developer.apple.com/unix/index.html
http://developer.apple.com/unix/toolkits.html
http://fink.sourceforge.net/


I saw some tutorials searching google for "run linux apps on Mac" too.

That said, you could give Quanta Plus or Bluefish a shot, both are great free linux apps. My personal favorite is Quanta Plus, it contains most of what you mentioned (even auto-completes your variables)

On the non-free side, Dreamweaver MX has some decent PHP features, although it's a pricey solution.
<mac stab> You should be use to that though! ;) </mac stab>


--
Chris Martin
Web Developer
Open Source & Web Standards Advocate
http://www.chriscodes.com/

--- End Message ---
--- Begin Message ---
I use Drewmweaver's code view as a PHP IDE It allows me to manage my
site / app files as a whole (which dreamweaver does great) and the
built-in IDE (not the wyswyg) has great code hinting and the other
standard features one might look for (syntax colors, line numbers,
etc.)

Since I usually do development as well as design, DW is a great IDE.
The MX and MX 2004 have a real Homesite feel - a great IDE that never
did make it over to the Mac.

- Eric Marden


On Sun, 5 Sep 2004 00:26:31 +1000, Justin French
<[EMAIL PROTECTED]> wrote:
> Can anyone suggest a PHP editor/IDE for OS X other than:
> 
> - BBEdit (already using it)
> - Zend Studio (it's Java, not OS X native)
> 
> What I'm hoping for is:
> - some form of auto-complete text for functions/constants/etc,
> - integrated testing/debugging
> - integration with local install of PHP
> - anything else that will make my life easier without 'getting in the
> way'.
> 
> My guess is it doesn't exist, but it's worth a shot.
> 
> PLEASE, no "On Windows I use..." or "I just use 'Text Editor X'" -- I'm
> looking for something more than a basic text editor, and it has to be
> OS X native (not some ugly, sluggish Java thing).
> 
> ---
> Justin French
> http://indent.com.au
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



-- 
---
eric marden
http://xentek.net
---

--- End Message ---
--- Begin Message ---
--- Matt Wondra <[EMAIL PROTECTED]> wrote:
> I'm trying to include a file from an HTTP Authenticated server
> in PHP. I have a valid username and password. Is there any way
> to remotely login and include the file?
> 
> Ex:
> 
> include("https://www.url.com/incl1.php";);

When allow_url_fopen is enabled, you can include a remote URL, similar to
what you've shown. What PHP does for you is send an HTTP request to the
remote server, receive the response, and include the content just as if
you included a local file.

It is this request that PHP sends that needs to have the Authorization
header. To my knowledge, there is no way to add your own headers to this
request made on your behalf, although you could certainly hack PHP's
source to allow such a thing.

What you can do is write your own code to make a request. I'll give you a
quick example, but keep in mind that I'm just typing this out in an email,
and it is likely to contain bugs. :-)

--
$username = 'myuser';
$password = 'mypass';
$host = 'example.org';
$path = '/path/to/script.php';
                                                                          
                                               
$authorization = base64_encode("$username:$password);
$http_response = '';
                                                                          
                                               
$fp = fsockopen($host, 80);

fputs($fp, "GET $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Authorization: $authorization\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);

while (!feof($fp))
{
     $http_response .= fgets($fp, 128);
}

fclose($fp);
--

Your example cites a URL with the https scheme. To speak SSL, this example
will of course require some enhancements, but hopefully this answers your
question.

Chris

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

PHP Security - O'Reilly
     Coming Fall 2004
HTTP Developer's Handbook - Sams
     http://httphandbook.org/
PHP Community Site
     http://phpcommunity.org/

--- End Message ---
--- Begin Message --- Gerben wrote:
hi there

I have a problem with installing PHP on my winXp with apache server using the installer. I'm missing the sapi directory ("c:/progra~1/php/sapi/") with in it the php4apache.dll file which apache misses.
The weird thing is that I've succesfully installed php and apache on this same machine, but now it's not working.
I've copied my httpd.conf and php.ini files from my last (succesfull) installation.


I have apache 1.3.28 and php 4.3.4 (but the latest version 4.3.8 also doesn't work)

Please help |:-(


Are your paths the same as they were in your last install? If not, you need to update the conf files. Especially your modules directory


You might read along the PHP manual install instructions and verify everythings in the right place. I always prefer the manual install anyway. I usually place php4apache.dll (and php4ts.dll) in the Apache root, or Apache/modules directory

If all else fails you could uninstall and try the WAMP bundle.

--
Chris Martin
Web Developer
Open Source & Web Standards Advocate
http://www.chriscodes.com/

--- End Message ---
--- Begin Message --- Jack Gates wrote:
Every time I post to the list, I get an undeliverable on the address below. Does any one else get this?

If this address is on the list can we get it removed?

To:      [EMAIL PROTECTED]
Subject: [PHP] PHP site ?

was undeliverable due to the following reason:

[EMAIL PROTECTED] - User doesn't exist or is inactive.



I don't get them from that address, but I get them from

From: "Mailer Iguanahosting.com" <[EMAIL PROTECTED]>
Subject: Destinatario No exitente

On top of that I've received post confirmations for messages I never sent. Hopefully since I never confirmed them, they never made it. I don't want to be considered one of the spammers that I'd like to knock the F* out.


-- Chris Martin Web Developer Open Source & Web Standards Advocate http://www.chriscodes.com/

--- End Message ---
--- Begin Message ---
Sorry!  Chris, I meant to send this to the list.

On Saturday 04 September 2004 10:17 pm, Chris Martin wrote:
> Jack Gates wrote:
> > Every time I post to the list, I get an undeliverable on the address
> > below. Does any one else get this?
> >
> > If this address is on the list can we get it removed?
> >
> > To:      [EMAIL PROTECTED]
> > Subject: [PHP] PHP site ?
> >
> > was undeliverable due to the following reason:
> >
> > [EMAIL PROTECTED] - User doesn't exist or is inactive.
>
> I don't get them from that address, but I get them from
>
> From: "Mailer Iguanahosting.com" <[EMAIL PROTECTED]>
> Subject: Destinatario No exitente

I get that one also.  So far those are the only two.

>
> On top of that I've received post confirmations for messages I never
> sent. Hopefully since I never confirmed them, they never made it. I
> don't want to be considered one of the spammers that I'd like to knock
> the F* out.

I send addresses to spamcop.net all the time.

>
>
> --
> Chris Martin
> Web Developer
> Open Source & Web Standards Advocate
> http://www.chriscodes.com/

-- 
Jack "Rhino" Gates, Registered Linux user #342662
Morning Star Communications, www.morningstarcom.net
Web Hosting, Site Design, Domain Registration,
VMware Workstation Software and GSX Server Software

--- End Message ---
--- Begin Message ---
I get bounces from both addresses mentioned, but not every time it
seems (must only happen why I reply to one of their questions and CC
them I think). I also used to get vacation messages off someone but
that's stopped now.

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

 

I want to build a music site, all copyrights intact, and I want users to be
able to download mp3 or realplayer files using a one-click link. When they
click on a link they will simply be given a typical download window to save
that music file. How do I go about doing that and how should my file
structure work? What should the link include? Is it possible to just say,
for example, http://somesite.com/music/something.mp3? Also, if I wanted them
to listen to streamed music does PHP have any specialized functions I could
use to achieve that? I just need some direction. Any help would be
appreciated. Thank you.

 

Nilaab

 


--- End Message ---
--- Begin Message ---
Hi.

> What should the link include? Is it possible to just say,
> for example, http://somesite.com/music/something.mp3?

There shuoldn't be any problem in just writing the link. You could make the
syntax like this:
print "<a href=\"http://domain.com/link/to/your/file.mp3\"; title=\"Name of
your MP3 File\">";

>Also, if I wanted them
> to listen to streamed music does PHP have any >specialized functions I
could
> use to achieve that?

Not that i know of, but it is possible to make an audio player in
javascript. You can do a search on Google on that

Regards
Anders from DK

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:

Hello everyone,



I want to build a music site, all copyrights intact, and I want users to be
able to download mp3 or realplayer files using a one-click link. When they
click on a link they will simply be given a typical download window to save
that music file. How do I go about doing that and how should my file
structure work? What should the link include? Is it possible to just say,
for example, http://somesite.com/music/something.mp3?
If you want more control over the files you could have the mp3's in a private directory, then using PHP to force a download. There are some other threads about the Content-Type header, which is probably what you're looking for

Imagine that your file, 3416.mp3 is in /songs. 3416 is the song ID, so you can grab info such as artist, album and song name from a DB. Below is download.php, to download 3416.mp3, you should type download.php?file=3416

        <?php

if (!isset($_GET['file']) or !file_exists('songs/' . $_GET['file'] . '.mp3')) {
die("No file selected");
} else {
$file = $_GET['file'];
}


        $db = mysql_connect();
        // More DB stuff

        $artist = $row['artist']; // The artist name from the DB
        $album  = $row['album']; // ...
        $song   = $row['song']; // ...

        $filename = $artist . '-' . $album . '-' . $song . '.mp3';

        header('Content-Type: application/force-download');
        header('Content-Length: ' . filesize('songs/'.$file.'.mp3'));
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        header('Content-Transfer-Encoding: binary');

        readfile('songs/' . $file . 'mp3');
        exit();

        ?>



Also, if I wanted them
to listen to streamed music does PHP have any specialized functions I could
use to achieve that?

You should take a look at the Ming library and the mp3 stream function (http://www.php.net/manual/en/function.swfmovie.streammp3.php). It's a bit tricky though, but i can't think of anything else.


--
Daniel Schierbeck

--- End Message ---
--- Begin Message ---
I'm having a problem figuring out how to deal with foreign characters in
text that was copied from an MS Word document and pasted into a form field.

I'm not how sure this is getting stored in the MySQL database, but, when I
run htmlentities() on this text, each foreign character is converted into 2
other foreign characters that don't at all represent the original.

For example, a lowercase u with an umlat over it (�) is somehow displayed as
an uppercase A with an umlat over it followed by the 1/4 symbol after parsed
by htmlentities(). A lowercase o with an ulmat displays as an uppercase A
with an umlat over it followed by the paragraph symbol. It seems that the
uppercase A w/umlat is a constant, and the next character changes.

The ord() function returns the same number for all of these foreign
characters: 195. So, I'm not sure what's happening with these foreign
characters, and if there's any way to convert them to proper htmlentities
before being displayed in a browser. I thought htmlentities would do this,
actually.

Thanks!

Monty.

--- End Message ---
--- Begin Message --- Well it seems you have a UTF-8 encoded text after your function. Use iconv to change it. See http://de3.php.net/manual/en/ref.iconv.php .

try doing this with your array before inserting it into the DB

foreach($insert_array as $key => $var){
        $new_arr[$key] = iconv("UTF-8", "ISO-8859-1", $var);
}

It can be that your array has a different coding than UTF-8 check the manual for the htmlentities function, but i'm pretty shure that should solve it.

I2eptilex

Monty wrote:

I'm having a problem figuring out how to deal with foreign characters in
text that was copied from an MS Word document and pasted into a form field.

I'm not how sure this is getting stored in the MySQL database, but, when I
run htmlentities() on this text, each foreign character is converted into 2
other foreign characters that don't at all represent the original.

For example, a lowercase u with an umlat over it (�) is somehow displayed as
an uppercase A with an umlat over it followed by the 1/4 symbol after parsed
by htmlentities(). A lowercase o with an ulmat displays as an uppercase A
with an umlat over it followed by the paragraph symbol. It seems that the
uppercase A w/umlat is a constant, and the next character changes.

The ord() function returns the same number for all of these foreign
characters: 195. So, I'm not sure what's happening with these foreign
characters, and if there's any way to convert them to proper htmlentities
before being displayed in a browser. I thought htmlentities would do this,
actually.

Thanks!

Monty.

--- End Message ---
--- Begin Message ---
Jack Gates wrote:

I replaced this:
$address = getenv("REMOTE_ADDR");

with this

$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
and now I am getting exactly what I was trying to get.

This will work fine for networks that provide their own 'REMOTE_ADDR', but once proxies are in the way, you will see a proxy address rather than the real machine.


My own connection gives
You are host81-138-11-136.in-addr.btopenworld.com
for the osCommerce site. Probably good enough, but not really me ;)

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services

--- End Message ---
--- Begin Message ---
* and then Dre declared....
> I'm sorry about the capital letters
> and nop I'm not prepending any files at all

Can I get a look at the file?
-- 
Nick W

--- End Message ---
--- Begin Message --- Hi,
I came across a strange behaviour in array_merge since I installed php5.
I merge three arrays, one of them can be empty. So not an array at all.
In php 4.3.6 that I had before, there was no warning and the two first arrays were merged. In php5 on the other hand, there is a warning and my array is empty.
Is this behaviour wanted? Or is this just me having this problem?
I find it pretty ugly, either there is more than a warning, or at least the first two arrays should be merged and given back.


$array_1 = array('key1'=>'oranges','key2'=>'apples');

        $array_2 = array('key3'=>'pears','key4'=>'tomatoes');
        $array_3 = null;
        $arr_gemerged = array_merge($array_1,$array_2,$array_3);

        print_r($arr_gemerged);

Result on php4:
Array ( [key1] => oranges [key2] => apples [key3] => pears [key4] => tomatoes )



Result on php5:
Warning: array_merge() [function.array-merge]: Argument #3 is not an array in /Library/WebServer/Documents/regis24/admin/test_array_merge.php on line 7



I would define this behaviour as backwards incompatible. How about you?


Sebastian

--- End Message ---
--- Begin Message ---
You can find more info about this here:
http://www.php.net/manual/en/migration5.incompatible.php

I2eptilex wrote:
Hi,
I came across a strange behaviour in array_merge since I installed php5.
I merge three arrays, one of them can be empty. So not an array at all.
In php 4.3.6 that I had before, there was no warning and the two first arrays were merged. In php5 on the other hand, there is a warning and my array is empty.
Is this behaviour wanted? Or is this just me having this problem?
I find it pretty ugly, either there is more than a warning, or at least the first two arrays should be merged and given back.


$array_1 = array('key1'=>'oranges','key2'=>'apples');

        $array_2 = array('key3'=>'pears','key4'=>'tomatoes');
        $array_3 = null;
        $arr_gemerged = array_merge($array_1,$array_2,$array_3);

        print_r($arr_gemerged);

Result on php4:
Array ( [key1] => oranges [key2] => apples [key3] => pears [key4] => tomatoes )



Result on php5:
Warning: array_merge() [function.array-merge]: Argument #3 is not an array in /Library/WebServer/Documents/regis24/admin/test_array_merge.php on line 7



I would define this behaviour as backwards incompatible. How about you?


Sebastian

--- End Message ---

Reply via email to