Re: [PHP] header function query

2010-02-26 Thread Richard Quadling
On 26 February 2010 06:49, Nick allan  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  tag, a
 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

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



[PHP] weird behavior: Apache mod rewrite

2010-02-26 Thread Alberto Lepe
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:



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.

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



Re: [PHP] weird behavior: Apache mod rewrite

2010-02-26 Thread Ashley Sheridan
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:
> 
> 
> 
> 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




Re: [PHP] header function query

2010-02-26 Thread Rene Veerman
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  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
>
>
>
>

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



[PHP] JPGraph error.

2010-02-26 Thread Jo�o C�ndido de Souza Neto
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. 



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



[PHP] Re: Database design

2010-02-26 Thread Nathan Rixham
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!

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



Re: [PHP] Re: Database design

2010-02-26 Thread Robert Cummings

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

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



[PHP] Re: ctype_print, the British Pound and other non-ASCII characters

2010-02-26 Thread Nathan Rixham
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  (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!

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



[PHP] Post and Redirect

2010-02-26 Thread Shawn McKenzie
I remembered seeing this question on the list several times in the past,
so I thought I would post something I just hacked up for someone.

As we know, we can user header() to redirect the browser, but of course
we can't redirect the browser and have it post data to the new page.  If
you need to do this it will require javascript.  Here's a quick and
dirty function:

function http_post_redirect($url='', $data=array(), $doc=false) {

$data = json_encode($data);

if($doc) {
echo "";
}
echo "

var data = eval('(' + '$data' + ')');
var jsForm = document.createElement('form');

jsForm.method = 'post';
jsForm.action = '$url';

for (var name in data) {
var jsInput = document.createElement('hidden');
jsInput.setAttribute('name', name);
jsInput.setAttribute('value', data[name]);
jsForm.appendChild(jsInput);
}
document.body.appendChild(jsForm);
jsForm.submit();
";

if($doc) {
echo "";
}
exit;
}

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Help preserving sentence structure

2010-02-26 Thread John Tamm-Buckle
Hi, new to this list...

I'm adapting some code that generates text and want to keep the syntax.  In
the original version the output was iterated from an array in  tags.
 That was fine for what it was, but it's now a word press plugin and the
 tags get in the way.  How do I keep the sentence structure without
using s?  Also, I'm quite new to PHP in general... :)  Any help would
be much appreciated!

Below is an extract of the code with some highlighting for emphasis:

function wpm_display_generator() {

if (isset($_POST['submit_button'])) {

// the form was submitted to this script - generate
// and display
require_once 'lib/generator.php';
require_once "lib/util.php";
require_once "lib/vocabulary.php";
require_once "lib/widgets.php";

$vocab = Vocabulary::getInstance();
$cats = $vocab->getCategories();
$catName = '';
$sentence = '';
if (isset($_POST['category_choice'])) {
$catName = $cats[$_POST['category_choice']];
$gen = new wordGenerator($_POST['category_choice'],
$_POST['length_choice']);
$lines = $gen->generate();
foreach ($lines as $line) {
$sentence .= "" . $line . "";
}
}

require 'sentence.php';
}
else {
require 'generator_form.php';
}
}


Many thanks,

John

-- 
Out now:
Kvist 002 - Raglani - Web of Light - 12"
Kvist 003 - EOD - untitled - 12"
Kvist 004 - JD Emmanuel - Solid Dawn - CD
Kvist 005 - Guillaume Gargaud - Here - CD

Coming soon:
Kvist 006 - Tom Hamilton - Pieces for Kohn/Formal & Informal Music - CD

www.kvistrecords.com


[PHP] Registry class question.

2010-02-26 Thread Peter van der Does
Hi,

I've build a registry class to store settings I need to use in several
other classes.

Currently I've set it up with a static array in the registry class and
using two methods to access the settings and values
storeSetting($key,$value) {
  $this->_settings[$key] = $value;
}

getSetting($key) {
  return $this->_settings[$key];
}

The question is what the pros and cons are compared to setting a new
property with the value, like:

storeSetting($key,$value) {
  $this->$key = $value;
}

and then instead of calling getSetting, you just use
$this->Registry->property

-- 
Peter van der Does

GPG key: E77E8E98

IRC: Ganseki on irc.freenode.net
Twitter: @petervanderdoes

WordPress Plugin Developer
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Twitter: @avhsoftware

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



Re: [PHP] Post and Redirect

2010-02-26 Thread Ashley Sheridan
On Fri, 2010-02-26 at 13:26 -0600, Shawn McKenzie wrote:

> I remembered seeing this question on the list several times in the past,
> so I thought I would post something I just hacked up for someone.
> 
> As we know, we can user header() to redirect the browser, but of course
> we can't redirect the browser and have it post data to the new page.  If
> you need to do this it will require javascript.  Here's a quick and
> dirty function:
> 
> function http_post_redirect($url='', $data=array(), $doc=false) {
> 
>   $data = json_encode($data);
> 
>   if($doc) {
>   echo "";
>   }
>   echo "
>   
>   var data = eval('(' + '$data' + ')');
>   var jsForm = document.createElement('form');
>   
>   jsForm.method = 'post';
>   jsForm.action = '$url';
>   
>   for (var name in data) {
>   var jsInput = document.createElement('hidden');
>   jsInput.setAttribute('name', name);
>   jsInput.setAttribute('value', data[name]);
>   jsForm.appendChild(jsInput);
>   }
>   document.body.appendChild(jsForm);
>   jsForm.submit();
>   ";
> 
>   if($doc) {
>   echo "";
>   }
>   exit;
> }
> 
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com
> 


Someone mentioned on the whatwg mailing list that most browsers are
capable of understanding multipart content, so that you could send down
two types of content a bit like you'd send a multipart email.

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




Re: [PHP] Help preserving sentence structure

2010-02-26 Thread Ashley Sheridan
On Fri, 2010-02-26 at 14:11 -0600, John Tamm-Buckle wrote:

> Hi, new to this list...
> 
> I'm adapting some code that generates text and want to keep the syntax.  In
> the original version the output was iterated from an array in  tags.
>  That was fine for what it was, but it's now a word press plugin and the
>  tags get in the way.  How do I keep the sentence structure without
> using s?  Also, I'm quite new to PHP in general... :)  Any help would
> be much appreciated!
> 
> Below is an extract of the code with some highlighting for emphasis:
> 
> function wpm_display_generator() {
> 
> if (isset($_POST['submit_button'])) {
> 
> // the form was submitted to this script - generate
> // and display
> require_once 'lib/generator.php';
> require_once "lib/util.php";
> require_once "lib/vocabulary.php";
> require_once "lib/widgets.php";
> 
> $vocab = Vocabulary::getInstance();
> $cats = $vocab->getCategories();
> $catName = '';
> $sentence = '';
> if (isset($_POST['category_choice'])) {
> $catName = $cats[$_POST['category_choice']];
> $gen = new wordGenerator($_POST['category_choice'],
> $_POST['length_choice']);
> $lines = $gen->generate();
> foreach ($lines as $line) {
> $sentence .= "" . $line . "";
> }
> }
> 
> require 'sentence.php';
> }
> else {
> require 'generator_form.php';
> }
> }
> 
> 
> Many thanks,
> 
> John
> 


 tags don't do anything to mark up a sentence. If you need to
convert the hard returns to a  tag, then use nl2br()

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




RE: [PHP] Excel Spreadsheets and PHP

2010-02-26 Thread Ian Robertson
Thank you all very much for your replies.

I learned about a few new approaches.

I didn't see it come up yet, so I'll post the URL of what I have been using.

php_writeexcel - 
http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/

I've been able to pull off quite a bit with this class and actually have 
referenced this Perl page for documentation since this PHP class was ported 
from a Perl class - 
http://cpansearch.perl.org/src/JMCNAMARA/Spreadsheet-WriteExcel-0.37/WriteExcel/doc/WriteExcel.html

So, many thanks for your replies and also thanks to Johann and his 3 Bettinas, 
wherever you are, haha.

-Original Message-
From: Jay Blanchard [mailto:jblanch...@pocket.com] 
Sent: Sunday, February 21, 2010 9:44 PM
To: Ian Robertson; php-general@lists.php.net
Subject: RE: [PHP] Excel Spreadsheets and PHP

[snip]
What are you using, if anything, to create Excel spreadsheets with PHP?
[/snip]

PHP

http://www.evolt.org/node/26896



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



[PHP] Re: ctype_print, the British Pound and other non-ASCII characters

2010-02-26 Thread Bob
Hello, Nathan.

I'm glad to hear that someone else can reproduce the problem with 
en_GB.UTF-8. I was worried it was some bad luck quirk that I was never 
going to get to the bottom of.

I tried using en_US.utf8 (and also en_US.UTF-8) in setlocale (and it did 
not return false, so again looks like the locale is found and accepted). 
But I still got a return of false from ctype_print for non-ASCII 
characters. So even with en_US I'm getting bad behaviour.

When you switch back to en_US.UTF-8 (or en_US.utf8) do you get true from 
ctype_print as expected? (I'm hoping that you don't suddenly find 
ctype_print refuses to behave properly under all locales.)

Output from `locale` shows that all types are 'en_GB.UTF-8' except LC_ALL 
which is blank (as I believe it should be).

Do you know how I can dig further? I don't know anything about debugging 
PHP or Linux, so I don't know how to trace the source of this strange 
result.

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



[PHP] Re: ctype_print, the British Pound and other non-ASCII characters

2010-02-26 Thread Bob
In php.i18n, an interesting discussion about this problem has appeared.

It looks like the problem is Ubuntu and not PHP, as a short chunk of code 
written in C and using the native isprint equivalent to ctype_print also 
returns false for the British Pound symbol.

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



Re: [PHP] Help preserving sentence structure

2010-02-26 Thread Ryan Sun
http://us.php.net/manual/en/function.htmlentities.php

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



[PHP] PHP: inexplicable behaviour of pre- and post-increment operators

2010-02-26 Thread clancy_1
A week ago Dasn asked a question about converting arrays, and I quoted one 
possible way of
achieving his task, using the operation:

$i = 0; while ($i < $k) { $b[$a[$i++]] = $a[$i++];  }

I added the comment that "I have always been wary of using statements like this 
because I
was unsure when the incrementing would occur, so I tried it."

I received several CC e-mails replying to this post, including one rather 
critical comment
to the effect that pre-and post-increment were all quite simple, and I really 
ought to
learn the fundamentals before I started trying to do anything elaborate. 

I posted a reply to these e-mails, but as neither they, nor my reply, or any 
follow-up
discussion ever appeared in the discussion group I will repost this reply.  (I 
did have a
power failure at this time, so it is conceivable that any follow-up was lost as 
a result
of a glitch in my mailer, but I think it is more likely that there was a glitch 
in the
discussion group server.)

Unfortunately things aren't nearly as simple as this writer believes. The rule 
I have
always used is that if you use the same variable as an index on both sides of 
an assign
statement it is not safe to change the value of the index within the statement. 
While I
have achieved the result I wanted in the example above (using PHP 5.1.6 -- 
there is no
guarantee it would work with other implementations of PHP) the results of doing 
this in
the general case can be quite inexplicable.

The particular case which prompted my comment was the one where you want to 
copy part of
one array into the corresponding elements of another array.  In accordance with 
my rule, I
normally write:

$i = 0; $j=count($a); while ($i < $j) { $b[$i] = $a[$i]; ++$i; }

It is tempting to try to put the increment into the assignment statement. 
Clearly the
value of $a[$i] has to be read before it can be written to $b[$i], so the 
logical
expression would be:

while ($i < $j) { $b[$i++] = $a[$i]; }  A.

However if you try this, you get $b[1] = $a[0], and so on. But if you try the 
alternative:

while ($i < $j) { $b[$i] = $a[$i++]; }  B.

You get $b[0] = $a[1], and so on (as you would expect). 

Out of curiosity, I then tried:

$i = -1; $j=count($a) - 1; while ($i < $j) { $b[$i] = $a[++$i]; }   
C

This gave the desired result, and seemed moderately logical. However when I 
tried: 

$i = -1; $j=count($a) - 1; while ($i < $j) { $b[++$i] = $a[$i]; }   
D

This gave exactly the same result.  It is quite impossible to explain the 
results in cases
A and D from the definitions of the pre-and post-increment operator, so I think 
I will
stick to my safe rule!

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



[PHP] Header function

2010-02-26 Thread Nick allan
Hi all

Has anyone got any ideas why the following isn't giving me correct filename
in the ie save dialogue

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

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

 

I get the save dialogue, but with preq.doc instead of PurchaseReq.doc

Preq.php is the calling php file. It has worked before so I'm not sure what
I've changed to have it stop working.

 

 

Thanks in advance for any suggestions.

 

Regards Nick

 



[PHP] Uninstalling PHP?

2010-02-26 Thread Austin Powers
Three weeks ago I was working through the Lynda.com "PHP with MySQL
Training" because I wanted to begin using PHP (surprise, surprise).

Anyway, on this video course the teacher explains that because installing
PHP and MySQL is so well understood on a Mac that we may as well just follow
his steps and do it manually.  Well, he is installing a different version of
PHP and MySQL to the ones that I was able to download and while what he was
saying way somewhat similar I am guessing that  there is a difference
somewhere, and (well) it's not working.

I AM A COMPLETE NOVICE WITH LINUX/FREEBSD.  It had not been my intention to
learn the intricacies of Linux.  However, I am now neck deep in a mire of
confusion that even MAMP can't seem to sort out for me.

It is purely a guess that I need to start again from a complete clean setup
(reformatting my hard disk and reinstall OS X again) but that is pretty much
out of the question.

I guess my question is:

"How can I completely uninstall PHP so that I can start again?"

Thanks. 



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



Re: [PHP] Uninstalling PHP?

2010-02-26 Thread John Black

On 02/27/2010 06:09 AM, Austin Powers wrote:

It is purely a guess that I need to start again from a complete clean setup
(reformatting my hard disk and reinstall OS X again) but that is pretty much
out of the question.
I guess my question is:
"How can I completely uninstall PHP so that I can start again?"


Hello,

Someone should be able to help you if you can provide us with the steps 
you tried and where you failed.


--
John
Der unmündige Untertan ruft die Polizei. Der mündige Bürger informiert
seinen Anwalt.
[Nikolaus Cybinski]

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



Re: [PHP] Uninstalling PHP?

2010-02-26 Thread Lester Caine

Austin Powers wrote:

"How can I completely uninstall PHP so that I can start again?"


Not knowing the Mac I'm fishing ;)
How did you INSTALL PHP? We normally do this via a 'package manager' of some 
sort, where you find the 'PHPxx' and select it. Uninstalling is simply a matter 
of 'deslecting' it.
If you loaded this from a 'command line' script then I would think that perhaps 
this is a book that needs a health warning :(


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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