Re: [PHP] how to read the stuff that got piped (

2003-05-27 Thread Alex Earl
> hi,
>
> i've a simple question:
>
> how can i read the stuff that got piped ("|") to the php-script?
>
> i.e. "ls -l | /home/myuser/phpscript.php"
[snip]

It is the stdin of the script, you can open that file handle with fopen(
"stdin", "r" ); i believe

Slide

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



RE: [PHP] sound

2003-05-30 Thread Alex Earl
I'm guessing perhaps you didn't upload the sound to the server when you
uploaded the webpage?

Slide

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



Re: [PHP] How to secure a download ?

2003-06-01 Thread Alex Earl
> header("Content-type: application/zip");
> header("Content-Disposition: attachment; filename=yourfilename.zip");
> readfile("/path/to/yourfilename.zip");
>

I have found that to make sure it works with all browsers you want to put
quotes around the filename in the content-disposition header.

header( "Content-tpye: application/zip" );
header( "Content-Disposition: attachment; filename=\"yourfile.zip\" );
readfile( "/path/to/yourfilname.zip" );

the reason I say this is because without the quotes, some browsers insert
a "[1]" or something similar without them.

Alex

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



Re: [PHP] Downloading a file.

2003-06-11 Thread Alex Earl
>
> If he wants to download, in the file downloadit.php, there is:
> header("Content-type: application/octet-stream\n");
> header("Content-Disposition: attachment; filename=mysoft-1.0-truc.zip");
> header('Cache-Control: public');
> header("Content-transfer-encoding: binary\n");
> header("Content-length: " . filesize($path) . "\n");
> $fp=fopen($path, "r");
> fpassthru($fp);
>
> But, with IE, it saves the file with [] as:
> mysoft-1.0[1]-truc.zip
> And with Netscape 7.x, it saves the file with the .php extension:
> mysoft-1.0-truc.zip.php
>
> Does anyone know what to do to make it saved as: mysoft-1.0-truc.zip
>
> And I would like to display a page telling "Thanks for download" or
> something...but if I had to the end:
> header("Location: http://www.mywebsite.com/thanks.html";) ;
> I does not work :(
>
> Does anyone know how change the location and is there is anyway to know
> if the download has been perfomed 'till the end...
>
> Thanks,
> Vincent.

There is no way to tell if the download completes, I don't think, that is
a client side thing that if you send the content-length header it should
know if the file downloaded successfully or not, the browser does not send
a "success" signal back. Also, if you put quotes around the filename in
the Content-Disposition header, it will save the file with the exact
filename you specify, the RFC doesn't specifiy that it has to be this way,
but I have found that putting quotes around it makes it work for pretty
much any browser I have tried.

For your other problems, I would deconstruct them one by one and try and
get a piece of it working and then put the pieces together, it sounds like
you are trying to get too much done in one pass and it is causing you
problems.

Cheers,

Slide

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



Re: [PHP] getting file contents

2003-06-11 Thread Alex Earl
> I have text a file which contains php code.  I am using it as a template
> for some other pages.  I want to take everything in that file and store it
> in a string or array and then output it all to an empty file (this will
> make both files look exactly the same).  I am using the
> file_get_contents() function to do this, but it seems to have trouble
> because it looks like it is trying to execute the php code in the file I
> am trying to get.  Anyone know of a better way to go about this?  Thanks.
>
> Matt


$file_data = join( '', file( '/path/to/file' ) );

Alex


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



Re: [PHP] form name and submit test

2003-06-11 Thread Alex Earl
> At 6/11/2003 09:42 AM, Amanda McComb wrote:
>
>  > If I have multiple forms on a page, and each form has it's own name,
> how
>  > can I tell which form has submitted?
>
> By its contents.
>

Give the submit buttons different names, then you can test to see which
one is set to see which form was submitted.

Alex

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



Re: [PHP] slash trouble when editing text

2003-06-11 Thread Alex Earl
Sounds like you have magic quotes turned on in your php.ini. I would check
that out.

Alex


> Will the stripslashes() remove the slashes that are supposed to be in the
> file?  Because often times there are slashes in the file that need to be
> there.
>
> Matt
> - Original Message -
> From: "CPT John W. Holmes" <[EMAIL PROTECTED]>
> To: "Matt Palermo" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Wednesday, June 11, 2003 4:42 PM
> Subject: Re: [PHP] slash trouble when editing text
>
>
>> Use stripslashes() to remove the slashes. Use htmlentities() on the text
>> before you put it into the , also.
>>
>> ---John Holmes...
>>
>> - Original Message -
>> From: "Matt Palermo" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Wednesday, June 11, 2003 4:16 PM
>> Subject: [PHP] slash trouble when editing text
>>
>>
>> I wrote a small script that creates a link to all the .php and .txt
>> files
> in
>> a given directory.  When one of these links is clicked, it brings up
> another
>> window with the files contents inserted into a text area.  From there
>> the
>> user can edit the text file then click a submit button to make the
> changes.
>> The problem is whenever the file contains quotes, when the file gets
> edited
>> it puts a slash in front of every quote.  Like this.
>>
>> // original .txt file
>> "these are quotes"
>>
>> Then when the submit buttons is clicked, the file looks like this:
>>
>> // edited .txt file
>> \"these are quotes\"
>>
>> If submit is pressed again, then it will look like this:
>>
>> // twice edited file
>> \\"these are quotes\\"
>>
>> Does anyone know how I can avoid this from happening?  Thanks.
>>
>> Matt
>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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



Re: [PHP] How to find if a string is an integer?

2003-06-12 Thread Alex Earl

> Sorry, I don´t know that you needed an effective snipet. And you are
> right,
> I only writed for positive integers. Try something like apply 2 type cast
> simunltaneous.
>
> if ( (string) ((int) $_POST["var_int"]) == $_POST["var_int"])
> echo "is int";
>


Why not just use the is_int() function?

www.php.net/is_int


Alex

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



Re: [PHP] How to find if a string is an integer?

2003-06-12 Thread Alex Earl
>> 
>> > Sorry, I don´t know that you needed an effective snipet. And you are
>> > right,
>> > I only writed for positive integers. Try something like apply 2 type
> cast
>> > simunltaneous.
>> >
>> > if ( (string) ((int) $_POST["var_int"]) == $_POST["var_int"])
>> > echo "is int";
>> >
>>
>>
>> Why not just use the is_int() function?
>>
>> www.php.net/is_int
>
> Please try to use is_int() on a value passed from a form and see why.
>
> Also, in the beginning of this thread, the OP already said that is_int()
> had
> been tried.
>
> ---John Holmes...
>

I guess I missed the first part of the thread then.

Thanks for the info.

Alex



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



Re: [PHP] How to find if a string is an integer?

2003-06-12 Thread Alex Earl
> Jumping in a little late here, but what about is_numeric()?
> Haven't tried it, but the php manual for is_int says:
> Note:  To test if a variable is a number or a numeric string (such as
> form input, which is always a string), you must use is_numeric().
>

The problem with is_numeric() is that something like "4e4" comes up as
true, because it could be construed as a HEX value.

Alex

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



Re: [PHP] Error display

2003-06-12 Thread Alex Earl
> I have error reporting set to E_ALL, but no matter what I do, no errors
> display.  Is there somewhere else in the .ini that I have to set
> something?
>

I believe there is a print_errors or show_errors directive in the php.ini
file. Check on php.net for sure.

Alex

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



Re: [PHP] make a variable not exist?

2003-06-12 Thread Alex Earl
>
> Is there a way to make a variable not exist?  There are several places
> where I test (!$variable), and I want to be able to change the
> variable to pass that test, even though it exists, under certain
> circumstances.
>
> Thanks.
>


You can unset the variable www.php.net/unset but also I would recommend
using if(!isset($variable)) instead of just if(!$variable) its a little
more clear as to what you are really trying to see I think.

Alex

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



Re: [PHP] stumped on mysql_num_rows

2003-06-13 Thread Alex Earl
Can you give us the query too?

Alex


> Hello List,
> The issue appears to be that no rows are being found with mysql_num_rows
> using the SQL LIMIT offset. There should be rows found. Further, all
> processing just halts, and no query is shown as per the code here:
>
>
> // RUN THE QUERY TO RETRIEVE EACH FOUND RECORD
> $queryResultHandle = mysql_query($concatquery, $link_identifier) or die (
> mysql_error());
> // make sure that we recieved some data from our query
> $rows = mysql_num_rows ($queryResultHandle);
> if ( $rows > 0 ) { //    THIS IS WHERE THE SCRIPT FAILS
>while ($data = mysql_fetch_array ($queryResultHandle)) {
>   /* /
>   // COMMON VARIABLE ASSIGNMENT BLOCK - start
>   $yflastupdate = $data["lastupdate"]; // and other fields too ...
>   // COMMON VARIABLE ASSIGNMENT BLOCK - end
>    */
>   include("showOneRecord.php");  // display the row values in a
> template
>} // while
>// mysql_free_result ($queryResultHandle);
> }else{
>echo"Process anomaly. Please try again.";
>echo $query;
>exit;
> }
>
>
> The result is intermittent failure with the message "Process anomaly.
> Please try again." when the first or subsequent "next page" button is
> clicked. No query shown with the failure, and a query should be shown.
>
>
> CONFIGURATION
> This issue is experienced intermittently on the developer production site
> and "always" on the customer  localhost and production sites. The customer
> is using "I just recently installed PHP and mySQL so they are pretty close
> to the latest versions.  I think it's PHP 4.3.1 and mySQL 4.0.13. I get
> the same error on both the first time I click the "More Results" button.
> My browser is IE 6.0.2800 SP1."
>
>
> What's the problem?
>
>
> Richard
> Information Services
> Global I.S. S.A.
> [EMAIL PROTECTED]
> ---
> Globalissa B2B Websites
> http://phpyellow.com
> http://www.dreamriver.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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



Re: [PHP] create a chmod'd file

2003-06-13 Thread Alex Earl
> I have a script that creates a php file based on user input.  I need this
> newly created file to have write permissions - chmod 777.  How can I have
> the script create the file with these permissions already set?  Is this
> possible?
>
> Thanks,
>
> Matt


How are you creating the file? fopen()? touch()? Give a little more
information please.

Alex

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



Re: [PHP] Will this work right?

2003-06-13 Thread Alex Earl
> The following function converts minutes to years, monthes, weeks, days,
> hours, minutes.  For instance, 61 minutes would become "1 hour, one
> minute".  Before I use it, I want to make sure there are no stupid
> mistakes.  I can't find any, can any of you?
> function min2ymwdhm($min){
> $a = array();
> $years = intval(intval($min) / 525600);
> if($years > 0) $array[] = $years . ' year' . ($years == 1 ? '' : 's');
> $monthes = intval(intval($min) / 43200) % 12;
> if($monthes > 0) $array[] = $monthes . ' month' . ($monthes == 1 ?
> '' : 'es');
> $weeks = intval(intval($min) / 10080) % 4;
> if($weeks > 0) $array[] = $weeks . ' week' . ($weeks == 1 ? '' : 's');
> $days = intval(intval($min) / 1440) % 7;
> if($days > 0) $array[] = $days . ' day' . ($days == 1 ? '' : 's');
> $hours = intval(intval($min) / 60) % 24;
> if($hours > 0) $array[] = $hours . ' hour' . ($hours == 1 ? '' : 's');
> $minutes = intval($min) % 60;
> if($minutes > 0) $array[] = $minutes . ' minute' . ($minutes == 1 ?
> '' : 's');
> return implode($array,', ');
> }
>


Why not just try it?

Alex

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



Re: [PHP] PLEASE STOP SENDING ME MAIL!!! PLEASE UNSUBSCRIBE NOW!!!

2003-06-13 Thread Alex Earl
Read the bottom of the email messages, it tells you how to unsubscribe.

Alex


> --- gregory landry <[EMAIL PROTECTED]> wrote:
>> I figured it out. Yipppee..
>>
>> Thanks
>>
>> -Original Message-
>> From: Gregory Landry [mailto:[EMAIL PROTECTED]
>> Sent: Friday, June 13, 2003 4:10 PM
>> To: [EMAIL PROTECTED]
>> Subject: [PHP] forms question -- simple
>>
>>
>> Hi all,
>>
>> I'm new to the list and to PHP. I haven't bought a
>> book as of yet but I've
>> found a number of resources that are getting me
>> through the basics.
>>
>> I am collecting data from a form. I've having no
>> problems collecting the
>> data and printing it out.  But...
>>
>> I have a form with check boxes with 4 options. See
>> below.
>>
> 
>>
>> > name=investment>
>> > name=vacation>
>> > name=retirement> > type=checkbox value=Primary Home  name=primary>
>>
>>
> 
>>
>> This form data is being sent off to a php page to
>> get the values printed
>> out. See below:
>>
>>
> 
>> **
>>
>> print "Which best describes your reason for wanting
>> to purchase land?";
>> print "$investment $investment2
>> $investment3 $investment4";
>>
>>
> 
>> **
>>
>> The problem is if a check box is not checked a blank
>> space gets printed out
>> which I don't want. Can someone show me how to use
>> an if then statement with
>> the following stucture:
>>
>>
> ***
>> if $investment  then print
>> $investment
>>
> ***
>>
>> I would use this structure for each of the variables
>> in the checkboxes
>> above. I'm sure this could be done with arrays in
>> some form or another but
>> since I'm new at this I would just as soon keep it
>> simple for now and learn
>> more sophisticated techniques later.
>>
>> Thanks so much,
>>
>> Greg Landry
>> [EMAIL PROTECTED]
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
> __
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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