Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199903

Re: [PHP3] [Fwd: 2 small questions...] From: Manuel Lemos (mlemos <email protected>)
Date: 03/17/99

Hello Mario,

On 17-Mar-99 17:42:53, you wrote:

>Number 1 - I want to produce a CSV file of a set of records from a
>database so that the users can import it into Excel (or similar). I'm
>forcing the browser to present the save dialog using a bogus
>Contents-Type, but it allways presents the same default name (the name
>of the php file). IS there a way to change this ?

Yes, rename your script as you wish it to be called and use .htaccess
or Apache main configuration files to tell that the file is to be handle
as PHP script. Make sure that the Content-Type header is set in the script
to application/octet-stream .

>Number 2 - the very same files are going to be treated by the users and
>then re-imported to the system. Each line has a student number, the
>grade, and an adittional note. I read a line with fgets, then explode it
>using "," as the separator. There is a possibilitie that the first
>contains the headers instead of info, but it might not be there either.
>So i thought about testing the first field by doing is_int($dados[0]).
>$dados[0] is an integer (I insert into postgres on an int field and it
>doesn't complain) but is_int returns nothing and neither does is_string
>! So the question is : am i using is_int wrongly or is this pure and
>simply broken (unlikely?)?

is_int does not tell if a string is an integer. It just tells if a varaible
is an PHP integer. If you read the data as a string it will always be a
string even if it contains digits.

To check if it is a valid integer I usually do it like this:

$value=intval($data);
if("$value"=="$data")
        echo "$value is an integer";

Keep in mind that there must be no spaces arround the integer data.

Regards,
Manuel Lemos

E-mail: mlemos <email protected>
URL: http://www.e-na.net/the_author.html
PGP key: finger://mlemos <email protected>

--

-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>