php-general Digest 26 Feb 2010 18:40:07 -0000 Issue 6611

Topics (messages 302398 through 302406):

header function query
        302398 by: Nick allan
        302399 by: Richard Quadling
        302402 by: Rene Veerman

weird behavior: Apache mod rewrite
        302400 by: Alberto Lepe
        302401 by: Ashley Sheridan

JPGraph error.
        302403 by: João Cândido de Souza Neto

Re: Database design
        302404 by: Nathan Rixham
        302405 by: Robert Cummings

Re: ctype_print, the British Pound and other non-ASCII characters
        302406 by: Nathan Rixham

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


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

The situation is as follows

I've read some data in from a couple of files into a string variable, made
some changes to it and want to send the contents of the string out to the
browser as a word document.

My code currently looks like the following

header('Content-Type: application/msword');

                header('Content-Disposition: attachment;
filename="preq.doc"');

ob_clean();

echo $allText;

 

 

The above code works fine, the client gets a file download dialogue and can
save or open the file.

How can I indicate end of file, then continue writing html to display a new
page. I want to be able to ask the user some additional questions after they
have downloaded the file.  My problem is that if I add any html code after
the above echo statement, it is included in the downloaded file.

There's probably a simple answer to this, but I haven't been able to find
anything using google.

 

Thanks in advance for any suggestions.

 

Regards Nick

 


--- End Message ---
--- Begin Message ---
On 26 February 2010 06:49, Nick allan <nal...@wdev.net> wrote:
> Hi all
>
> The situation is as follows
>
> I've read some data in from a couple of files into a string variable, made
> some changes to it and want to send the contents of the string out to the
> browser as a word document.
>
> My code currently looks like the following
>
> header('Content-Type: application/msword');
>
>                header('Content-Disposition: attachment;
> filename="preq.doc"');
>
> ob_clean();
>
> echo $allText;
>
>
>
>
>
> The above code works fine, the client gets a file download dialogue and can
> save or open the file.
>
> How can I indicate end of file, then continue writing html to display a new
> page. I want to be able to ask the user some additional questions after they
> have downloaded the file.  My problem is that if I add any html code after
> the above echo statement, it is included in the downloaded file.
>
> There's probably a simple answer to this, but I haven't been able to find
> anything using google.
>
>
>
> Thanks in advance for any suggestions.
>
>
>
> Regards Nick
>
>
>
>

Under normal conditions, you can't.

A request is for a single thing. While it is potentially possible to
embed graphics, css, js into a single html file request, downloading
files is not.

Instead, you issue the html first, but include in the <head> tag, a
<meta> redirect tag to the URL just for the download file.




-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
output the html you want to send afterwards first,

then either put a link to another script that outputs the word file,
or have an auto-launch ajax routine (i recommend jquery.com for ajax)
do it automatically.

On Fri, Feb 26, 2010 at 7:49 AM, Nick allan <nal...@wdev.net> wrote:
> Hi all
>
> The situation is as follows
>
> I've read some data in from a couple of files into a string variable, made
> some changes to it and want to send the contents of the string out to the
> browser as a word document.
>
> My code currently looks like the following
>
> header('Content-Type: application/msword');
>
>                header('Content-Disposition: attachment;
> filename="preq.doc"');
>
> ob_clean();
>
> echo $allText;
>
>
>
>
>
> The above code works fine, the client gets a file download dialogue and can
> save or open the file.
>
> How can I indicate end of file, then continue writing html to display a new
> page. I want to be able to ask the user some additional questions after they
> have downloaded the file.  My problem is that if I add any html code after
> the above echo statement, it is included in the downloaded file.
>
> There's probably a simple answer to this, but I haven't been able to find
> anything using google.
>
>
>
> Thanks in advance for any suggestions.
>
>
>
> Regards Nick
>
>
>
>

--- End Message ---
--- Begin Message ---
Hello everyone, this is my first time in this mailing list.
Using: PHP Version 5.2.10-2ubuntu6.4, Apache/2.2.12

I'm redirecting all the request into one file with ( .htaccess ):

RewriteEngine On
RewriteRule .* index.php

My index code is:

<?php  echo $_SERVER["REDIRECT_URL"];  ?>

In the same directory I just have other file besides index.php. And
depends on how this file is named, I'm getting
different values for the same request:

Request: /menu.html

Filename: menu.html
Output: /menu.html
Result: OK!

Filename: menu.html.bak
Output: /menu.html.bak
Result: NOT GOOD!

Filename: menu.html.whatever.other
Output: ERROR 404 (from apache)
Result: NOT GOOD!

Could someone please explain me why I'm getting this weird behavior?

As the request is the same, I expected to display always the same
value. Am I'm wrong??

Thank you.

--- End Message ---
--- Begin Message ---
On Fri, 2010-02-26 at 18:39 +0900, Alberto Lepe wrote:

> Hello everyone, this is my first time in this mailing list.
> Using: PHP Version 5.2.10-2ubuntu6.4, Apache/2.2.12
> 
> I'm redirecting all the request into one file with ( .htaccess ):
> 
> RewriteEngine On
> RewriteRule .* index.php
> 
> My index code is:
> 
> <?php  echo $_SERVER["REDIRECT_URL"];  ?>
> 
> In the same directory I just have other file besides index.php. And
> depends on how this file is named, I'm getting
> different values for the same request:
> 
> Request: /menu.html
> 
> Filename: menu.html
> Output: /menu.html
> Result: OK!
> 
> Filename: menu.html.bak
> Output: /menu.html.bak
> Result: NOT GOOD!
> 
> Filename: menu.html.whatever.other
> Output: ERROR 404 (from apache)
> Result: NOT GOOD!
> 
> Could someone please explain me why I'm getting this weird behavior?
> 
> As the request is the same, I expected to display always the same
> value. Am I'm wrong??
> 
> Thank you.
> 


What weird behavior are you meaning?

If you request menu.html.bak, that's what your PHP script will see a
request for.

I'm not quite sure I understand exactly what you expect to happen here.
You make a request for '/menu.html'. Are you then saying you randomly
get given back different output from your PHP? In the above examples,
filename has no context, as you're not doing anything with any files in
your PHP script.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Hey guys.

In my system we´ve got an option of getting charts of some data and it´s 
many options.

My problem is that it works fine on my test server but in my client´s server 
it gives me the following error as you can see.

*** glibc detected *** /var/www/html/bin/httpd: munmap_chunk(): invalid 
pointer: 0x0a319b78 ***
======= Backtrace: =========
/lib/libc.so.6(cfree+0x1bb)[0x17d81b]
/var/www/html/modules/libphp5.so(_efree+0x7e)[0x4bd35e]
/var/www/html/modules/libphp5.so(zend_hash_destroy+0x5c)[0x4dbd7c]
/var/www/html/modules/libphp5.so(_zval_dtor_func+0x55)[0x4d27e5]
/var/www/html/modules/libphp5.so(_zval_ptr_dtor+0x4f)[0x4c7f0f]
/var/www/html/modules/libphp5.so(zend_hash_destroy+0x36)[0x4dbd56]
/var/www/html/modules/libphp5.so(destroy_zend_class+0x3a)[0x4cb86a]
/var/www/html/modules/libphp5.so[0x4dba07]
/var/www/html/modules/libphp5.so(zend_hash_reverse_apply+0x57)[0x4dbb47]
/var/www/html/modules/libphp5.so(shutdown_executor+0x404)[0x4c85c4]
/var/www/html/modules/libphp5.so(zend_deactivate+0x93)[0x4d2e83]
/var/www/html/modules/libphp5.so(php_request_shutdown+0x1e0)[0x497bd0]
/var/www/html/modules/libphp5.so[0x548927]
/var/www/html/bin/httpd(ap_run_handler+0x59)[0x8074bf9]
/var/www/html/bin/httpd(ap_invoke_handler+0x67)[0x8077d67]
/var/www/html/bin/httpd(ap_process_request+0x178)[0x808e308]
/var/www/html/bin/httpd[0x808b60b]
/var/www/html/bin/httpd(ap_run_process_connection+0x59)[0x807bb19]
/var/www/html/bin/httpd[0x80a1240]
/var/www/html/bin/httpd[0x80a1537]
/var/www/html/bin/httpd(ap_mpm_run+0x880)[0x80a1e90]
/var/www/html/bin/httpd(main+0x845)[0x80629d5]
/lib/libc.so.6(__libc_start_main+0xdc)[0x129f2c]
/var/www/html/bin/httpd(apr_os_proc_mutex_put+0x5d)[0x8061be1]
======= Memory map: ========
[Thu Feb 25 16:17:20 2010] [notice] child pid 2850 exit signal Aborted (6)

Does anybody know why is it happening?

Thanks in advance.
João. 



--- End Message ---
--- Begin Message ---
Angus Mann wrote:
> Hi all. I know this is not strictly a PHP question but the code will be 
> written in PHP, and I figure the folks here will be well versed in the 
> questions I raise. Please feel free to contact me off the list if appropriate.
> 
> I need some assistance with database design for a project I'm coding in PHP. 
> I'm willing to pay for the advice, since I think it will be a bit complex. I 
> plan to use MySQLi
> 
> If anybody feels they can assist, or can point elsewhere please feel free to 
> contact me off list, or reply to the list if you think appropriate.
> 

Best tip I can give is to model out all your data first (using UML or
suchlike) then figure out the tables to hold it from that; your database
should not dictate the model of the data; also if you design to a model
then your codebase need never change when it becomes time to change to a
different RDMBS or even a completely different way of persisting your
data :)

regards!

--- End Message ---
--- Begin Message ---
Nathan Rixham wrote:
Angus Mann wrote:
Hi all. I know this is not strictly a PHP question but the code will be written 
in PHP, and I figure the folks here will be well versed in the questions I 
raise. Please feel free to contact me off the list if appropriate.

I need some assistance with database design for a project I'm coding in PHP. 
I'm willing to pay for the advice, since I think it will be a bit complex. I 
plan to use MySQLi

If anybody feels they can assist, or can point elsewhere please feel free to 
contact me off list, or reply to the list if you think appropriate.


Best tip I can give is to model out all your data first (using UML or
suchlike) then figure out the tables to hold it from that; your database
should not dictate the model of the data; also if you design to a model
then your codebase need never change when it becomes time to change to a
different RDMBS or even a completely different way of persisting your
data :)

Although, and I'm just raising awareness here since there's nothing inherently wrong with what Nathan has said... when you design to a model specifically, rather than to the target medium, your solution will be almost certainly be less efficient. Also, there are different skills to be had from the tree of learning. If you build to the model first then you learn to abstract. If you build to a specific medium and then later need to change mediums, then you learn to refactor. Given the wide amount of crappy code in existence... the latter IMHO, is the more useful skill in most scenarios... but then again, you'll probably get lots and lots of practice at that anyways :B

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
Bob wrote:
> I'm seeing mischief from ctype_print.
> 
> So far as I can tell, the British Pound symbol, '£' is considered a 
> printable character according to the locale I use on my Ubuntu box. But 
> even across two years, two boxes, several versions of Ubuntu (from 7.04 
> to 9.10, one x86, one AMD64), and two major versions of PHP (PHP 4 and 
> now PHP 5.2.11), I cannot get ctype_print to return true when a string 
> given to it contains the British Pound symbol. (Or other non-ASCII 
> characters such as ø or ß.)
> 
> The locale I'm using is en_GB.UTF-8 and when I call setlocale(LC_ALL, 
> 'en_GB.UTF-8') in PHP, it returns the name of this locale rather than 
> FALSE, so that seems to be in order. (However, to be sure I have 
> installed and reinstalled the language pack in Ubuntu as suggested by 
> others.)
> 
> I've even read through the en_GB and i18n locale definition files to 
> confirm that <U00A3> (for the British Pound symbol) does appear within 
> the print and graph sections, so both ctype_print and ctype_graph should 
> consider it acceptable.
> 
> What's most maddening is that ctype_print does return true on my shared 
> hosting server, so I know that it can be achieved. I'm just hoping that 
> someone here can tell me what I'm doing wrong, or what my operating 
> system is doing wrong.
> 
> For your information, I'm currently running the following:
> 
> Ubuntu 9.10 (AMD64)
> Apache 2.2.14
> PHP 5.2.11 running as a CGI (to mirror the config of my shared host)
> Locale in use: en_GB.UTF-8
> LANG=en_GB.UTF-8
> 
> Can anyone tell me how to get ctype_print to behave?

Tested on a few ubuntu boxes (8&9s) and:

When using en_US.utf8 all is fine

var_dump( ctype_print( 'abcd ef £ ghs als kl ,!' ) ); // TRUE

then:

# locale-gen en_GB.UTF-8
Generating locales...
  en_GB.UTF-8... done
Generation complete.

# locale -a
C
en_GB.utf8
en_US
en_US.utf8
POSIX

setlocale(LC_ALL, 'en_GB.UTF-8');
var_dump( ctype_print( 'abcd ef £ ghs als kl ,!' ) ); // FALSE

wondering if this is a PHP issue or a mapping generation issue on ubuntu..

have you checked the output of #locale to ensure LC_CTYPE is set to the
appropriate value?

regards!

--- End Message ---

Reply via email to