php-general Digest 2 Jun 2006 13:49:09 -0000 Issue 4162

2006-06-02 Thread php-general-digest-help

php-general Digest 2 Jun 2006 13:49:09 - Issue 4162

Topics (messages 237233 through 237264):

$BG%?1$7$F$^$9(B
237233 by: yume

Re: Help with enter key in Forms
237234 by: George Babichev
237235 by: Chris
237236 by: Chuck Anderson
237237 by: George Babichev

Re: OO purism sucks - this is a rant for anyone who is  allergic to 
thatkind of thing...
237238 by: Rasmus Lerdorf
237239 by: John Meyer
237253 by: Jochem Maas

PHP/Mysql: Making binary field available for download - extra browser window ?
237240 by: Matthew Pegg
237241 by: Sichta, Daniel
237254 by: Jochem Maas

Problem with a script
237242 by: Ministério Público
237243 by: Chris
237246 by: Chris
237248 by: Ministério Público
237251 by: Chris

Re: Retrieve Content from URL
237244 by: Ministério Público
237245 by: Chris
237247 by: Ministério Público
237249 by: Chris
237250 by: Ministério Público

Re: Extended Ascii Characters
237252 by: Richard Luckhurst

Reading an XML outputting PHP file as XML
237255 by: IG
237262 by: Jochem Maas

If value is odd or not
237256 by: Jonas Rosling
237257 by: Dave Goodchild
237258 by: Brad Bonkoski
237259 by: Jonas Rosling
237260 by: IG
237261 by: Jochem Maas
237263 by: Jochem Maas
237264 by: Ford, Mike

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:
php-general@lists.php.net


--
---BeginMessage---







美香です。妊娠6ヶ月ですが、エッチしませんか。

ミルクも出ますよ

今はほとんど1日中家にいるので連絡頂ければ何時でも会えます。

278424のプロフにアドレスあります。待ってます

http://vqlh.com/?2006







[EMAIL PROTECTED]




---End Message---
---BeginMessage---

Ok, I sent it to everyone and you. Now can you answer my question please?
I type in
1



2
into my form in the program that i made, then when I view it, it shows
1 2
BUT if I check it in PHP My Admin it displays
1



2

So why is my program not showing those spaces?


On 6/1/06, Chris [EMAIL PROTECTED] wrote:


George Babichev wrote:
 I can't exactly reply all, because It is only sending it to you. Ok, so
 wait, the data with the spaces (enter keys), but why does my program not
 show it? Look. This is what I mean

In your email program hit Reply ALL instead of Reply.

Until you work out how to do that, I'm going to ignore your emails.

--
Postgresql  php tutorials
http://www.designmagick.com/

---End Message---
---BeginMessage---

George Babichev wrote:

Ok, I sent it to everyone and you. Now can you answer my question please?
I type in
1



2
into my form in the program that i made, then when I view it, it shows
1 2
BUT if I check it in PHP My Admin it displays
1



2


The answer is to change this:

? echo .$row['post'].

to this:

? echo .nl2br($row['post']).


like I said before...

--
Postgresql  php tutorials
http://www.designmagick.com/
---End Message---
---BeginMessage---

Chris wrote:

George Babichev wrote:
  

Hello everyone, I am programming a blog, and most of it is done, except I
have one issue. When I am typing in the form (before I click submit) and I
click the neter key to make a space, the MySQL database does not recognize
that space. How do I make it recognize it?



Unless you're stripping it out, it will recognise it. View HTML Source 
and you'll see the newline is actually in there. A \n is not a html 
newline so you need to convert it.


What you want is http://php.net/nl2br

  

Uhhh  did you try this -- nl2br?

--
*
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*
---End Message---
---BeginMessage---

Awesome, thank you so much! It works!

On 6/1/06, Chris [EMAIL PROTECTED] wrote:


George Babichev wrote:
 Ok, I sent it to everyone and you. Now can you answer my question
please?
 I type in
 1



 2
 into my form in the program that i made, then when I view it, it shows
 1 2
 BUT if I check it in PHP My Admin it displays
 1



 2

The answer is to change this:

? echo .$row['post'].

to this:

? echo .nl2br($row['post']).


like I said before...

--
Postgresql  php tutorials
http://www.designmagick.com/

---End Message---
---BeginMessage---

Robert Cummings wrote:


Well there was a segfault, but that's fixed now, now the warning is
thrown because of some purist attitude that says it's incorrect to pass
a literal to a reference expecting parameter... I can see how that's an
issue in C with pointers, or in a strongly type language like Java, but
part of PHP's popularity is that while it shares a lot of functions with
C, it is neither C nor Java, but rather a much simpler system that
generally for all the novices out there works well.



[PHP] PHP/Mysql: Making binary field available for download - extra browser window ?

2006-06-02 Thread Matthew Pegg
Hi all,

Working on a PHP script at the moment where I want to be able to
extract a file (PDF file) from a mysql database and force the popup
of the File Download dialog, to allow the user to either save or open
the document (ie. and bypass loading the file using the browser's plugin) 

I've found solutions on the net for doing this with a file using readfile()
but if I can get away with it, I don't want to create temporary files...

Here's what I've got so far (truncated...):
?
..
// db query string extract the PDF file
$result = mysql_query(select file_data from brochure where 
id=1,$connection);

$row= mysql_fetch_array($result);
$lengths = mysql_fetch_lengths($result);

// Grab the file contents as returned from the db
$pdf_brochure = $row[file_data];

// setup headers to force download of $pdf_brochure into crap.pdf
header(Pragma: public);
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: private,false); // required for certain browsers
header(Content-Type: application/force-download);

header(Content-Disposition: attachment; filename=\crap.pdf\; );
header(Content-Transfer-Encoding: binary);
header(Content-Length:  . $lengths[0]);

// send the file to stdout
print $pdf_brochure;//  problem might be here 
exit();

?

This almost works but the problem is that this code still spawns a new empty
browser window, and I don't know how to prevent this Can anyone help ?


regards,
Matt.

-- 
___
Matt Pegg
IT Specialist
Abacus Business Machines
Ballarat, Australia.
___

RE: [PHP] PHP/Mysql: Making binary field available for download - extra browser window ?

2006-06-02 Thread Sichta, Daniel
Hi,

In this case I usually creating Iframe with zero with and zero height
and using 
your header code in the iframe sorce file.

DS

-Original Message-
From: Matthew Pegg [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 02, 2006 7:59 AM
To: php-general@lists.php.net
Subject: [PHP] PHP/Mysql: Making binary field available for download -
extra browser window ? 

Hi all,

Working on a PHP script at the moment where I want to be able to
extract a file (PDF file) from a mysql database and force the popup
of the File Download dialog, to allow the user to either save or open
the document (ie. and bypass loading the file using the browser's
plugin) 

I've found solutions on the net for doing this with a file using
readfile()
but if I can get away with it, I don't want to create temporary files...

Here's what I've got so far (truncated...):
?
..
// db query string extract the PDF file
$result = mysql_query(select file_data from brochure where
id=1,$connection);

$row= mysql_fetch_array($result);
$lengths = mysql_fetch_lengths($result);

// Grab the file contents as returned from the db
$pdf_brochure = $row[file_data];

// setup headers to force download of $pdf_brochure into crap.pdf
header(Pragma: public);
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: private,false); // required for certain
browsers
header(Content-Type: application/force-download);

header(Content-Disposition: attachment; filename=\crap.pdf\; );
header(Content-Transfer-Encoding: binary);
header(Content-Length:  . $lengths[0]);

// send the file to stdout
print $pdf_brochure;//  problem might be here 
exit();

?

This almost works but the problem is that this code still spawns a new
empty
browser window, and I don't know how to prevent this Can anyone help
?


regards,
Matt.

-- 
___
Matt Pegg
IT Specialist
Abacus Business Machines
Ballarat, Australia.
___

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



[PHP] Problem with a script

2006-06-02 Thread Ministério Público

Hi guys I'm getting the following error and I cant seem to understand what
Im doing wrong, if someone could help me I'd apreciate it.

Here is the error message I get in some fileds of the output on the browser:

*Warning*: Invalid argument supplied for foreach() in *
c:\apache\htdocs\pobs\pobs.php* on line *180*
**
*And here goes the lines I've put a few before and a few after just in case.
*
**
**
**
*178

TRTD valign=bottomJavaScript (Functions  Variables)/TDTD WIDTH=10
valign=topnbsp;/TDTDinput type=checkbox name=ReplaceJS
value=1 checkednbsp;nbsp;
*
*179*

? echo *+ files with extensions: ;
*
*180*

*foreach($JSFileExtArray* as *$Key* *=* *$Value)
*
*181*

echo *'b'.$Value.'/b,';
*
*182*

?


Re: [PHP] Problem with a script

2006-06-02 Thread Chris

Ministério Público wrote:

Hi guys I'm getting the following error and I cant seem to understand what
Im doing wrong, if someone could help me I'd apreciate it.

Here is the error message I get in some fileds of the output on the 
browser:


*Warning*: Invalid argument supplied for foreach() in *
c:\apache\htdocs\pobs\pobs.php* on line *180*


..


*foreach($JSFileExtArray* as *$Key* *=* *$Value)


JSFileExtArray isn't an array, it's something else.

Use var_dump to see what it is and go from there.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Retrieve Content from URL

2006-06-02 Thread Ministério Público

What I need to know is that if when I fopen() or the other function you gave
me I get the variables that are assigned on the html, such as the option for
example, if its name is test, could I access it retrieving the value $test
???

cause I really need to do it and I cant seem to know where to begin.

Thanks in advance,
Rodrigo


Re: [PHP] Retrieve Content from URL

2006-06-02 Thread Chris

Ministério Público wrote:
What I need to know is that if when I fopen() or the other function you 
gave me I get the variables that are assigned on the html, such as the 
option for example, if its name is test, could I access it retrieving 
the value $test ???


No. Those functions will retrieve the webpage exactly the same as your 
browser does.


What would test be? Provide an example of what you see and what you 
are trying to end up with.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Problem with a script

2006-06-02 Thread Chris

Ministério Público wrote:
After using the var_dump the only thing I get is NULL, therefore I'll 
try something else that I think is more complete for the fellow programmers.


Nobody's going to trawl through all of your code.

Narrow down where the problem is.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Retrieve Content from URL

2006-06-02 Thread Ministério Público

Here it goes: in a certain page there is a dinamicaly generated Option ( one
of those boxes from wich you can select a certain thing in a list) I want to
retrieve the content of these options and the values assigned to each of
them.

Thanx.
Rodrigo


Re: [PHP] Problem with a script

2006-06-02 Thread Ministério Público

I showed where the problem is and after var_dump all I get is NULL. I just
sent the code cause I thought it would be easier to see it in context, not
to make somebody trawl trough it. If its not an array how to find out what
it is? What can I do about it?
Thanks.
Rodrigo


Re: [PHP] Retrieve Content from URL

2006-06-02 Thread Chris

Ministério Público wrote:
Here it goes: in a certain page there is a dinamicaly generated Option ( 
one of those boxes from wich you can select a certain thing in a list) I 
want to retrieve the content of these options and the values assigned to 
each of them.


So if you have:

option value=test1Test 1/option
option value=test2Test 2/option

You want:

$test1 = Test 1;
$test2 = Test 2;

??

preg_match_all('%option 
value=[\']*([^\']+?)[\']*\s*(.*)/option%isU', $text, $matches);


That will give you an array that looks like this:

Array
(
[0] = Array
(
[0] = option value=test1Test 1/option
[1] = option value=test2Test 2/option
)

[1] = Array
(
[0] = test1
[1] = test2
)

[2] = Array
(
[0] = Test 1
[1] = Test 2
)

)

From there you should be able to work out what to do..

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Retrieve Content from URL

2006-06-02 Thread Ministério Público

Chris you rule !!!

That great from here I'll be abble to go on.

Thanks.
Rodrigo


Re: [PHP] Problem with a script

2006-06-02 Thread Chris

Ministério Público wrote:


I showed where the problem is and after var_dump all I get is NULL. I 
just sent the code cause I thought it would be easier to see it in 
context, not to make somebody trawl trough it. If its not an array how 
to find out what it is? What can I do about it?


Put debug lines throughout your code and see where it breaks.

eg:

echo at line  . __LINE__ . , var is  . gettype($JSFileExtArray) . 
br/;


do that every 20 lines and then narrow the problem down from there.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re[2]: [PHP] Extended Ascii Characters

2006-06-02 Thread Richard Luckhurst
Hi Tedd,

I had a hunt in the archives and couldn't find anything. Do you have any clue
about when it was?

Richard

t At 9:46 AM +1000 6/2/06, Richard Luckhurst wrote:
Hi All

I am in the process of cleaning up an application that was left half 
finished. I
am fairly new to PHP so I am seeking the wisdom of the community to help with 
a
little problem.

In many cases I need to build command strings to be sent to a backend system.
The strings have to contain a couple of non ascii characters.

I have no problem with the following in a script

$RM=\xFF;

Then using the variable works fine within that chunk of php code.

What I would like to do is place all of the extended ascii characters in one 
of
the inc files and just use these in various scripts throughout the 
application.

When I try what I get is a test representation rather than the actual ascii
code. Ie I get \xFF instead of the ascii character ÿ

Is there any way to actually do this in php?
 


Regards,
Richard Luckhurst 
Product Development


t Yes, I think there is  -- we discussed this a few months ago on this list 
and someone wrote a routine to do basically want you want, or so I think -- so 
check the archives.

t tedd

t -- 
t 

t http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] OO purism sucks - this is a rant for anyone who is allergic to that kind of thing...

2006-06-02 Thread Jochem Maas

hi Rasmus,

I understand the point you made below - you have made this argument before
and I, for one, accepted it as valid when I first read the discussion
on internals - which is why I avoided ranting about that (and changes like it)

But I am wondering what if any your views might be on the original rant (mine)
regarding purism/strictness that [I feel] is creeping into php for no good
(read 'pragmatic') reason?

as an example - I have in the past argued that discontinuing the ability to
define static methods in interfaces was against the grain and was given the
reply 'you don't understand OO fix your code' - in the last couple of weeks
static interface methods were reintroduced to help in a situation highlighted
by Derick R. I have had pretty much the same experience regarding late static
binding - to which (though nothing to do with my pleas) has finally been 
capitulated
for inclusion in php6 not inducive to an optimal uptake of php5 which given
the length of time it's been out is rather dismal when compared to the speed at
which php4 was taken up.

if you agree at all with my postulation then maybe you also see some need
to address the issue?

kind regards,
Jochem

Rasmus Lerdorf wrote:

Robert Cummings wrote:


Well there was a segfault, but that's fixed now, now the warning is
thrown because of some purist attitude that says it's incorrect to pass
a literal to a reference expecting parameter... I can see how that's an
issue in C with pointers, or in a strongly type language like Java, but
part of PHP's popularity is that while it shares a lot of functions with
C, it is neither C nor Java, but rather a much simpler system that
generally for all the novices out there works well.



Stuff like this is a bug in your code.  It has nothing to do with purism:

function inc_arg($arg) {
  $arg++;
}
inc_arg(3);

You have specifically defined your function to modify the argument yet 
you pass it something that has no storage and thus there is no way to 
use that modification.  For the most part I agree that we need to keep 
the language as flexible and forgiving as possible, but where we are 
able to detect code that obviously doesn't do what the programmer 
intended, it is tremendously helpful to get a descriptive error.


As far as functions returning references, you are right that returning a 
literal there sometimes makes sense, but this can also hide a bug which 
is why this only throws a notice.


You could argue that we could try to look ahead and see what is actually 
done with the passed argument to see if it is modified, or that we could 
try to figure out whether the returned reference is actually used as 
such, but that is technically extremely difficult given the way things 
work internally.  So given the choice between ignoring extremely 
suspicious code like this and throwing an error/warning, I'd rather be 
told about it and in the edge cases where I really do want the 
equivalent of a NOP in my code, it isn't that hard to force it by adding 
a dummy storage variable along with a comment explaining why you need to 
do that.


-Rasmus



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



Re: [PHP] PHP/Mysql: Making binary field available for download - extra browser window ?

2006-06-02 Thread Jochem Maas

Matthew Pegg wrote:

Hi all,

Working on a PHP script at the moment where I want to be able to
extract a file (PDF file) from a mysql database and force the popup
of the File Download dialog, to allow the user to either save or open
the document (ie. and bypass loading the file using the browser's plugin) 


I've found solutions on the net for doing this with a file using readfile()
but if I can get away with it, I don't want to create temporary files...


not having temporary files and even the code you use have nothing to do with
the extra window problem - that is a client side issue over which php has no
control .. it's down to the browser settings (possibly) or (more likely) the
target attribute of the link in question.



Here's what I've got so far (truncated...):
?
..
// db query string extract the PDF file
$result = mysql_query(select file_data from brochure where 
id=1,$connection);

$row= mysql_fetch_array($result);
$lengths = mysql_fetch_lengths($result);

// Grab the file contents as returned from the db
$pdf_brochure = $row[file_data];

// setup headers to force download of $pdf_brochure into crap.pdf
header(Pragma: public);
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: private,false); // required for certain browsers
header(Content-Type: application/force-download);

header(Content-Disposition: attachment; filename=\crap.pdf\; );
header(Content-Transfer-Encoding: binary);
header(Content-Length:  . $lengths[0]);

// send the file to stdout
print $pdf_brochure;//  problem might be here 
exit();


?

This almost works but the problem is that this code still spawns a new empty
browser window, and I don't know how to prevent this Can anyone help ?


don't open a new window to download it then ... i.e. don't use 
'target=_blank' in
the html defintion of the relevant link.




regards,
Matt.



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



[PHP] Reading an XML outputting PHP file as XML

2006-06-02 Thread IG

Hi.
I have a PHP file that outputs as XML from a database. i have used the 
header() function to output the correct header but when I use the 
simplexml function it is trying to parse the php file itself and not the 
output of the php file. I can't get my head round this. Can anyone help me?


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



[PHP] If value is odd or not

2006-06-02 Thread Jonas Rosling
Hi all,
is there any easy why to check if a value is odd or not?

Thanks // Jonas

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



Re: [PHP] If value is odd or not

2006-06-02 Thread Dave Goodchild

On 02/06/06, Jonas Rosling [EMAIL PROTECTED] wrote:


Hi all,
is there any easy why to check if a value is odd or not?

Thanks // Jonas

Yep, use the modulo operator like so:




if  ($value %  2  ==0)  $odd = false;




--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


Re: [PHP] If value is odd or not

2006-06-02 Thread Brad Bonkoski

if ($value % 2 == 0 )
   echo Value is even;
else
   echo Value is odd;

Jonas Rosling wrote:


Hi all,
is there any easy why to check if a value is odd or not?

Thanks // Jonas

 



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



SV: [PHP] If value is odd or not

2006-06-02 Thread Jonas Rosling
-Ursprungligt meddelande-
Fran: Eric Mol [mailto:[EMAIL PROTECTED]
Skickat: den 2 juni 2006 15:34
Till: 'Jonas Rosling'; 'PHP List'
Amne: RE: [PHP] If value is odd or not


If ($var/2==round($var/2)){
  // not odd
}else{
  // odd
}

Greetings,
Eric

Thanks (all)!

-Oorspronkelijk bericht-
Van: Jonas Rosling [mailto:[EMAIL PROTECTED] 
Verzonden: vrijdag 2 juni 2006 15:32
Aan: PHP List
Onderwerp: [PHP] If value is odd or not

Hi all,
is there any easy why to check if a value is odd or not?

Thanks // Jonas

-- 
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] If value is odd or not

2006-06-02 Thread IG

Jonas Rosling wrote:

Hi all,
is there any easy why to check if a value is odd or not?

Thanks // Jonas


$value = 3;
if (strpos(($value/2),.) === FALSE) {echo even;}
else {echo odd;}

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



Re: [PHP] If value is odd or not

2006-06-02 Thread Jochem Maas

Jonas Rosling wrote:

Hi all,
is there any easy why to check if a value is odd or not?


the modulos operator:

read about what it does here:
http://php.net/manual/en/language.operators.arithmetic.php

here is a simple example of how to check if something
is odd or not (odd number that is ;-):

$x = 1;
$y = 2;
$z = 3;

var_dump(($x % 2), ($y % 2), ($z % 2));



Thanks // Jonas



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



Re: [PHP] Reading an XML outputting PHP file as XML

2006-06-02 Thread Jochem Maas

IG wrote:

Hi.
I have a PHP file that outputs as XML from a database. i have used the 
header() function to output the correct header but when I use the 
simplexml function it is trying to parse the php file itself and not the 
output of the php file. I can't get my head round this. Can anyone help me?


your running the simplexml function on the php file and not its output.





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



Re: [PHP] If value is odd or not

2006-06-02 Thread Jochem Maas

Jonas Rosling wrote:

Hi all,
is there any easy why to check if a value is odd or not?


ignore every answer that doesn't use the % operator.



Thanks // Jonas



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



RE: [PHP] If value is odd or not

2006-06-02 Thread Ford, Mike
On 02 June 2006 14:32, Jonas Rosling wrote:

 Hi all,
 is there any easy why to check if a value is odd or not?

   if ($value%2):
  // $value is odd
   endif;

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] If value is odd or not

2006-06-02 Thread IG

Jochem Maas wrote:

Jonas Rosling wrote:

Hi all,
is there any easy why to check if a value is odd or not?


ignore every answer that doesn't use the % operator.



Thanks // Jonas



ie my answer!  I think the % operator is the best way, but there was 
nothing wrong with the answer I gave in that it would let you know 
whether the value is odd or not. But, I guess being not as clever as the 
other guys means I better go... sob sob


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



Re: [PHP] If value is odd or not

2006-06-02 Thread John Nichel

Jochem Maas wrote:

Jonas Rosling wrote:

Hi all,
is there any easy why to check if a value is odd or not?


ignore every answer that doesn't use the % operator.



if ( is_int ( $value / 2 ) ) {
//  Even
}

:-p

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] If value is odd or not

2006-06-02 Thread Jochem Maas

IG wrote:

Jochem Maas wrote:


Jonas Rosling wrote:


Hi all,
is there any easy why to check if a value is odd or not?



ignore every answer that doesn't use the % operator.



Thanks // Jonas



ie my answer!  I think the % operator is the best way, but there was 


not just your answer.

nothing wrong with the answer I gave in that it would let you know 


didn't say there was anything wrong with it, just that Jonas should
modulos - it's the best option and the fastest - an added bonus.

whether the value is odd or not. But, I guess being not as clever as the 
other guys means I better go... sob sob


suit yourself :-)





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



RE: [PHP] If value is odd or not

2006-06-02 Thread Jay Blanchard
[snip]
if ( is_int ( $value / 2 ) ) {
//  Even
}
[/snip]

:)

More?

$oddArray = array(1,3,5,7,9); 

if(in_array(substr($integer, -1, 1))){
   echo $integer .  is odd\n;
}

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



Re: [PHP] If value is odd or not

2006-06-02 Thread tedd
At 3:32 PM +0200 6/2/06, Jonas Rosling wrote:
Hi all,
is there any easy why to check if a value is odd or not?

Jonas:

echo($num  1);

This produces 1 for odd and 0 for even.

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] If value is odd or not

2006-06-02 Thread Jochem Maas

John Nichel wrote:

Jochem Maas wrote:


Jonas Rosling wrote:


Hi all,
is there any easy why to check if a value is odd or not?



ignore every answer that doesn't use the % operator.



if ( is_int ( $value / 2 ) ) {
//  Even
}


LOL.



:-p



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



Re: [PHP] If value is odd or not

2006-06-02 Thread Dimiter Ivanov

I doubt that Jonas ever expected 'the rain of answers' that will
follow his humble question ;]

On 6/2/06, tedd [EMAIL PROTECTED] wrote:

At 3:32 PM +0200 6/2/06, Jonas Rosling wrote:
Hi all,
is there any easy why to check if a value is odd or not?

Jonas:

echo($num  1);

This produces 1 for odd and 0 for even.

tedd

--

http://sperling.com  http://ancientstones.com  http://earthstones.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



[PHP] Retrieving Content

2006-06-02 Thread Rodrigo de Oliveira Costa

Hi guys, I'm trying to retrieve a certain variable from a site. Here it goes:

The site has a SELECT box that is dynamicaly updated, I need to put a
script running that will retrieve the specified SELECT with its
contents, that are labels and values. Is there a way to retrieve the
page and then select just one line of the code, discard the rest and
then retrieve from this line the values?

Here goes the SELECT :

SELECT title='navigation' Name=navigating onChange=self.location =
'/s/2318355/'+ this.options[this.selectedIndex].value + '/';option
value=1 selected1. Nameoption  value=2 2. Name/select


I need to get something like this:
$select = navigating;
$label1 = 1.Name;
$value1 = 1;
$label2 = 2.Name;
$value2 = 2;


Remmembering that the SELECT is dynamic so I need also to check how
many labels and values there are and store them into variables. I
getting a really hard time doing this.


I thank any imput you guys can give me.

Thanx,
Rodrigo

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



Re: [PHP] If value is odd or not

2006-06-02 Thread Steven Osborn

$odd = array(1,3,5,7,9);

if(inarray(substr($var,strlen($var)-1,1),$od)
{
  //haha
}
else
{
  //even
}

p.s. sorry for the direct mail

Jonas Rosling wrote:

Hi all,
is there any easy why to check if a value is odd or not?

Thanks // Jonas

  


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



Re: [PHP] If value is odd or not

2006-06-02 Thread John Meyer

Steven Osborn wrote:

$odd = array(1,3,5,7,9);

if(inarray(substr($var,strlen($var)-1,1),$od)
{
  //haha
}
else
{
  //even
}




How about this

if ($var % 2 == 0) { //it's even
} else { //it's odd
}
--
Online library -- http://pueblonative.110mb.com
126 books and counting.

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



Re: [PHP] OO purism sucks - this is a rant for anyone who is allergic to that kind of thing...

2006-06-02 Thread Rasmus Lerdorf

Jochem Maas wrote:

I understand the point you made below - you have made this argument before
and I, for one, accepted it as valid when I first read the discussion
on internals - which is why I avoided ranting about that (and changes 
like it)


But you didn't avoid it, you used it as an example to back up your rant.

And on the OO side your argument gets shaky as well.  The whole point of 
OO is to add a very structured layer on top of your code to make it more 
consistent and more maintainable than the equivalent procedural code. 
There is nothing you can do in OO that you can't do with completely 
freeform procedural code.  When you choose to go OO, you choose a set of 
rules and a certain code structure that by definition is going to be 
somewhat constrained.  The argument over exactly how constrained this 
should be and where we should loosen things up will continue until the 
end of time.  PPP and Interfaces are all about constraints.  They serve 
no practical purpose whatsoever other than to add constraints.


And saying that these OO issues is slowing down PHP 5 uptake is a bit of 
a red herring.  We are competing against ourselves.  PHP 4 works 
extremely well.  There is a lot of code written for it and it works.  I 
seriously doubt very many people are not upgrading to PHP 5 because of 
some debatable edge-case OO thing.  People are not upgrading to PHP 5 
because PHP 4 works just fine for them and they haven't yet discovered 
things like SimpleXML and some of the other killer features of PHP 5.


-Rasmus

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



Re: [PHP] If value is odd or not

2006-06-02 Thread tedd
At 5:14 PM +0300 6/2/06, Dimiter Ivanov wrote:
I doubt that Jonas ever expected 'the rain of answers' that will
follow his humble question ;]

Well... at least the answers are getting shorter.

It might be interesting to see how long of a piece of code could be written to 
answer the same question.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] If value is odd or not

2006-06-02 Thread Jay Blanchard
[snip]
It might be interesting to see how long of a piece of code could be
written to answer the same question.
[/snip]

I can think of a really long one using a callback function

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



[PHP] HTML Mail script reading text from MySQL

2006-06-02 Thread Tom Chubb

I can't work out how to load the text from a recordset result into a
variable for sending using mail in a script.
I have a script which creates a dynamic table then I want to load the
table's HTML into a variable which will be echoed in the mail function.
I can't work out how to do this.
I've tried calling the file using exec and fopen but I don't get any result.

I have googled and RTFM (especially variable scope) but just can't work out
how to do it.
Any help would be greatly appreciated.

PS - I know there are many Mail classes out there, but I also realise that
this is something I will want to know how to do at a later time.
Thanks,

Tom


RE: [PHP] If value is odd or not

2006-06-02 Thread tedd
At 9:52 AM -0500 6/2/06, Jay Blanchard wrote:
[snip]
It might be interesting to see how long of a piece of code could be
written to answer the same question.
[/snip]

I can think of a really long one using a callback function


It's interesting to dangle bait above a pool of programmers and see what rises. 
:-)

There used to be a contest to create the most complicated solution to 
accomplish a very trivial task, like turning on a light switch. However, I 
can't remember what the contest was called -- it was something like the FUBAR 
awards.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] OO purism sucks - sell me on PHP5?

2006-06-02 Thread tg-php
I'm kind of coming from the outside here, so forgive my ignorance on some 
matters.  I have some OO experience, just not with PHP and have only worked 
with PHP4 so again.. kind of on the outside of all this.

Rasmus, you make a great point here.  OO is structured and is all about 
constraints whereas PHP tends to be rather flexible.  So OO in PHP doesn't mean 
that it should comprompise the idea of a structured development method.  It's 
just part of PHP's philosophy of allowing developers to choose their method of 
skinning the proverbial cat.

It seems that one of Jochem's main complaints about it isn't so much the rules 
and structure, but the idea that he was told his code was wrong and he needed 
to redo a good chunk of his 2 years worth of development (or any of this code) 
to PHP5's OO standard then a short time later he's told that someone else had 
the same problem and the 'standard' was changed to accomodate.  But hey.. stuff 
happens.  Sometimes concessions need to eventually be made when there's no 
other way.

So that leads me to the 'sell' part of my altered subject line.

Rasmus said: People are not upgrading to PHP 5 because PHP 4 works just fine 
for them and they haven't yet discovered things like SimpleXML and some of the 
other killer features of PHP 5.

So I've read some of the new features on PHP5 and am still not sold on 
upgrading.  As was stated, what we've developed so far works great and there's 
no real incentive to upgrade.   But upgrades are inevitable so in the interest 
of planning for the future, I'm looking at PHP5.   Our XML routines work fine, 
but since you mentioned SimpleXML, I'll take a closer look at it.   What are 
some of the other killer features of PHP5 that I may be sleeping on here.

If it ain't broke, don't fix it works for a while, but if there are easier 
and/or better ways to do things in PHP5, I want in!  So someone sell me on this 
from the point of view of someone who's upgraded and has learned the joys of 
PHP5.  So far what I've found online has been little more than a list of new 
features without an idea of how much of a headache they're going to save me in 
the future.

Thanks!

-TG

= = = Original message = = =

Jochem Maas wrote:
 I understand the point you made below - you have made this argument before
 and I, for one, accepted it as valid when I first read the discussion
 on internals - which is why I avoided ranting about that (and changes 
 like it)

But you didn't avoid it, you used it as an example to back up your rant.

And on the OO side your argument gets shaky as well.  The whole point of 
OO is to add a very structured layer on top of your code to make it more 
consistent and more maintainable than the equivalent procedural code. 
There is nothing you can do in OO that you can't do with completely 
freeform procedural code.  When you choose to go OO, you choose a set of 
rules and a certain code structure that by definition is going to be 
somewhat constrained.  The argument over exactly how constrained this 
should be and where we should loosen things up will continue until the 
end of time.  PPP and Interfaces are all about constraints.  They serve 
no practical purpose whatsoever other than to add constraints.

And saying that these OO issues is slowing down PHP 5 uptake is a bit of 
a red herring.  We are competing against ourselves.  PHP 4 works 
extremely well.  There is a lot of code written for it and it works.  I 
seriously doubt very many people are not upgrading to PHP 5 because of 
some debatable edge-case OO thing.  People are not upgrading to PHP 5 
because PHP 4 works just fine for them and they haven't yet discovered 
things like SimpleXML and some of the other killer features of PHP 5.

-Rasmus


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



RE: [PHP] If value is odd or not

2006-06-02 Thread tg-php
The Obfuscated C contest had a category for most complicated solution to a 
simple problem.  Like 50 lines of code to add two numbers together, stuff like 
that.

-TG

= = = Original message = = =

At 9:52 AM -0500 6/2/06, Jay Blanchard wrote:
[snip]
It might be interesting to see how long of a piece of code could be
written to answer the same question.
[/snip]

I can think of a really long one using a callback function


It's interesting to dangle bait above a pool of programmers and see what rises. 
:-)

There used to be a contest to create the most complicated solution to 
accomplish a very trivial task, like turning on a light switch. However, I 
can't remember what the contest was called -- it was something like the FUBAR 
awards.

tedd


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



RE: [PHP] If value is odd or not

2006-06-02 Thread Jay Blanchard
[snip]
It's interesting to dangle bait above a pool of programmers and see what
rises. :-)

There used to be a contest to create the most complicated solution to
accomplish a very trivial task, like turning on a light switch. However,
I can't remember what the contest was called -- it was something like
the FUBAR awards.
[/snip]

Obfuscation contests! The Rube-Goldberg machines of software design.

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



Re: [PHP] Reading an XML outputting PHP file as XML

2006-06-02 Thread Adam Zey

Jochem Maas wrote:

IG wrote:

Hi.
I have a PHP file that outputs as XML from a database. i have used the 
header() function to output the correct header but when I use the 
simplexml function it is trying to parse the php file itself and not 
the output of the php file. I can't get my head round this. Can anyone 
help me?


your running the simplexml function on the php file and not its output.






You are doing (something like) this:

$xml = simplexml_load_string(file_get_contents(/www/html/foo.php);

You need to do something like this:

$xml = simplexml_load_string(file_get_contents(http://ba.com/foo.php;);

Alternatively, if you don't want the PHP script to be visible on the web 
server, make it executable (with a shebang) and then execute it and pass 
the output to simplexml_load_string(). You know, using shell_exec() or 
the backticks operator.


Note that simplexml_load_string() doesn't care about what type of file 
you reported it as (with Content-Type or something). It only cares that 
the string you pass it is XML. So if your script is the ONLY one that 
will ever get this XML, you don't need to bother with the content type.


Regards, Adam Zey.

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



Re: [PHP] If value is odd or not

2006-06-02 Thread Adam Zey

IG wrote:

Jochem Maas wrote:

Jonas Rosling wrote:

Hi all,
is there any easy why to check if a value is odd or not?


ignore every answer that doesn't use the % operator.



Thanks // Jonas



ie my answer!  I think the % operator is the best way, but there was 
nothing wrong with the answer I gave in that it would let you know 
whether the value is odd or not. But, I guess being not as clever as the 
other guys means I better go... sob sob


But there was something wrong with it. You're using string operations on 
a number to find out if it is odd. That means that it is many TIMES 
slower, and if he needs to do this in a loop, using string functions is 
going to be horribly slow compared to a simple modulus.


Just because code works doesn't mean that it is acceptable. Spending a 
thousand times more computational time to solve a problem than is needed 
is a recipe for disaster.


Regards, Adam Zey.

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



Re: [PHP] HTML Mail script reading text from MySQL

2006-06-02 Thread Tom Chubb

Sorry Mark,
What I meant is say a page outputs an HTML table eg:

table width=100 cellspacing=0 cellpadding=0
 tr
   tda/td
   tdb/td
   tdc/td
   tdd/td
   tde/td
 /tr
 tr
   tdf/td
   tdg/td
   tdh/td
   tdi/td
   tdj/td
 /tr
 tr
   tdk/td
   tdl/td
   tdm/td
   tdn/td
   tdo/td
 /tr
 tr
   tdp/td
   tdq/td
   tdr/td
   tds/td
   tdt/td
 /tr
 tr
   tdu/td
   tdv/td
   tdw/td
   tdx/td
   tdy/td
 /tr
/table

But I want to get that code into the $message variable.
I have written many mail scripts before it's just getting the data into the
variable.
Should I be using something like CURL?


On 02/06/06, Mark Cain [EMAIL PROTECTED] wrote:


For my server configuration (Unix), mailing works like this for me.

In the simplest manner mailing works in the following way:

?
// build the email
$mail_to = [EMAIL PROTECTED];

$subject = subject of mail goes here -- $variable_of_your_choosing;

$message = The text of the message starts here

$variable_of_your_choosing_2

$variable_of_your_choosing_3

;

$headers = From: [EMAIL PROTECTED] .
Reply-To: [EMAIL PROTECTED];

//send email
mail($mail_to, $subject, $message, $headers);
?


HTH,

Mark Cain

- Original Message -
From: Tom Chubb [EMAIL PROTECTED]
To: [php] PHP General List php-general@lists.php.net
Sent: Friday, June 02, 2006 10:59 AM
Subject: [PHP] HTML Mail script reading text from MySQL


I can't work out how to load the text from a recordset result into a
 variable for sending using mail in a script.
 I have a script which creates a dynamic table then I want to load the
 table's HTML into a variable which will be echoed in the mail function.
 I can't work out how to do this.
 I've tried calling the file using exec and fopen but I don't get any
 result.

 I have googled and RTFM (especially variable scope) but just can't work
 out
 how to do it.
 Any help would be greatly appreciated.

 PS - I know there are many Mail classes out there, but I also realise
that
 this is something I will want to know how to do at a later time.
 Thanks,

 Tom






--
Tom Chubb
[EMAIL PROTECTED]
07915 053312


RE: [PHP] If value is odd or not

2006-06-02 Thread tedd
At 10:10 AM -0500 6/2/06, Jay Blanchard wrote:
[snip]
It's interesting to dangle bait above a pool of programmers and see what
rises. :-)

There used to be a contest to create the most complicated solution to
accomplish a very trivial task, like turning on a light switch. However,
I can't remember what the contest was called -- it was something like
the FUBAR awards.
[/snip]

Obfuscation contests! The Rube-Goldberg machines of software design.

Ahhh, yes -- that was it. However, the Rube-Goldberg started with physical 
machines, like rolling balls, mouse-traps, levers, and such.

Thanks for refreshing my memory, I would have thought about that all day.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Re: Retrieving Content

2006-06-02 Thread Adam Zey

Rodrigo de Oliveira Costa wrote:
Hi guys, I'm trying to retrieve a certain variable from a site. Here it 
goes:


The site has a SELECT box that is dynamicaly updated, I need to put a
script running that will retrieve the specified SELECT with its
contents, that are labels and values. Is there a way to retrieve the
page and then select just one line of the code, discard the rest and
then retrieve from this line the values?

Here goes the SELECT :

SELECT title='navigation' Name=navigating onChange=self.location =
'/s/2318355/'+ this.options[this.selectedIndex].value + '/';option
value=1 selected1. Nameoption  value=2 2. Name/select


I need to get something like this:
$select = navigating;
$label1 = 1.Name;
$value1 = 1;
$label2 = 2.Name;
$value2 = 2;


Remmembering that the SELECT is dynamic so I need also to check how
many labels and values there are and store them into variables. I
getting a really hard time doing this.


I thank any imput you guys can give me.

Thanx,
Rodrigo



First, get the file using file_get_contents(). Now, do two nested 
regular expression matches. As in, do a regular expression match to get 
all the select/select blocks, and then for each match do another 
regular expression match to grab all the option blocks.


Alternatively, you could do this with strpos(), since it lets you 
specify where to START searching from. It might be faster, but it would 
probably end up being less flexible.


Alternatively, if you need a super robust solution, you might want to 
look into actual HTML parsing libraries, like tidy (which has a PHP module).


Regards, Adam Zey.

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



Re: [PHP] HTML Mail script reading text from MySQL

2006-06-02 Thread Tom Chubb

I've just read a similar post and think that I should use file_get_contents
and the preg_match for the table  /table tags.
...But if anyone knows a better way I'm all ears!


On 02/06/06, Tom Chubb [EMAIL PROTECTED] wrote:


 Sorry Mark,
What I meant is say a page outputs an HTML table eg:

table width=100 cellspacing=0 cellpadding=0
  tr
tda/td
tdb/td
tdc/td
tdd/td
tde/td
  /tr
  tr
tdf/td
tdg/td
tdh/td
tdi/td
tdj/td
  /tr
  tr
tdk/td
tdl/td
tdm/td
tdn/td
tdo/td
  /tr
  tr
tdp/td
tdq/td
tdr/td
tds/td
tdt/td
  /tr
  tr
tdu/td
tdv/td
tdw/td
tdx/td
tdy/td
  /tr
/table

But I want to get that code into the $message variable.
I have written many mail scripts before it's just getting the data into
the variable.
Should I be using something like CURL?


 On 02/06/06, Mark Cain [EMAIL PROTECTED] wrote:

 For my server configuration (Unix), mailing works like this for me.

 In the simplest manner mailing works in the following way:

 ?
 // build the email
 $mail_to = [EMAIL PROTECTED];

 $subject = subject of mail goes here -- $variable_of_your_choosing;

 $message = The text of the message starts here

 $variable_of_your_choosing_2

 $variable_of_your_choosing_3

 ;

 $headers = From: [EMAIL PROTECTED] .
 Reply-To: [EMAIL PROTECTED];

 //send email
 mail($mail_to, $subject, $message, $headers);
 ?


 HTH,

 Mark Cain

 - Original Message -
 From: Tom Chubb [EMAIL PROTECTED]
 To: [php] PHP General List php-general@lists.php.net
 Sent: Friday, June 02, 2006 10:59 AM
 Subject: [PHP] HTML Mail script reading text from MySQL


 I can't work out how to load the text from a recordset result into a
  variable for sending using mail in a script.
  I have a script which creates a dynamic table then I want to load the
  table's HTML into a variable which will be echoed in the mail
 function.
  I can't work out how to do this.
  I've tried calling the file using exec and fopen but I don't get any
  result.
 
  I have googled and RTFM (especially variable scope) but just can't
 work
  out
  how to do it.
  Any help would be greatly appreciated.
 
  PS - I know there are many Mail classes out there, but I also realise
 that
  this is something I will want to know how to do at a later time.
  Thanks,
 
  Tom
 




--
Tom Chubb
[EMAIL PROTECTED]
07915 053312





--
Tom Chubb
[EMAIL PROTECTED]
07915 053312


Re[2]: [PHP] Extended Ascii Characters

2006-06-02 Thread tedd
Richard:

The discussion was in February, I looked and couldn't find what I remembered. 
So, I'm thinking that the coder sent it to me directly, but I searched my files 
and again I came up with nothing -- it's not like me to lose code.

What I remember was a function that took Unicode HEX and produced the html 
entities, like those found here:

http://www.roborg.co.uk/html_entities/

I will send you off-list what code I have that comes close, but perhaps the 
original author might resubmit his code. It was a fairly simple look-up and 
replace table, except the table was very extensive. It was a nice piece of 
work.

tedd

PS: For sake of clarification, ASCII ranges only from 0 to 127 DEC (HEX 
0-7F).

While 128-255 DEC is commonly referred to as Extended ASCII, it isn't 
officially ASCII -- as such, there are differences between OS's (i.e., win v 
mac).

However, Unicode includes everything and handles all code-points from 00 
to FF and divides those into various char-sets based upon various 
criteria (i.e., language, use, etc). So, the new words on the block are 
code-point and char-set.


--- previous ---


At 5:08 PM +1000 6/2/06, Richard Luckhurst wrote:
Hi Tedd,

I had a hunt in the archives and couldn't find anything. Do you have any clue
about when it was?

Richard

t At 9:46 AM +1000 6/2/06, Richard Luckhurst wrote:
Hi All

I am in the process of cleaning up an application that was left half 
finished. I
am fairly new to PHP so I am seeking the wisdom of the community to help 
with a
little problem.

In many cases I need to build command strings to be sent to a backend system.
The strings have to contain a couple of non ascii characters.

I have no problem with the following in a script

$RM=\xFF;

Then using the variable works fine within that chunk of php code.

What I would like to do is place all of the extended ascii characters in one 
of
the inc files and just use these in various scripts throughout the 
application.

When I try what I get is a test representation rather than the actual ascii
code. Ie I get \xFF instead of the ascii character ÿ

Is there any way to actually do this in php?



Regards,
Richard Luckhurst
Product Development


t Yes, I think there is  -- we discussed this a few months ago on this list 
and someone wrote a routine to do basically want you want, or so I think -- so 
check the archives.

t tedd

t --
t 

t http://sperling.com  http://ancientstones.com  http://earthstones.com


--

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] HTML Mail script reading text from MySQL

2006-06-02 Thread Rabin Vincent

On 6/2/06, Tom Chubb [EMAIL PROTECTED] wrote:

What I meant is say a page outputs an HTML table eg:

table width=100 cellspacing=0 cellpadding=0

[snipped]

/table

But I want to get that code into the $message variable.
I have written many mail scripts before it's just getting the data into the
variable.
Should I be using something like CURL?


This other script cannot/should not be modified? Then you can
either use shell_exec to execute the script and get the output

$message = shell_exec('the/other/script.php');

or use file_get_contents():

$message = file_get_contents('http://domain/script.php?a=b');

or if the other script is also php look into output buffering.
php.net/ob_start, php.net/ob_get_contents.

Rabin

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



Re: [PHP] OO purism sucks - sell me on PHP5?

2006-06-02 Thread Rasmus Lerdorf

[EMAIL PROTECTED] wrote:


If it ain't broke, don't fix it works for a while, but if there are easier 
and/or better ways to do things in PHP5, I want in!  So someone sell me on this from the 
point of view of someone who's upgraded and has learned the joys of PHP5.  So far what 
I've found online has been little more than a list of new features without an idea of how 
much of a headache they're going to save me in the future.


To me the main user-visible benefits of going to PHP 5 are (ignoring the 
OO changes for now):


1. Simplexml

eg. One-line RSS parser (of Flickr's upload queue feed)

  $url = 'http://www.flickr.com/services/feeds/photos_public.gne';
  foreach(simplexml_load_file($url)-entry as $it) echo $it-content;


2. Much improved DOM support

eg. various things you can do to a DOM

  // First, load your XML document into a DOM
  $dom = domdocument::load('test.xml');

  // Apply a stylesheet to the dom
  $proc = new xsltProcessor;
  $proc-importStyleSheet($domxsl);
  echo $proc-transformToXML($dom);

  // xpath query on the dom
  $ctx = new domXPath($dom);
  $result = $ctx-query('/top/[EMAIL PROTECTED]  3]/foo/text()');
  foreach($result as $node) {
echo $node-nodeValue;
  }

  // pull it into simplexml and access it
  $s = simplexml_import_dom($dom);
  echo $s-child[0]-foo;


3. xmlreader/xmlwriter

eg. SAX document validation using xmlreader

  $reader = new XMLReader();
  $reader-open('test.xml');
  $reader-setParserProperty(XMLReader::VALIDATE, true);
  while($reader-read());
  echo $reader-isValid();


4. PDO

eg. Prepare execute against MySQL with named parameters

  $pdo = new PDO('mysql:dbname=testdb');

  $sql = 'SELECT name, colour, calories
  FROM fruit
  WHERE calories  :calories AND colour = :colour';
  $prep = $pdo-prepare($sql);
  $prep-execute(array(':calories' = 150, ':colour' = 'red'));
  $red = $prep-fetchAll();


5. SOAP

eg. Exposing your PHP code as a SOAP web service

  function Add($x,$y) {
return $x+$y;
  }
  $server = new SoapServer(null,array('uri'=http://test-uri/;));
  $server-addFunction(Add);
  $server-handle();


6. SPL

eg. Iterating over entries in a directory

  $dir = new DirectoryIterator('.');
  foreach($dir as $ent) echo $ent;


7. Filter

eg. Define a default filter and use form input safely without cluttering
up your code with htmlspecialchars() calls everywhere and provide
easily auditable access to the unfiltered data

  php.ini: filter.default = special_chars

  echo $_POST['data'];
  $raw = input_get(INPUT_POST,'data', FILTER_UNSAFE_RAW);


8. Native Date/Time mechanism

Date/time functions now behave exactly the same way on every platform 
regardless of the differences in locales if you choose to use the native 
mechanism.


Beyond that the compiler produces smaller opcode arrays and the executor 
is faster.  Not a directly visible thing, and this is still improving, 
but definitely a plus.


Note that for all of this I am referring to PHP 5.1.x, not 5.0.x.

-Rasmus

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



[PHP] Re: Retrieving Content

2006-06-02 Thread Rodrigo de Oliveira Costa

Actualy I went a slightly diffent way, I tried to use the file()  like
on the script below and I get the content of the whole page but when I
try to get a single line from the array it all goes sideways. Here
goes the script with the correct urls, remembering that I'm using it
on the local server thats why I save it on the file to see if its
getting the right content:

$fc = file('http://www.fanfiction.net/s/979216/1/');
$f=fopen(some.txt,w);

foreach($fc as $line)
{
if ($line[85])
{ //look for $key in each line
  fputs($f,$line[85]);
} //place $line back in file
echo $line;
}


It shows the whole page but saves on the file something grambled that
I cant identify what it is.

Iknow that when opening the html result of the page that I need to get
the content its the second SELECT, and its actually on line 86, but
since the PHPEd dont use line 0 it should be right. Or I'm missing
something...

Thanks,
Rodrigo

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



Re: [PHP] OO purism sucks - sell me on PHP5?

2006-06-02 Thread tedd
At 9:00 AM -0700 6/2/06, Rasmus Lerdorf wrote:
[EMAIL PROTECTED] wrote:


-snip- (a bunch of things over my head)


Note that for all of this I am referring to PHP 5.1.x, not 5.0.x.

-Rasmus

Damn -- remind me to never disagree with you (as if I could). My self-perceived 
position on the food chain just declined considerably.  Any more display of 
knowledge like this, and I'll be back to programming with rocks.

Thanks for your insight.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Am I supposed to be using SPL?

2006-06-02 Thread Kevin Waterson
This one time, at band camp, Richard Lynch [EMAIL PROTECTED] wrote:


 So, of all the things that COULD go wrong, we just assume it's No
 files Found???
 
 I don't think I'll ever learn to like SPL or try/catch...

Ok, I think my example was a little too simplistic...
You could of course create multiple catch blocks and test for various errors.
In this simple example the catch might loook like

catch(Exception $e){
   echo 'Uh oh: '. $e-getMessage();
}


This would tell you what the problem is perhaps.

Kind regards
Kevin


-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

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



[PHP] Try XMLWriter ... was Re: [PHP] OO purism sucks - sell me on PHP5?

2006-06-02 Thread D. Dante Lorenso

[EMAIL PROTECTED] wrote:

What are some of the other killer features of PHP5 that I may be sleeping on 
here.
  


You have got to get your hands on XMLWriter.  I don't write any XHTML 
inside php any more.  I've wrapped the XMLWriter object inside my own 
object and now I can create 100% properly escaped XHTML without ever 
using a '' or '' symbol:


?php
$XML = new XTag('a', 'href', $href, 'title', 'This is a test  such.');
$XML-push('img', 'src', $img_src, 'width', 100, 'height', 50, 'border', 0);
$XML-pop(2); // img, a
print $XML-toXML();
// outputs: a href=[$href value here] title=This is a test amp; 
such.img src=[$img_src value here] width=100 height=50 
border=0//a

?

XMLWriter handles:

   * the escaping of characters to ensure I'm writing XHTML compliant code,
   * tags are guaranteed to open and close in the proper nested order,
   * content is encoded with UTF-8 encoding,
   * indentation of XHTML is optional
   * php code is legible without needing to backslash double and single
 quotes
   * PECL version of XMLWriter (gonna be in 5.2) contains ability to
 write raw (unescaped content) into your xml so you can merge
 already-created snippets of XHTML into your XHTML.
   * good for creating syntax valid XHTML 1.0+ strict output
   * good for creating syntax valid XML documents

There are a couple other 'gotta have' features of 5.1+ that are cool ... 
like PDO etc.  Sadly, all that is cool appears to be cutting edge and so 
documentation and examples are seriously lacking.  I find myself reading 
the source of many extensions just to try to figure out how to use 
them.  Maybe that's a sign I'm upgrading too often?  Of course, everyone 
is using 5.1.4 with XMLWriter from PECL, right?


Dante

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



[PHP] php java intregration

2006-06-02 Thread Vedanta Barooah

hello all,
i am setting up php_java.dll extension under windows/iis, my php
version is 5.1.2. can any one point me to the download location of
php_java.jar which is needed for the setup.

i searched all the sites/mirrors but its not available. do i have to
compile from source to get that jar? ... let me know,... thanks

- regards, vedanta

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



[PHP] Re: Retrieving Content

2006-06-02 Thread Adam Zey

Rodrigo de Oliveira Costa wrote:

Actualy I went a slightly diffent way, I tried to use the file()  like
on the script below and I get the content of the whole page but when I
try to get a single line from the array it all goes sideways. Here
goes the script with the correct urls, remembering that I'm using it
on the local server thats why I save it on the file to see if its
getting the right content:

$fc = file('http://www.fanfiction.net/s/979216/1/');
$f=fopen(some.txt,w);

foreach($fc as $line)
{
if ($line[85])
{ //look for $key in each line
  fputs($f,$line[85]);
} //place $line back in file
echo $line;
}


It shows the whole page but saves on the file something grambled that
I cant identify what it is.

Iknow that when opening the html result of the page that I need to get
the content its the second SELECT, and its actually on line 86, but
since the PHPEd dont use line 0 it should be right. Or I'm missing
something...

Thanks,
Rodrigo
HTML can't be parsed line-by-line since even a single tag can be broken 
up onto multiple lines. And also, if ($line[85]) simply checks if 
there is a character in position 85 of the line. It looks like your code 
is reading in a file, checking if each line is at least 85 characters 
long, and then writing it out again.


I suggest you read in the whole file using file_get_contents(), and then 
do the regex matching or strpos matching that I described in my previous 
message. Also keep in mind that as of PHP 5 there is a 
file_put_contents() function that lets you dump out a file in one go 
(with higher performance than doing it yourself). php_compat also has a 
copy of that function for other versions of PHP, although of course they 
do it in PHP code so the performance benefits are slightly less.


Regards, Adam Zey.

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



[PHP] Retrieve output from HTML or PHP file

2006-06-02 Thread Rodrigo de Oliveira Costa

Can I do the below to an URL, like retrieving the output of a site and
store it on a variable?
Thanks,
Rodrigo




Hi Peter,

Ah, I understand now.

If the file echo'ed it's output you could do:

ob_start();
include('file.php');
$output = ob_get_contents();
ob_end_clean();

or:

$output = exec('script.php');

(but make sure you use escapeshellarg /or escapeshellcmd where
applicable for security reasons).

first method would be better, more robust and more portable.

Peter Lauri wrote:

Hi Chris,

As I read in the documentation it only takes the content of the file. If
there is a script in the file I want that to be fun first. A file like this:

--
HTLM content
?php echo 'Hello World';  ?
HTML content
--

I want the result from my function to be

--
HTLM content
Hello World
HTML content
--

The file_get_contents('file.html') will give me

--
HTLM content
?php echo 'Hello World';  ?
HTML content
--

Or am I not correct?

Best regards,
Peter Lauri




-Original Message-
From: Chris [mailto:[EMAIL PROTECTED]
Sent: Monday, January 30, 2006 11:49 AM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Retrieve output from HTML or PHP file

Hi Peter,

Close :)

file('file.html');
see http://www.php.net/file
or

file_get_contents('file.html');
see http://www.php.net/file_get_contents

the 'file' function returns an array, 'file_get_contents' returns it as
a string.

Peter Lauri wrote:


Best group member,



I have a php script running and need to save the output from an HTML-file


or


PHP-file. What I want to do:



$the_output = thenicefunction('file.html');



Any suggestions?



/Peter





--

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



[PHP] Re: Retrieving Content

2006-06-02 Thread Rodrigo de Oliveira Costa

I just discovered the problem I have to retrieve the output of the
site and not the url since its dynamic. Ca I do it like retrieve the
output of this url:

www.tryout.com/1/2/

And of course store it on a variable? How to do it? I founr the func
below but couldnt understand how to make it work with a url.

Thanks guys,
Rodrigo


ob_start();
include('file.php');  //  Could be a site here? What should I do to
retrieve it from an url?
$output = ob_get_contents();
ob_end_clean();

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



Re: [PHP] OO purism sucks - sell me on PHP5?

2006-06-02 Thread Rasmus Lerdorf

tedd wrote:

At 9:00 AM -0700 6/2/06, Rasmus Lerdorf wrote:

[EMAIL PROTECTED] wrote:



-snip- (a bunch of things over my head)


I thought I kept the examples pretty simple actually.  If you have 
specific questions on them I would be happy to explain them in more detail.


-Rasmus

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



Re: [PHP] OO purism sucks - sell me on PHP5?

2006-06-02 Thread tedd
At 10:51 AM -0700 6/2/06, Rasmus Lerdorf wrote:
tedd wrote:
At 9:00 AM -0700 6/2/06, Rasmus Lerdorf wrote:
[EMAIL PROTECTED] wrote:


-snip- (a bunch of things over my head)

I thought I kept the examples pretty simple actually.  If you have specific 
questions on them I would be happy to explain them in more detail.

-Rasmus

-Rasmus:

Simple/Difficult are relative terms -- thanks very much for your kind offer, 
but I think it will be a while before I rise to that level of confusion. 
However, I did cut/paste your eight points into The things I want to learn 
category of my note pad.

In defense of my ignorance, I balance what I want to learn with what I need 
to learn -- as demand prompts, I adjust and learn accordingly. Nothing you 
mentioned was completely foreign to me, just don't test me on it. :-)

You see, and no offense meant, but this isn't my first time at the dance and 
I've seen too many times where people rush in to learn the new dance step only 
to find it was a passing fad and soon replaced with something kewler.

So for now, I'll stay with my tried and true box-step and try not forget the 
reason why we're at the dance in the first place.  :-)

tedd

-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Re: Retrieving Content

2006-06-02 Thread Adam Zey

Rodrigo de Oliveira Costa wrote:

I just discovered the problem I have to retrieve the output of the
site and not the url since its dynamic. Ca I do it like retrieve the
output of this url:

www.tryout.com/1/2/

And of course store it on a variable? How to do it? I founr the func
below but couldnt understand how to make it work with a url.

Thanks guys,
Rodrigo


ob_start();
include('file.php');  //  Could be a site here? What should I do to
retrieve it from an url?
$output = ob_get_contents();
ob_end_clean();

Umm. As I said, just use file_get_contents():

$file = file_get_contents(http://www.tryout.com/1/2/;);

Regards, Adam Zey.

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



RE: [PHP] OO purism sucks - sell me on PHP5?

2006-06-02 Thread Kilbride, James P.
 

 -Original Message-
 From: tedd [mailto:[EMAIL PROTECTED] 
 Sent: Friday, June 02, 2006 3:11 PM
 To: Rasmus Lerdorf; tedd
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] OO purism sucks - sell me on PHP5?
 
SNIP
 
 So for now, I'll stay with my tried and true box-step and 
 try not forget the reason why we're at the dance in the first 
 place.  :-)
 

To hold up the wall and snack upon the foods provided?

 tedd
 
 --
 --
 --
 http://sperling.com  http://ancientstones.com  http://earthstones.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



[PHP] Re: php java intregration

2006-06-02 Thread Vedanta Barooah

really no one?

On 6/2/06, Vedanta Barooah [EMAIL PROTECTED] wrote:

hello all,
i am setting up php_java.dll extension under windows/iis, my php
version is 5.1.2. can any one point me to the download location of
php_java.jar which is needed for the setup.

i searched all the sites/mirrors but its not available. do i have to
compile from source to get that jar? ... let me know,... thanks

- regards, vedanta




--
*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*
Vedanta Barooah
YM! - vedanta2006
Skype - vedanta2006

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



Re: [PHP] Help with enter key in Forms

2006-06-02 Thread Martin Alterisio

2006/6/2, George Babichev [EMAIL PROTECTED]:


Awesome, thank you so much! It works!

On 6/1/06, Chris [EMAIL PROTECTED] wrote:

 George Babichev wrote:
  Ok, I sent it to everyone and you. Now can you answer my question
 please?
  I type in
  1
 
 
 
  2
  into my form in the program that i made, then when I view it, it shows
  1 2
  BUT if I check it in PHP My Admin it displays
  1
 
 
 
  2

 The answer is to change this:

 ? echo .$row['post'].

 to this:

 ? echo .nl2br($row['post']).


 like I said before...

 --
 Postgresql  php tutorials
 http://www.designmagick.com/




Now that your problem is solved it would be a nice idea to study a little
bit more about HTML and PHP so that you can find the explanation and
solution for this and other problems on your own. Please read the manual,
specially when someone is kind enough to point you the exact function to
look for.

PS: Have you understood what went wrong in your script? Have you understood
what is the purpose of nl2br? If not, the kindness of those who answered you
will have been in vain.


Re: [PHP] Re: php java intregration

2006-06-02 Thread Vedanta Barooah

it was not about windows! :)
it was about php getting into IIS instead of  than .net or java
- vedanta


On 6/3/06, tedd [EMAIL PROTECTED] wrote:

really no one?

On 6/2/06, Vedanta Barooah [EMAIL PROTECTED] wrote:
hello all,
i am setting up php_java.dll extension under windows/iis, my php
version is 5.1.2. can any one point me to the download location of
php_java.jar which is needed for the setup.

i searched all the sites/mirrors but its not available. do i have to
compile from source to get that jar? ... let me know,... thanks

- regards, vedanta


sorry, no windows here.

tedd
--

http://sperling.com  http://ancientstones.com  http://earthstones.com




--
*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*

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



[PHP] sessions expiring

2006-06-02 Thread John Gunther

I can't find the proper settings to keep unattended sessions from
expiring in about an hour. Specifically, the $_SESSION variable contents
disappear. I've read the docs, but nothing seems to work. Any ideas?
Here are the session parameters that are in effect:

session.auto_startOn
session.bug_compat_42On
session.bug_compat_warnOn
session.cache_expire180
session.cache_limiternocache
session.cookie_domainno value
session.cookie_lifetime0
session.cookie_path/
session.cookie_secureOff
session.entropy_fileno value
session.entropy_length0
session.gc_divisor100
session.gc_maxlifetime28800
session.gc_probability0
session.namePHPSESSID
session.referer_checkno value
session.save_handlerfiles
session.save_path/var/lib/php4
session.serialize_handlerphp
session.use_cookiesOn
session.use_only_cookiesOff
session.use_trans_sidOff


Thanks.

John Gunther
Bucks vs Bytes Inc

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



[PHP] SPL Iterator and Associative Array

2006-06-02 Thread Jason Karns
I'm going to try my best to explain what I'm trying to do.

I have my own class that has an array member.  This class itself implements
Iterator.  One of the fields in the array is itself an array that I would
like to iterate over. Here's some code:

class Folio implements Iterator {
$projects = array(
array(
'title'=,
'clip'=,
'small'=array('1','2','3')),
array(
'title'=,
'clip'=,
'small'=array('0','1','2'))
);
function title($x){
return current($this-projects[$]['small']);
}

function smalls($x){
return $this-projects[$x]['small'];
}
}

And I'd like to do:
foreach($folio-smalls() as $s){
echo $folio-title();
}

However, at the moment, doing this doesn't increment through the 'small'
array. It loops the correct number of times. But it only prints the first
one. I assumed it was because it wasn't moving the internal array pointer.
So I tried making the method smalls return a reference. Doing that made the
following work perfectly:

reset($folio-smalls());
while($s = current($folio-smalls())){
echo $folio-small();
next($folio-smalls());
}

But trying the foreach loop printed the second, and third elements, then
tried to output one passed the end of the array.

From what I understand, foreach simply expands to 
reset();
while($x=current())
{...; next();}

What do I do?

Jason Karns
~~~
The Ohio State University [www.osu.edu]
Computer Science  Engineering [www.cse.osu.edu]


smime.p7s
Description: S/MIME cryptographic signature


[PHP] Re: SPL Iterator and Associative Array

2006-06-02 Thread Greg Beaver
Jason Karns wrote:
 I'm going to try my best to explain what I'm trying to do.
 
 I have my own class that has an array member.  This class itself implements
 Iterator.  One of the fields in the array is itself an array that I would
 like to iterate over. Here's some code:
 
 class Folio implements Iterator {
 $projects = array(
   array(
   'title'=,
   'clip'=,
   'small'=array('1','2','3')),
   array(
   'title'=,
   'clip'=,
   'small'=array('0','1','2'))
 );
 function title($x){
   return current($this-projects[$]['small']);
  ^^
 }
 
 function smalls($x){
   return $this-projects[$x]['small'];
 }
 }

snip
Hi Jason,

The code you pasted is littered with fatal errors and bugs (I marked one
example with ^^ above).  Please paste a real batch of code that you've
tested and reproduces the error and that will be much more helpful.  The
PHP version would be helpful to know as well.

Greg

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



[PHP] Parse error: syntax error, unexpected '}'

2006-06-02 Thread Mark Sargent

Hi All,

can anone see what's wrong with the below code? I get this error,


*Parse error*: syntax error, unexpected '}' in 
*/usr/local/apache2/htdocs/moviedata2.php* on line *18


*
$age=1;
while($age=100) {
$insert = INSERT INTO age (age_label) VALUES ($age);
$results = mysql_query($insert) or die(mysql_error());
$age++
}



Cheers.

Mark Sargent.

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



Re: [PHP] Parse error: syntax error, unexpected '}'

2006-06-02 Thread Rick Emery

Quoting Mark Sargent [EMAIL PROTECTED]:


Hi All,

can anone see what's wrong with the below code? I get this error,


*Parse error*: syntax error, unexpected '}' in
*/usr/local/apache2/htdocs/moviedata2.php* on line *18

*
$age=1;
while($age=100) {
$insert = INSERT INTO age (age_label) VALUES ($age);
$results = mysql_query($insert) or die(mysql_error());
$age++
}



There's a semi-colon missing at the end of the last line ($age++).

Hope thi shelps,
Rick
--
Rick Emery

When once you have tasted flight, you will forever walk the Earth
 with your eyes turned skyward, for there you have been, and there
 you will always long to return
  -- Leonardo Da Vinci

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



[PHP] RE: SPL Iterator and Associative Array

2006-06-02 Thread Jason Karns
 -Original Message-
 From: Greg Beaver [mailto:[EMAIL PROTECTED] 
 Sent: Friday, June 02, 2006 10:39 PM
 To: Jason Karns
 Cc: php-general@lists.php.net
 Subject: Re: SPL Iterator and Associative Array
 
 Jason Karns wrote:
  I'm going to try my best to explain what I'm trying to do.
  
  I have my own class that has an array member.  This class itself 
  implements Iterator.  One of the fields in the array is itself an 
  array that I would like to iterate over. Here's some code:
  
snip
 
 snip
 Hi Jason,
 
 The code you pasted is littered with fatal errors and bugs (I 
 marked one example with ^^ above).  Please paste a real 
 batch of code that you've tested and reproduces the error and 
 that will be much more helpful.  The PHP version would be 
 helpful to know as well.
 
 Greg
 
 --
 No virus found in this incoming message.
 Checked by AVG Free Edition.
 Version: 7.1.394 / Virus Database: 268.8.1/354 - Release 
 Date: 6/1/2006
  
 

?php
class Folio implements Iterator {
private $projects = array();
private $valid = FALSE;
public function __construct($file = null) {
if(!is_null($file))
$this-load($file);
}
public function load($file){
...
$keys = array();
$values = array();
foreach ($projects as $project) {
$small = array();
$big = array();
foreach
($xpath-query('showcase/images/screenshot/thumbnail',$project) as $img){
$small[] = $img-nodeValue;}
foreach
($xpath-query('showcase/images/screenshot/src',$project) as $img){
$big[] = $img-nodeValue;}

$keys[] =
$xpath-query('@id',$project)-item(0)-nodeValue;
$values[] = array(

'title'=$xpath-query('showcase/title',$project)-item(0)-nodeValue,

'href'=$xpath-query('livesite',$project)-item(0)-nodeValue,

'clip'=$xpath-query('showcase/images/feature/thumbnail',$project)-item(0)
-nodeValue,
'big'=$big,
'small'=$small,

'text'=$xpath-query('showcase/description',$project)-item(0)-nodeValue);
}
$this-projects = array_combine($keys,$values);
}

function smalls($x=null){
if(is_null($x) or !key_exists($x,$this-projects)) $x =
$this-key();
return $this-projects[$x]['small'];
}

function small_src($x=null){
if(is_null($x) or !key_exists($x,$this-projects)) $x =
$this-key();
return current($this-projects[$x]['small']);
}

function small($x=null){
if(is_null($x) or !key_exists($x,$this-projects)) $x =
$this-key();
return 'a href='.$this-small_href().'
title='.$this-small_title().''.$this-small_img($x).'/a';
}

}
?

?php
reset($folio-smalls());
while($s = current($folio-smalls())){
echo $folio-small();
next($folio-smalls());
}

foreach($folio-smalls() as $s){
echo $folio-small();
}
?

Production server will be PHP 5.1.2, developing on 5.0.5
I am also considering making my own 'project' object and having Folio have
an array of 'projects' rather than using the array of associative arrays.
Would this provide a solution?

Thanks,
Jason


smime.p7s
Description: S/MIME cryptographic signature


RE: [PHP] Parse error: syntax error, unexpected '}'

2006-06-02 Thread Bagus Nugroho
how about like this
---
$insert = INSERT INTO age (age_label) VALUES ('$age');
---

 


From: Mark Sargent [mailto:[EMAIL PROTECTED]
Sent: Sat 03-Jun-2006 10:02
To: PHP List
Subject: [PHP] Parse error: syntax error, unexpected '}'



Hi All,

can anone see what's wrong with the below code? I get this error,


*Parse error*: syntax error, unexpected '}' in
*/usr/local/apache2/htdocs/moviedata2.php* on line *18

*
$age=1;
while($age=100) {
$insert = INSERT INTO age (age_label) VALUES ($age);
$results = mysql_query($insert) or die(mysql_error());
$age++
}



Cheers.

Mark Sargent.

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






Re: [PHP] Re: php java intregration

2006-06-02 Thread Vedanta Barooah

if i am not wrong the bridge is better if you are trying to put in php
into a java app server. i do know to create the jar in linux i
will try some other combinations and keep things posted.
i am not able to find the jar, anywhere yet though :(
- vedanta

On 6/3/06, Jon Anderson [EMAIL PROTECTED] wrote:

You could try something like PHP-Java bridge:
http://php-java-bridge.sourceforge.net/

I've set it up for our server farm at work, but never used it myself.
The developer who requested it seems quite fond of the extension, and
performance seems to be excellent.

jon

Vedanta Barooah wrote:
 really no one?

 On 6/2/06, Vedanta Barooah [EMAIL PROTECTED] wrote:
 hello all,
 i am setting up php_java.dll extension under windows/iis, my php
 version is 5.1.2. can any one point me to the download location of
 php_java.jar which is needed for the setup.

 i searched all the sites/mirrors but its not available. do i have to
 compile from source to get that jar? ... let me know,... thanks

 - regards, vedanta








--
*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*~:~*
Vedanta Barooah

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



Re: [PHP] Parse error: syntax error, unexpected '}'

2006-06-02 Thread Mark Sargent

Hi All,

sorry, found it. Forgot the ; after $age++. Cheers.

Mark Sargent.

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



[PHP] Recall: [PHP] Parse error: syntax error, unexpected '}'

2006-06-02 Thread Bagus Nugroho
Bagus Nugroho would like to recall the message, [PHP] Parse error: syntax 
error, unexpected '}'.


[PHP] HTTP HEADERS

2006-06-02 Thread kartikay malhotra

Hi all!

I use HTTP POST to upload a file. I've a PHP script running on the server.
Are HTTP headers passed with this request? How can I see the headers passed
to the server?

Thanks
KM