Re: [PHP] html tools for Web page

2007-10-19 Thread edwardspl

Łukasz Wojciechowski wrote:


On 10/18/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 


Dear All,

Is there a tool better than fckeditor ( http://www.fckeditor.net ) ?
Would you mind recommend ?
   



You may check out
http://tinymce.moxiecode.com/

 


Hello,

Does it support multi-language and linux system ?

Thanks !

Edward.


[PHP] PHP/MySQL CMS for Articles/Studies/Research Papers?

2007-10-19 Thread Jason Paschal
One of my clients is a veterinarian who performs research on the side.  He
wants to be able to post his papers online and let ppl comment and have
discussions.  he's not just a dabbler.  the university of georgia is
(was?) conducting clinical trials for his parvo cure that has already saved
hundreds of animals from certain death.

Caveats:
- he has no HTML knowledge, so something with a rich-text editor is a must.
- the simpler the interface, the better (For God's sake, Jim, I'm a vet, not
a web developer!)
- he's on a managed server, has to be something we can upload via ftp
- wants to be able to include images in his posts
- free is better

right now, he's using PHP-nuke, but he's not very keen on it, nor am i.

drupal is a possibility with the image and rich-text modules, but it can get
messy for someone whose web mastery extends to sending emails (consider
drupal's taxonomy system.  at the most, he might just want to make a new
category and be done with it and not get confounded with parent/child
relationships and their weights).

he has a blog, but that is going to be used for dealing with particular
cases.  the CMS site will be used for the big articles and papers.

the CMS should be blog-like in nature, and we may end up just creating
another blogspot blog for him to use (connected via FTP publishing).

just wanted to know if any of you have seen anything geared for this sort of
content, something professional-looking that doesn't come with a huge
learning curve.  it wouldn't have to be TOO fancy, i could probably make
something, but didn't want to re-invent the round-thing-that-rolls.

thank you,

~jason



-- 
Crunchmutt Studios
Latest News Headlines: http://www.rssvideonews.com
http://www.crunchmutt.com
http://www.deadjoe.com
http://www.dailymedication.com
http://www.extremesportclips.com
http://www.coolanimalclips.com
http://www.robotclips.com
http://www.newsfinger.com
http://www.postyourimage.com
http://www.nakedalarmclock.com


Re: [PHP] Catching/handing out of memory errors...

2007-10-19 Thread Stut

John Parker wrote:

In essence, I'm asking if it's technically possible to catch an out of
memory error in PHP. 


As such, it's not really a code specific issue. I'm just asked whether
or not it's possible. (I'm pretty sure it isn't, I'm just double
checking.)


As far as I know it's not technically possibly because the problem is 
caught when an attempt is made to allocate more memory than allowed and 
because it's a fatal error execution stops there.


-Stut

--
http://stut.net/


-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED] 
Sent: 19 October 2007 13:46

To: John Parker; php-general@lists.php.net
Subject: RE: [PHP] Catching/handing out of memory errors...

[snip]
I've tried using a error handler and try/catch block, but it doesn't
seem to be possible.
 
Is this the case, or am I missing something obvious?

[/snip]

Without seeing your code or knowing more specifics about what you are
trying to do it will be hard to answer this question.

--
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] INSTALL_ROOT and apxs

2007-10-19 Thread Andre Majorel
I'm trying to build PHP 5.2 as an Apache 2.0 handler module.
Apache and PHP are installed with DESTDIR/INSTALL_ROOT=/sandbox
set because the end goal is to make a package, not to install on
the build machine.

The paths returned by apxs are relative to /, not to /sandbox
which throws off PHP's makefile :

  /sandbox/php-5.2$ ./configure --with-apxs2=/sandbox/opt/apache/bin/apxs
  /sandbox/php-5.2$ make
  /sandbox/php-5.2/libtool [...] -I/opt/apache/include [...]
-c sapi/apache2handler/mod_php5.c -o sapi/apache2handler/mod_php5.lo
  In file included from sapi/apache2handler/mod_php5.c:26:
  /sandbox/php-5.2/sapi/apache2handler/php_apache.h:24:19: error:
httpd.h: No such file or directory

Is there any existing mechanism to deal with this ? For example,
something to make PHP's makefile aware that it should prepend
INSTALL_ROOT to all paths returned by apxs ?

-- 
André Majorel URL:http://www.teaser.fr/~amajorel/
Do not use this account for regular correspondence.
See the URL above for contact information.

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



Re: [PHP] This, then that. [solved?]

2007-10-19 Thread tedd

Hi gang:

I think I found a solution.

Here's the url:

http://www.webbytedd.com/bbb/image-test1/

The point is that the image is only accessible via this script, is 
this correct?


The technique I used simply runs the first php script, which creates 
the page that has uses ajax to trigger another php script to run.


It was a question of timing.

Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] problem calling functions

2007-10-19 Thread Stut

Jay Blanchard wrote:

I don't think you can put a function name in a variable and call it like
$function($var).


Yes you can - it's basically the same as variable variables.

-Stut

--
http://stut.net/

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



Re: [PHP] IF command

2007-10-19 Thread Bill Allaire

On Oct 18, 2007, at 9:50 PM, Bastien Koert wrote:




Are you sure that the value is a string? If its numeric, then try  
the check without the quotes around the value




http://www.php.net/manual/en/language.operators.comparison.php
If you compare an integer with a string, the string is converted to  
a number. If you compare two numerical strings, they are compared as  
integers.


?php

$component_reference = 5;
if ( ($component_reference != 5) AND ($component_reference !=  
19) ) {

echo(I am not a 5 or a 19br);
}
else
echo(I am a 5 or a 19br);


$component_reference = 5;
if ( ($component_reference != 5) AND ($component_reference !=  
19) ) {

echo(I am not a 5 or a 19br);
}
else
echo(I am a 5 or a 19br);

$component_reference = 3;
if ( ($component_reference != 5) AND ($component_reference !=  
19) ) {

echo(I am not a 5 or a 19br);
}
else
echo(I am a 5 or a 19br);

$component_reference = 3;
if ( ($component_reference != 5) AND ($component_reference !=  
19) ) {

echo(I am not a 5 or a 19br);
}
else
echo(I am a 5 or a 19br);

?



The results:

I am a 5 or a 19
I am a 5 or a 19
I am not a 5 or a 19
I am not a 5 or a 19

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



Re: [PHP] Reference return buggy notice?

2007-10-19 Thread Stut

Jochem Maas wrote:

Stut wrote:

Say you have a function that builds a fairly large array and then
returns it. If you just return it as usual PHP will make a copy of that
array and therefore use twice the amount of memory than it needs to.


php has something called 'copy on change' so until an attempt to make a change 
on
the returned array is made the doubling of memory usage doesn't occur. afaik.


Interesting. Didn't know that.


are there any benchmarks either way?


I've never come across any, but I don't need a benchmark to know that 
the potential for double the memory use is best avoided.



References also provide a way to return more than one variable from a
function, but I doubt many PHP developers come across the need to do that.


an example is returning the total count of a given sql statement in an
'by reference' argument whilst returning a 'paged' result set.


Good example. Not one I'd think of because all my SQL is wrapped up in 
classes that expose that stuff in other ways.



Where in the manual does it say that? I've never seen it and I can't
find it.


say what?


In the email I replied to from M. Sokolewicz...

As the manual states if you think you need to use references, 
think again, you probably don't.


Just wondering where it says that.

-Stut

--
http://stut.net/

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



Re: [PHP] Reference return buggy notice?

2007-10-19 Thread Jochem Maas
Stut wrote:

...

 
 Say you have a function that builds a fairly large array and then
 returns it. If you just return it as usual PHP will make a copy of that
 array and therefore use twice the amount of memory than it needs to.

php has something called 'copy on change' so until an attempt to make a change 
on
the returned array is made the doubling of memory usage doesn't occur. afaik.

are there any benchmarks either way?

 
 References also provide a way to return more than one variable from a
 function, but I doubt many PHP developers come across the need to do that.

an example is returning the total count of a given sql statement in an
'by reference' argument whilst returning a 'paged' result set.

 
 Where in the manual does it say that? I've never seen it and I can't
 find it.

say what?

 
 -Stut
 

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



RE: [PHP] This, then that.

2007-10-19 Thread Robert Cummings
On Fri, 2007-10-19 at 13:31 -0700, Instruct ICC wrote:
  I want to prohibit an image from being shown to anyone who is not 
  permitted (i.e., logged in).
  
  The way I want to do this is to:
  
  1. Set [file] permissions...
 
 
 
 What if 2 or more users access the application at the same time?
 
 Set the permissions so only the PHP application can access it.
 Have the PHP application decide if this present user running this instance 
 should see the image.
 If approved, display image.

One idea that has always been REALLY popular around here... stuff your
image in a database. *MUHAWHAWHAWHAWHAW* *Ducks from the flying rocks*.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



RE: [PHP] This, then that. [solved?]

2007-10-19 Thread Instruct ICC

 but in the img tag, try src=display_image.php?id=anId
 and in display_image.php, test if the user is authorized before displaying 
 the image.
 Then a direct call to display_image.php?id=anId would still have a chance to 
 authenticate the user.

Forgot to reiterate:
Keep the images where only PHP can read them.
If you have the images in a file or a database, use header, and echo or 
fpassthru on the data.

Something like jan at anh dot sk
http://php.he.net/image

_
Windows Live Hotmail and Microsoft Office Outlook – together at last.  Get it 
now.
http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] socket_bind function

2007-10-19 Thread Bill Rausch


I see reading the online docs that I'm supposed to go:

socket_create...
socket_bind...
socket_connect...

I've never used the bind function and it hasn't seemed to make any
difference? I've always just done socket_create() and then
socket_connect(). What benefit is there to putting a socket_bind in
between?

Bill

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



Re: [PHP] json_encode/json_decode, take 2

2007-10-19 Thread Jochem Maas
try seeing what json_encode() creates:

$json = json;
$data = array(
no_1 = $json,
no_2 = $json,
no_3 = $json,
no_4 = array(foo = $json, bar = $json),
);
print_r({{$json}_encode}($data));


Christoph Boget wrote:
 The string used below in $myArrEncoded is generated in javascript, after
 creating the structure and spitting out:
 
 var JSONVar = javascriptVar.toSource();
 
 I can eval JSONVar and work with it as I would be working with the original
 javascriptVar so I know the transition back and forth from a structure to a
 string isn't causing problems.  The problem is when I try to work with the
 string in PHP.
 
 Here is my code:
 
 ?php
 
   $myArrEncoded = ({Salary:{'50-70K':{filterType:quot;rangequot;,
 fieldName:quot;SALARYquot;, fieldValueLabel:quot;50-70Kquot;,
 lowerValue:quot;50quot;, upperValue:quot;70quot;,
 inclusive:quot;BOTHquot;}},
 Position:{Developer:{filterType:quot;singlequot;,
 fieldName:quot;POSITIONquot;, fieldValueLabel:quot;Developerquot;,
 fieldValue:quot;Developerquot;, constraint:quot;equalsquot;},
 SysAdmin:{filterType:quot;singlequot;, fieldName:quot;POSITIONquot;,
 fieldValueLabel:quot;System Adminquot;, fieldValue:quot;SysAdminquot;,
 constraint:quot;equalsquot;}}, 'Required Action':{'2 -
 GenScreen':{filterType:quot;singlequot;,
 fieldName:quot;REQUIRED_ACTIONquot;, fieldValueLabel:quot;General Phone
 Screenquot;, fieldValue:quot;2 - GenScreenquot;,
 constraint:quot;equalsquot;}}});
 
   echo var_dump( $myArrEncoded ) . 'brbr';
   echo '$myArr encoded: ' . $myArrEncoded . 'brbr';
   try {
 echo '$myArr decoded: pre' . print_r( json_decode( $myArrEncoded, TRUE
 ), TRUE ) . '/prebrbr';
   } catch( Exception $e ) {
 echo 'Error: ' . var_dump( $e );
   }
 
 ?
 
 When I run it, I get the following output:
 
 
 
 string(587) ({Salary:{'50-70K':{filterType:range,
 fieldName:SALARY, fieldValueLabel:50-70K, lowerValue:50,
 upperValue:70, inclusive:BOTH}},
 Position:{Developer:{filterType:single, fieldName:POSITION,
 fieldValueLabel:Developer, fieldValue:Developer,
 constraint:equals}, SysAdmin:{filterType:single,
 fieldName:POSITION, fieldValueLabel:System Admin,
 fieldValue:SysAdmin, constraint:equals}}, 'Required Action':{'2 -
 GenScreen':{filterType:single, fieldName:REQUIRED_ACTION,
 fieldValueLabel:General Phone Screen, fieldValue:2 - GenScreen,
 constraint:equals}}})
 
 $myArr encoded: ({Salary:{'50-70K':{filterType:range,
 fieldName:SALARY, fieldValueLabel:50-70K, lowerValue:50,
 upperValue:70, inclusive:BOTH}},
 Position:{Developer:{filterType:single, fieldName:POSITION,
 fieldValueLabel:Developer, fieldValue:Developer,
 constraint:equals}, SysAdmin:{filterType:single,
 fieldName:POSITION, fieldValueLabel:System Admin,
 fieldValue:SysAdmin, constraint:equals}}, 'Required Action':{'2 -
 GenScreen':{filterType:single, fieldName:REQUIRED_ACTION,
 fieldValueLabel:General Phone Screen, fieldValue:2 - GenScreen,
 constraint:equals}}})
 
 $myArr decoded: ({Salary:{'50-70K':{filterType:range,
 fieldName:SALARY, fieldValueLabel:50-70K, lowerValue:50,
 upperValue:70, inclusive:BOTH}},
 Position:{Developer:{filterType:single, fieldName:POSITION,
 fieldValueLabel:Developer, fieldValue:Developer,
 constraint:equals}, SysAdmin:{filterType:single,
 fieldName:POSITION, fieldValueLabel:System Admin,
 fieldValue:SysAdmin, constraint:equals}}, 'Required Action':{'2 -
 GenScreen':{filterType:single, fieldName:REQUIRED_ACTION,
 fieldValueLabel:General Phone Screen, fieldValue:2 - GenScreen,
 constraint:equals}}})
 
 
 
 Why isn't json_decode() converting the string to an array?  Is there
 something extra in there that json_decode() can't deal with?  I can work
 with it fine in javascript... :(
 
 thnx,
 Christoph
 

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



Re: [PHP] json_encode/json_decode, take 2

2007-10-19 Thread Nathan Nobbe
On 10/19/07, Jochem Maas [EMAIL PROTECTED] wrote:

 Christoph Boget wrote:
  The string used below in $myArrEncoded is generated in javascript,
 after
  creating the structure and spitting out:
 
  var JSONVar = javascriptVar.toSource();
 
  I can eval JSONVar and work with it as I would be working with the
 original
  javascriptVar so I know the transition back and forth from a structure
 to a
  string isn't causing problems.  The problem is when I try to work with
 the
  string in PHP.
 
  Here is my code:

 quot; is not what you think it is (but that could be my mail client),
 and the exterior parentheses are also incorrect. your try/catch block is
 doing
 nothing because neither function throws exceptions.


i thought it might be something like that, but i didnt spend long enough at
it to verify.
here is a great tool to help:

http://www.jslint.com/

-nathan


Re: [PHP] json_encode/json_decode, take 2

2007-10-19 Thread Jochem Maas
Christoph Boget wrote:
 The string used below in $myArrEncoded is generated in javascript, after
 creating the structure and spitting out:
 
 var JSONVar = javascriptVar.toSource();
 
 I can eval JSONVar and work with it as I would be working with the original
 javascriptVar so I know the transition back and forth from a structure to a
 string isn't causing problems.  The problem is when I try to work with the
 string in PHP.
 
 Here is my code:

quot; is not what you think it is (but that could be my mail client),
and the exterior parentheses are also incorrect. your try/catch block is doing
nothing because neither function throws exceptions.

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



RE: [PHP] This, then that. [solved?]

2007-10-19 Thread Instruct ICC

 Hi gang:
 
 I think I found a solution.
 
 Here's the url:
 
 http://www.webbytedd.com/bbb/image-test1/
 
 The point is that the image is only accessible via this script, is 
 this correct?

I can access it without a script:
http://www.webbytedd.com/bbb/image-test1/images/a.jpg

It may be difficult to guess a.jpg even if I can guess /images
but in the img tag, try src=display_image.php?id=anId
and in display_image.php, test if the user is authorized before displaying the 
image.
Then a direct call to display_image.php?id=anId would still have a chance to 
authenticate the user.
_
Peek-a-boo FREE Tricks  Treats for You!
http://www.reallivemoms.com?ocid=TXT_TAGHMloc=us

Re: [PHP] Rename does not work

2007-10-19 Thread Børge Holen
On Friday 19 October 2007 12:49:50 Sascha Braun | CEO @ BRAUN Networks wrote:
 Hi everyone,

 I am using the rename function on my local development
 system fine. But as soon as I upload the script, the
 rename function does not work anymore.

 Is there a specific compiler flag needed, to make rename
 work on both plattforms?

say, depends on what the rename function is. I've done some things I find 
hard with php using remote apps from the host OS.


 Thank you very much.

 Sascha

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



Re: [PHP] picture upload within a form

2007-10-19 Thread Børge Holen
On Friday 19 October 2007 10:34:28 Ronald Wiplinger wrote:
 I have a form, where I upload a picture and a corresponding text.

this far I'm with you

 

 Is it possible to have a form (upload picture) within a form (text)?
 As I have it now, the submit button just does nothing.

here you escapes me. A form inside a form, or two forms or orororor something?
the submit button, witch one is that?
you want the image to be uploaded into the likes of webmail systems; sort of 
like a temporary remote storage for further execution?


 bye

 Ronald


--

Børge Holen

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



RE: [PHP] p-s-e-x-e-c

2007-10-19 Thread Instruct ICC

   When I run the command on the server itself, it
   works just fine. When I run the same command via a webpage, the text file
   does not generate.
 
 
  I also have a similar problem but reversed.  It works in a webpage but not 
  on the command line.
  mysql_connect, mssql_connect, and a non-db function.
  A command line script calling file() to call the web page works however.
  And it just stopped working about 2 months ago (from the command line).
 
 one word: permissions
... 
 also perhaps the php.ini settings are different for either one, and
 there's a different ini file for shell vs. web.

Even though the build date was before the time the problem started, I 
scrutinized both the phpinfo's which pointed to the same php.ini, but I noticed 
that the ./configure switches did not match up and finally the admin admitted 
that his yum update must have overwritten the formerly manually compiled 
version.

My issue is resolved.  Sorry for the partial hijacking of this thread but as 
you can see, it can be beneficial.

_
Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare!
http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews

Re: [PHP] directory modification dates

2007-10-19 Thread Robert Cummings
On Sat, 2007-10-20 at 01:36 +0300, Marek wrote:
 I have a simple directory listing script - you can move up and down
 directories and it shows the files/dirs inside. Now I have to figure out
 a way to display the latest modification time for each directory.
 
 The problem is that filemtime() works only if the modifications are done
 on the first level. For example, if I add files in dir1/dir2/dir3/, then
  the modification time for dir1 doesn't update.
 
 My first instinct was to find the correct time recursively on each load
 but there are so many files and so many visitors that it clogs the
 server. I have a few other ideas but they seem rather ugly (like hidden
 files with stored info in each directory).
 
 Can you suggest any better ways to approach this problem?

When a file is uploaded/changed ascend the directory tree and touch()
each of the directories.

http://ca.php.net/manual/en/function.touch.php

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Regex for Advanced search feature

2007-10-19 Thread Robert Cummings
On Fri, 2007-10-19 at 09:48 -0700, Kevin Murphy wrote:
 I'm trying to create an advanced search feature for my site, and I  
 have it mostly working the way I want. I take whatever search term  
 ($searchkey) that the user submits, explodes if off any spaces  
 between words, and then use that to search for each word separately.
 
 $keys = explode( ,$searchkey);
 
 So the search phrase of:
 
 Dog Cat Horse
 
 would output :
 
 Array
 (
  [0] = Dog
  [1] = Cat
  [2] = Horse
 )
 
 However, I would like to add the ability to have phrases in there  
 indicated by  marks. So, if the search phrase was this:
 
 Dog Cat Horse
 
 It would output:
 
 Array
 (
  [0] = Dog Cat
  [1] = Horse
 )
 
 My concept to solve this is right before I explode the keys as above,  
 to replace any spaces within  marks with a garbage string of  
 characters (say XX) using a regular expression, and then  
 later replace it back with a space. However, I suck at regular  
 expressions and can't figure it out.
 
 Anyone have a way for me to accomplish this with a regular expression  
 or with another method?

?php

$foo = 'dog cat horse mouse tiger fish';

if( preg_match_all( '/[[:space:]]+(([^]*)|([^[:space:]]+))/', '
'.$foo, $bits ) )
{
print_r( $bits );
}

?

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] problem calling functions

2007-10-19 Thread afan pasalic
yup! it works perfect.
obviously, it's MY fault.
:-)

thanks stut

-afan

Stut wrote:
 afan pasalic wrote:
 actually, what example you are talking about? I got jay's example only?

 http://dev.stut.net/php/varfunc.php

 -Stut


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



Re: [PHP] Which PHP-Editor to use?

2007-10-19 Thread Børge Holen
On Thursday 18 October 2007 09:59:16 Nathan Nobbe wrote:
 On 10/18/07, Zoltán Németh [EMAIL PROTECTED] wrote:
  2007. 10. 18, csütörtök keltezéssel 12.56-kor Matt Arnilo S. Baluyos
 
  (Mailing Lists) ezt írta:
   Does Eclipse already have word-wrap?
  
   To my disappointment, it was still lacking that basic functionality
   the last time I tried it.

 a quick google tells the story of word wrap in eclipse; strangely ive never
 felt the need for it and ive been using php-eclipse for about 2 years now.

 i go to kate for all my peripheral editing needs.  i was using jedit; but
 kate
 is much leaner and i use kde anyway.  plus protoeditor can be compiled into
 kate which is nice.

 -nathan


Why wouldn't just anyone use quanta, and let this old bugger thread be, it's 
sleepy

---
Børge Holen

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



[PHP] Re: Regex for Advanced search feature

2007-10-19 Thread Al
Go here and get charprobe http://www.dextronet.com/charprobe.php  It's a super 
utility to have.


Look up the hex code for a space, /x20 as I recall.

Then pick a non-printable code that you like e.g., /x83 or a printable one that 
users cannot enter.


Then simply preg_replace(%/x20+%, /83, $string);//one or more spaces

If you want to preserve the number of spaces don't use +.


Kevin Murphy wrote:
I'm trying to create an advanced search feature for my site, and I have 
it mostly working the way I want. I take whatever search term 
($searchkey) that the user submits, explodes if off any spaces between 
words, and then use that to search for each word separately.


$keys = explode( ,$searchkey);

So the search phrase of:

Dog Cat Horse

would output :

Array
(
[0] = Dog
[1] = Cat
[2] = Horse
)

However, I would like to add the ability to have phrases in there 
indicated by  marks. So, if the search phrase was this:


Dog Cat Horse

It would output:

Array
(
[0] = Dog Cat
[1] = Horse
)

My concept to solve this is right before I explode the keys as above, to 
replace any spaces within  marks with a garbage string of characters 
(say XX) using a regular expression, and then later replace it 
back with a space. However, I suck at regular expressions and can't 
figure it out.


Anyone have a way for me to accomplish this with a regular expression or 
with another method?




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



Re: [PHP] problem calling functions

2007-10-19 Thread Stut

afan pasalic wrote:

actually, what example you are talking about? I got jay's example only?


http://dev.stut.net/php/varfunc.php

-Stut

--
http://stut.net/


Stut wrote:

afan pasalic wrote:

why then the code doesn't work?
the error I'm getting is: Fatal error: Call to undefined function
solution1() in ... even the function itself is just above the line that
calls function?

I can only guess that you're not showing us the code you're actually
running. See the example I put in another reply - that works and is
based on the code you sent.

-Stut



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



[PHP] Dang lack of a list reply button

2007-10-19 Thread Nathan Hawks
I have only done this when I am building the function name using a
string expression, so my advice might not be necessary in your case but
it has worked for me:

{$function}($var);

In that case, the curly braces equate to the eval() function in
Javascript.

Jay Blanchard wrote:
 I don't think you can put a function name in a variable and call it
like
 $function($var).

Yes you can - it's basically the same as variable variables.

-Stut

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



Re: [PHP] problem calling functions

2007-10-19 Thread afan pasalic
why then the code doesn't work?
the error I'm getting is: Fatal error: Call to undefined function
solution1() in ... even the function itself is just above the line that
calls function?

-afan



Stut wrote:
 Jay Blanchard wrote:
 I don't think you can put a function name in a variable and call it like
 $function($var).

 Yes you can - it's basically the same as variable variables.

 -Stut


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



Re: [PHP] problem calling functions

2007-10-19 Thread afan pasalic
Jay Blanchard wrote:
 [snip]
  [snip]
 ?php
 function solution1($var1){
 // some code
 }

 function solution2($var2){
 // some code
 }

 function solution3($var3){
 // some code
 }

 if ($function == 'solution1' or $function == 'solution2' or $function ==
 'solution3')
 {
 $my_solution = $function($var); # this supposed to call one of
 solution functions, right?
 }
 ?
 [/snip]

 I don't think you can put a function name in a variable and call it like
 $function($var). You'd be better of with a case statement in one
 function and call the proper solution (quick syntax, may need a little
 fixing;

 function my_solution($function, $var){
   switch $function{
   case function1:
   ...do stuff...
   break;
   case function1:


   etc.
   }
 }
 [/snip]

 And call it like this;

 my_solution('function1', $var);
   

actually, I did a little bit different:

switch($function)
{
case 'solution1':
   solution1($var1);
   break;

case 'solution2':
   solution2($var2);
   break;

case 'solution3':
   solution3($var3);
   break;
}



;-)

-afan

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



Re: [PHP] Dang lack of a list reply button

2007-10-19 Thread Stut

Nathan Hawks wrote:

I have only done this when I am building the function name using a
string expression, so my advice might not be necessary in your case but
it has worked for me:

{$function}($var);

In that case, the curly braces equate to the eval() function in
Javascript.


You don't need the { }.

http://dev.stut.net/php/varfunc.php

-Stut

--
http://stut.net/

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



Re: [PHP] problem calling functions

2007-10-19 Thread afan pasalic


Robin Vickery wrote:
 On 19/10/2007, afan pasalic [EMAIL PROTECTED] wrote:
   
 hi
 I have a problem with calling functions:

 ?php
 function solution1($var1){
 // some code
 }

 function solution2($var2){
 // some code
 }

 function solution3($var3){
 // some code
 }

 if ($function == 'solution1' or $function == 'solution2' or $function ==
 'solution3')
 {
 $my_solution = $function($var); # this supposed to call one of
 solution functions, right?
 }
 ?

 suggestions?
 

 suggestions for what?

 What is your problem? If you set $function to 'solution1' and run your
 code, it will indeed execute solution1().

 -robin
   

the problem is that this code doesn't work. and I was asking where is
the problem, or can I do it this way at all.
:-)

-afan

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



Re: [PHP] This, then that.

2007-10-19 Thread Wolf
actually, you could run it by 

1.  making the page
2. flushing the output buffer (which puts it in the screen)
3. run the 2nd script

 tedd [EMAIL PROTECTED] wrote: 
 At 12:06 AM -0400 10/19/07, Nathan Hawks wrote:
 If by creates a web page you just mean it echos output to the browser,
 and you want to do something else after that, then:
 
 After you have sent your /html and have no more output for the
 browser, just use the include() function to run your extra process.
 
 e.g
 
 /html
 ?php include('secondary_script.php'); ?
 
 
 No, includes don't work that way.
 
 Your secondary_script.php will be run before your html is shown.
 
 You have to try it to understand.
 
 Cheers,
 
 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] json_encode/json_decode, take 2

2007-10-19 Thread Christoph Boget
The string used below in $myArrEncoded is generated in javascript, after
creating the structure and spitting out:

var JSONVar = javascriptVar.toSource();

I can eval JSONVar and work with it as I would be working with the original
javascriptVar so I know the transition back and forth from a structure to a
string isn't causing problems.  The problem is when I try to work with the
string in PHP.

Here is my code:

?php

  $myArrEncoded = ({Salary:{'50-70K':{filterType:quot;rangequot;,
fieldName:quot;SALARYquot;, fieldValueLabel:quot;50-70Kquot;,
lowerValue:quot;50quot;, upperValue:quot;70quot;,
inclusive:quot;BOTHquot;}},
Position:{Developer:{filterType:quot;singlequot;,
fieldName:quot;POSITIONquot;, fieldValueLabel:quot;Developerquot;,
fieldValue:quot;Developerquot;, constraint:quot;equalsquot;},
SysAdmin:{filterType:quot;singlequot;, fieldName:quot;POSITIONquot;,
fieldValueLabel:quot;System Adminquot;, fieldValue:quot;SysAdminquot;,
constraint:quot;equalsquot;}}, 'Required Action':{'2 -
GenScreen':{filterType:quot;singlequot;,
fieldName:quot;REQUIRED_ACTIONquot;, fieldValueLabel:quot;General Phone
Screenquot;, fieldValue:quot;2 - GenScreenquot;,
constraint:quot;equalsquot;}}});

  echo var_dump( $myArrEncoded ) . 'brbr';
  echo '$myArr encoded: ' . $myArrEncoded . 'brbr';
  try {
echo '$myArr decoded: pre' . print_r( json_decode( $myArrEncoded, TRUE
), TRUE ) . '/prebrbr';
  } catch( Exception $e ) {
echo 'Error: ' . var_dump( $e );
  }

?

When I run it, I get the following output:



string(587) ({Salary:{'50-70K':{filterType:range,
fieldName:SALARY, fieldValueLabel:50-70K, lowerValue:50,
upperValue:70, inclusive:BOTH}},
Position:{Developer:{filterType:single, fieldName:POSITION,
fieldValueLabel:Developer, fieldValue:Developer,
constraint:equals}, SysAdmin:{filterType:single,
fieldName:POSITION, fieldValueLabel:System Admin,
fieldValue:SysAdmin, constraint:equals}}, 'Required Action':{'2 -
GenScreen':{filterType:single, fieldName:REQUIRED_ACTION,
fieldValueLabel:General Phone Screen, fieldValue:2 - GenScreen,
constraint:equals}}})

$myArr encoded: ({Salary:{'50-70K':{filterType:range,
fieldName:SALARY, fieldValueLabel:50-70K, lowerValue:50,
upperValue:70, inclusive:BOTH}},
Position:{Developer:{filterType:single, fieldName:POSITION,
fieldValueLabel:Developer, fieldValue:Developer,
constraint:equals}, SysAdmin:{filterType:single,
fieldName:POSITION, fieldValueLabel:System Admin,
fieldValue:SysAdmin, constraint:equals}}, 'Required Action':{'2 -
GenScreen':{filterType:single, fieldName:REQUIRED_ACTION,
fieldValueLabel:General Phone Screen, fieldValue:2 - GenScreen,
constraint:equals}}})

$myArr decoded: ({Salary:{'50-70K':{filterType:range,
fieldName:SALARY, fieldValueLabel:50-70K, lowerValue:50,
upperValue:70, inclusive:BOTH}},
Position:{Developer:{filterType:single, fieldName:POSITION,
fieldValueLabel:Developer, fieldValue:Developer,
constraint:equals}, SysAdmin:{filterType:single,
fieldName:POSITION, fieldValueLabel:System Admin,
fieldValue:SysAdmin, constraint:equals}}, 'Required Action':{'2 -
GenScreen':{filterType:single, fieldName:REQUIRED_ACTION,
fieldValueLabel:General Phone Screen, fieldValue:2 - GenScreen,
constraint:equals}}})



Why isn't json_decode() converting the string to an array?  Is there
something extra in there that json_decode() can't deal with?  I can work
with it fine in javascript... :(

thnx,
Christoph


[PHP] Regex for Advanced search feature

2007-10-19 Thread Kevin Murphy
I'm trying to create an advanced search feature for my site, and I  
have it mostly working the way I want. I take whatever search term  
($searchkey) that the user submits, explodes if off any spaces  
between words, and then use that to search for each word separately.


$keys = explode( ,$searchkey);

So the search phrase of:

Dog Cat Horse

would output :

Array
(
[0] = Dog
[1] = Cat
[2] = Horse
)

However, I would like to add the ability to have phrases in there  
indicated by  marks. So, if the search phrase was this:


Dog Cat Horse

It would output:

Array
(
[0] = Dog Cat
[1] = Horse
)

My concept to solve this is right before I explode the keys as above,  
to replace any spaces within  marks with a garbage string of  
characters (say XX) using a regular expression, and then  
later replace it back with a space. However, I suck at regular  
expressions and can't figure it out.


Anyone have a way for me to accomplish this with a regular expression  
or with another method?


--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada College
www.wnc.edu
775-445-3326

P.S. Please note that my e-mail and website address have changed from  
wncc.edu to wnc.edu.





RE: [PHP] problem calling functions

2007-10-19 Thread Jay Blanchard
[snip]
 [snip]
?php
function solution1($var1){
// some code
}

function solution2($var2){
// some code
}

function solution3($var3){
// some code
}

if ($function == 'solution1' or $function == 'solution2' or $function ==
'solution3')
{
$my_solution = $function($var); # this supposed to call one of
solution functions, right?
}
?
[/snip]

I don't think you can put a function name in a variable and call it like
$function($var). You'd be better of with a case statement in one
function and call the proper solution (quick syntax, may need a little
fixing;

function my_solution($function, $var){
switch $function{
case function1:
...do stuff...
break;
case function1:


etc.
}
}
[/snip]

And call it like this;

my_solution('function1', $var);

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



Re: [PHP] problem calling functions

2007-10-19 Thread Robin Vickery
On 19/10/2007, afan pasalic [EMAIL PROTECTED] wrote:
 hi
 I have a problem with calling functions:

 ?php
 function solution1($var1){
 // some code
 }

 function solution2($var2){
 // some code
 }

 function solution3($var3){
 // some code
 }

 if ($function == 'solution1' or $function == 'solution2' or $function ==
 'solution3')
 {
 $my_solution = $function($var); # this supposed to call one of
 solution functions, right?
 }
 ?

 suggestions?

suggestions for what?

What is your problem? If you set $function to 'solution1' and run your
code, it will indeed execute solution1().

-robin

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



Re: [PHP] This, then that.

2007-10-19 Thread Zoltán Németh
2007. 10. 19, péntek keltezéssel 12.16-kor tedd ezt írta:
 At 12:06 AM -0400 10/19/07, Nathan Hawks wrote:
 If by creates a web page you just mean it echos output to the browser,
 and you want to do something else after that, then:
 
 After you have sent your /html and have no more output for the
 browser, just use the include() function to run your extra process.
 
 e.g
 
 /html
 ?php include('secondary_script.php'); ?
 
 
 No, includes don't work that way.
 
 Your secondary_script.php will be run before your html is shown.

no, you just have to put a flush(); before the include

greets
Zoltán Németh

 
 You have to try it to understand.
 
 Cheers,
 
 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] This, then that.

2007-10-19 Thread tedd

At 12:06 AM -0400 10/19/07, Nathan Hawks wrote:

If by creates a web page you just mean it echos output to the browser,
and you want to do something else after that, then:

After you have sent your /html and have no more output for the
browser, just use the include() function to run your extra process.

e.g

/html
?php include('secondary_script.php'); ?



No, includes don't work that way.

Your secondary_script.php will be run before your html is shown.

You have to try it to understand.

Cheers,

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] This, then that.

2007-10-19 Thread tedd

At 3:13 PM -0400 10/18/07, Robert Cummings wrote:

On Thu, 2007-10-18 at 15:04 -0400, tedd wrote:

 Hi gang:

 I would like to run a php script that creates a web page and AFTER it
 is finished creating the page, then it runs another php script -- how
 you do that?


exec()

Cheers,
Rob.



Rob:

I'm sure you're right, but I can't seem to get the hang of it.

Thus far, I'm using something like:

exec(/var/www/vhosts/example.com/httpdocs/mydir part2.php);

where part2.php is what I want to run and the path is what's provided 
by __FILE__.


Where am I going wrong?

Cheers,

tedd
--
---
http://sperling.com/

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



Re: [PHP] This, then that

2007-10-19 Thread tedd

At 3:13 PM -0400 10/18/07, Robert Cummings wrote:

On Thu, 2007-10-18 at 15:04 -0400, tedd wrote:

 Hi gang:

 I would like to run a php script that creates a web page and AFTER it
 is finished creating the page, then it runs another php script -- how
 you do that?


exec()

Cheers,
Rob.



Rob:

I'm sure you're right, but I can't seem to get the hang of it.

Thus far, I'm using something like:

exec(/var/www/vhosts/example.com/httpdocs/mydir part2.php);

where part2.php is what I want to run and the path is what's provided 
by __FILE__.


Where am I going wrong?

Cheers,

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: json_encode/json_decode

2007-10-19 Thread Christoph Boget
Please disregard.  Sometimes I weep at my own stupidity... :p

thnx,
Christoph

On 10/19/07, Christoph Boget [EMAIL PROTECTED] wrote:

 Please take a look at the following code and tell me what I'm doing wrong
 here.  I'm just not understanding why this isn't working:


Re: [PHP] Reference return buggy notice?

2007-10-19 Thread Stut

M. Sokolewicz wrote:

Philip Thompson wrote:

On 10/19/07, Stut [EMAIL PROTECTED] wrote:

Ondra Zizka wrote:

Hello,

please look at the code bellow and tell if it does not conform to rules

of

returning a reference from a function.
In the first method, I return reference to $sRet variable, and PHP is

quiet.

But in the second, PHP says:

Notice: Only variable references should be returned by reference in
C:\web\php_bug_reference_return.php on line 8   // return $ref =
$this-ReturnReference();
(Note that the notice does not concern the first method as the notice
appears even if I remove references from the first method.)

But I am still just returning a reference to a variable, so I guess 
it's

actually correct, isn't it?

Thanks for oppinions.
Ondra Zizka


?php
class A {
 function ReturnReference(){
  $sFoo = Hi.;
  return $sRet = $sFoo;
 }
 function RequireReference(){
  return $ref = $this-ReturnReference();
 }
}

$oA = new A();
$ref = $oA-RequireReference();
?

When you define a function as returning a reference (with the  prefix)
you do not need to get the reference yourself, PHP will do it for you.
The following should work fine...

?php
 class A
 {
 function  ReturnReference()
 {
 $sFoo = Hi.;
 return $sFoo;
 }

 function  RequireReference()
 {
 $retval = $this-ReturnReference();
 return $retval;
 }
 }

 $oA = new A();
 $ref = $oA-RequireReference();
?

-Stut




I know we went over references (C) in first semester programming. 
Excuse me
if this is too trivial, but why would you want to use a reference? I 
thought

in PHP, specifically, that it is unnecessary to use references.

A lil' embarrassed,
~Philip



in PHP4 it was occasionally a good idea to use references when assigning 
objects. As of PHP5 the reasons to use references have been reduced to 
virtually none. As the manual states if you think you need to use 
references, think again, you probably don't.


Say you have a function that builds a fairly large array and then 
returns it. If you just return it as usual PHP will make a copy of that 
array and therefore use twice the amount of memory than it needs to.


References also provide a way to return more than one variable from a 
function, but I doubt many PHP developers come across the need to do that.


Where in the manual does it say that? I've never seen it and I can't 
find it.


-Stut

--
http://stut.net/

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



Re: [PHP] Reference return buggy notice?

2007-10-19 Thread M. Sokolewicz

Philip Thompson wrote:

On 10/19/07, Stut [EMAIL PROTECTED] wrote:

Ondra Zizka wrote:

Hello,

please look at the code bellow and tell if it does not conform to rules

of

returning a reference from a function.
In the first method, I return reference to $sRet variable, and PHP is

quiet.

But in the second, PHP says:

Notice: Only variable references should be returned by reference in
C:\web\php_bug_reference_return.php on line 8   // return $ref =
$this-ReturnReference();
(Note that the notice does not concern the first method as the notice
appears even if I remove references from the first method.)

But I am still just returning a reference to a variable, so I guess it's
actually correct, isn't it?

Thanks for oppinions.
Ondra Zizka


?php
class A {
 function ReturnReference(){
  $sFoo = Hi.;
  return $sRet = $sFoo;
 }
 function RequireReference(){
  return $ref = $this-ReturnReference();
 }
}

$oA = new A();
$ref = $oA-RequireReference();
?

When you define a function as returning a reference (with the  prefix)
you do not need to get the reference yourself, PHP will do it for you.
The following should work fine...

?php
 class A
 {
 function  ReturnReference()
 {
 $sFoo = Hi.;
 return $sFoo;
 }

 function  RequireReference()
 {
 $retval = $this-ReturnReference();
 return $retval;
 }
 }

 $oA = new A();
 $ref = $oA-RequireReference();
?

-Stut




I know we went over references (C) in first semester programming. Excuse me
if this is too trivial, but why would you want to use a reference? I thought
in PHP, specifically, that it is unnecessary to use references.

A lil' embarrassed,
~Philip



in PHP4 it was occasionally a good idea to use references when assigning 
objects. As of PHP5 the reasons to use references have been reduced to 
virtually none. As the manual states if you think you need to use 
references, think again, you probably don't.


- Tul

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



Re: [PHP] Reference return buggy notice?

2007-10-19 Thread Philip Thompson
On 10/19/07, Stut [EMAIL PROTECTED] wrote:

 Ondra Zizka wrote:
  Hello,
 
  please look at the code bellow and tell if it does not conform to rules
 of
  returning a reference from a function.
  In the first method, I return reference to $sRet variable, and PHP is
 quiet.
  But in the second, PHP says:
 
  Notice: Only variable references should be returned by reference in
  C:\web\php_bug_reference_return.php on line 8   // return $ref =
  $this-ReturnReference();
  (Note that the notice does not concern the first method as the notice
  appears even if I remove references from the first method.)
 
  But I am still just returning a reference to a variable, so I guess it's
  actually correct, isn't it?
 
  Thanks for oppinions.
  Ondra Zizka
 
 
  ?php
  class A {
   function ReturnReference(){
$sFoo = Hi.;
return $sRet = $sFoo;
   }
   function RequireReference(){
return $ref = $this-ReturnReference();
   }
  }
 
  $oA = new A();
  $ref = $oA-RequireReference();
  ?

 When you define a function as returning a reference (with the  prefix)
 you do not need to get the reference yourself, PHP will do it for you.
 The following should work fine...

 ?php
  class A
  {
  function  ReturnReference()
  {
  $sFoo = Hi.;
  return $sFoo;
  }

  function  RequireReference()
  {
  $retval = $this-ReturnReference();
  return $retval;
  }
  }

  $oA = new A();
  $ref = $oA-RequireReference();
 ?

 -Stut



I know we went over references (C) in first semester programming. Excuse me
if this is too trivial, but why would you want to use a reference? I thought
in PHP, specifically, that it is unnecessary to use references.

A lil' embarrassed,
~Philip


Fwd: [PHP] Need a hint how to use an anker on the next page

2007-10-19 Thread Philip Thompson
-- Forwarded message --
From: Philip Thompson [EMAIL PROTECTED]
Date: Oct 19, 2007 8:31 AM
Subject: Re: [PHP] Need a hint how to use an anker on the next page
To: Per Jessen [EMAIL PROTECTED]

On 10/19/07, Per Jessen [EMAIL PROTECTED] wrote:

 Ronald Wiplinger wrote:

  I have a long page (form), where the user has to return to the place
  he left last time, or where in that page a question has not been
  answered.


 Hi Ronald

 When you send the user back (maybe using a redirect), you supply the
 anchor on the URL by appending #anchor.


 /Per Jessen, Zürich


Adding to Per's comments...

In the HTML:
a  name=rose/a
3. Rose...

In the URL:
http://somewhere.com/somepage.php#rose

HTML specs: http://www.w3.org/TR/html401/
Your specific example:
http://www.w3.org/TR/html401/struct/links.html#h-12.2.1 (notice the anchor
reference in the URL =)

~Philip

(Sorry Per for sending that last one to just you.)


Re: [PHP] Is it possible to restart Windows Apache (service) on a PHP script?

2007-10-19 Thread Philip Thompson
On 10/19/07, Robert Degen [EMAIL PROTECTED] wrote:

 Why don't you try a

   passthru('net apache restart')

 perhabs another parameter order, but I think It won't work.
 Stopping it might work, but restarting...



 On Fr, Okt 19, 2007 at 04:32:45 +0800, Louie Miranda wrote:
  Is it possible to restart Windows Apache (service) on a PHP script?
 
  i have installed PHP/Apache on a Windows machine. Added the ext
 windows32
  service.
  But could not find any how to or information online.
 
  Please help!
 
  --
  Louie Miranda ([EMAIL PROTECTED])


This reminds me of the time I was remoting into a machine (using Altiris, I
think) to do some work on it. I then needed to restart it... so I did. Well,
class, what happens when you turn off Mr. Computer?

Not saying that this is the same thing...  b/c if you push a restart
command, then it *should* come back up. =/ Sorry, I don't know the exact
command, but consider using exec().

Good Luck,
~Philip

PS... Yay, it's Friday!


Re: [PHP] html tools for Web page

2007-10-19 Thread Łukasz Wojciechowski
On 10/19/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

  Hello,

  Does it support multi-language and linux system ?


Yes it is multi-language (language-pack support)
http://wiki.moxiecode.com/index.php/TinyMCE:LanguagePack

And about compatibility look here:
http://wiki.moxiecode.com/index.php/TinyMCE:Compatiblity

-- 
Łukasz Wojciechowski


RE: [PHP] Catching/handing out of memory errors...

2007-10-19 Thread John Parker

In essence, I'm asking if it's technically possible to catch an out of
memory error in PHP. 

As such, it's not really a code specific issue. I'm just asked whether
or not it's possible. (I'm pretty sure it isn't, I'm just double
checking.)

JP. 

-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED] 
Sent: 19 October 2007 13:46
To: John Parker; php-general@lists.php.net
Subject: RE: [PHP] Catching/handing out of memory errors...

[snip]
I've tried using a error handler and try/catch block, but it doesn't
seem to be possible.
 
Is this the case, or am I missing something obvious?
[/snip]

Without seeing your code or knowing more specifics about what you are
trying to do it will be hard to answer this question.

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



RE: [PHP] Catching/handing out of memory errors...

2007-10-19 Thread Jay Blanchard
[snip]
I've tried using a error handler and try/catch block, but it doesn't
seem to be possible.
 
Is this the case, or am I missing something obvious?
[/snip]

Without seeing your code or knowing more specifics about what you are
trying to do it will be hard to answer this question.

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



Re: [PHP] From TXT to a mySQL db

2007-10-19 Thread Jason Pruim


On Oct 18, 2007, at 3:15 PM, Marcelo Wolfgang wrote:

This looks good, but since the db server is in a hosting company it  
will be possible to read from a .txt ?


also I have never seen the LOAD DATA command, so I'm testing here  
and having problems ... can anyone spot what's wrong on this query ?


$SQL = LOAD DATA INFILE 'test.txt' INTO TABLE test FIELDS  
TERMINATED BY '^'  LINES STARTING BY '20';

$Query = mysql_query($SQL);

TIA
Marcelo Wolfgang


I'm not sure about the issue  with the query... I've only used it a  
few times, although I will be using it today with a csv file so I'll  
let you know if I find anything :)


As far as if the hosting company will let you put the file and read  
it from their account I'm not sure, that would be a decision that  
they made, actually I'm not positive that there is anyway they can  
stop it...


But if they don't want to let you do it that way.. Would they allow  
you to place a mysql database on their server that they didn't  
create? You said you were testing locally, so why not simply do the  
load file, and then transfer a complete table up to the hosting company?




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Rename does not work

2007-10-19 Thread Richard Heyes

Sascha Braun | CEO @ BRAUN Networks wrote:

I am using the rename function on my local development
system fine. But as soon as I upload the script, the
rename function does not work anymore.

Is there a specific compiler flag needed, to make rename
work on both plattforms?


You're using different platforms for developing and your live version? 
Mistake number one. As for the rename issue, first guess is permissions. 
As in, you don't have them.


--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



Re: [PHP] Re: Strange behaviour of static declared content.

2007-10-19 Thread Stut

Colin Guthrie wrote:

Stut wrote:

Colin Guthrie wrote:

Stut wrote:

Stut wrote:

In that case you need a new foo. That's the only way you're going to
reset the internal static if the API doesn't give you a way to do it.

$f=new foo();
$f-bar();
$f-bar();
$g=new foo();
$g-bar();

Actually, scratch that, won't work. Not even unsetting $f before
creating the new object works. This kinda sucks since it means PHP does
not support static function-scoped vars.

Yeah I tried that same thing too and then wondered if I had
misinterpreted how function-scoped statics worked.

I've often used a method like:

function Init()
{
 static $bln_inited = false;
 if (!$bln_inited)
 {
  // Do stuff
  $bln_inited = true;
 }
}


I had always assumed that the static definition here was
function-scoped... I guess I should have tested more but still it caught
me off guard this morning when I played with it.

Correct me if I'm wrong but does C++ not do it as both of us initially
thought? e.g. static is function scoped rather than globally scoped when
used within a class method?

Yes it does, which is why I assumed PHP would do it like that too. I
knew I should have tried it before sending the reply.

I've tried various ways of accessing that variable via a derived class
but it doesn't seem to be possible. Again I'm just assuming, but my
theory is that the line...

static $foobar = false;

...actually is static to the function and therefore cannot be accessed
from outside it in any way, shape or form.

So using function statics as you have above will work fine. And they
also work fine when used in a method of a class. This behaviour is
correct because if a function-scoped static is to work correctly there
should be absolutely no way to get at it from outside the function.


I completely agree that there should be no way to access it outside the
function/method it is defined within. The problem is that in PHP the
static keyword seems to be globally unique but function/class scoped.
e.g. that if it is used in a class method, regardless of how many
instances of that method you create with new there is only ever one
instance of the variable.

So the case where it wont work fine is when you have the above function
as a method of a class which can have multiple instances, all of which
need to be Init()'ed independently.

In such cases, I guess you'd have to use a private member variable
instead which just isn't quite a neat and tidy.

If you only ever have one instance of the class then all is well but
still could have unexpected side effects if you later extend the system
to have more than one instance. I guess if you use a singltron method
with a private constructor then it's safe enough but then you can just
do your initialisation in the singletron method in that case so there's
little point!

Hey ho.

/me scuttles of to grep code for static :s


Nope, not globally unique: http://dev.stut.net/php/funcstatic.php

So what you have will be fine.

-Stut

--
http://stut.net/

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



[PHP] Any body know Ink Serialized Format (ISF) ?

2007-10-19 Thread LKSunny
MSN Messenger uses the Ink Serialized Format for sending Ink.

reference: http://siebe.bot2k3.net/docs/?url=ink.html

i through php to use msn function, most okay,
main problem, how can i create handwriting image Ink in php ?

Thank You Very Much ! 

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



Re: [PHP] Reference return buggy notice?

2007-10-19 Thread Stut

Ondra Zizka wrote:

Hello,

please look at the code bellow and tell if it does not conform to rules of 
returning a reference from a function.

In the first method, I return reference to $sRet variable, and PHP is quiet.
But in the second, PHP says:

Notice: Only variable references should be returned by reference in 
C:\web\php_bug_reference_return.php on line 8   // return $ref = 
$this-ReturnReference();
(Note that the notice does not concern the first method as the notice 
appears even if I remove references from the first method.)


But I am still just returning a reference to a variable, so I guess it's 
actually correct, isn't it?


Thanks for oppinions.
Ondra Zizka


?php
class A {
 function ReturnReference(){
  $sFoo = Hi.;
  return $sRet = $sFoo;
 }
 function RequireReference(){
  return $ref = $this-ReturnReference();
 }
}

$oA = new A();
$ref = $oA-RequireReference();
?


When you define a function as returning a reference (with the  prefix) 
you do not need to get the reference yourself, PHP will do it for you. 
The following should work fine...


?php
class A
{
function  ReturnReference()
{
$sFoo = Hi.;
return $sFoo;
}

function  RequireReference()
{
$retval = $this-ReturnReference();
return $retval;
}
}

$oA = new A();
$ref = $oA-RequireReference();
?

-Stut

--
http://stut.net/

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



[PHP] Rename does not work

2007-10-19 Thread Sascha Braun | CEO @ BRAUN Networks
Hi everyone,

I am using the rename function on my local development
system fine. But as soon as I upload the script, the
rename function does not work anymore.

Is there a specific compiler flag needed, to make rename
work on both plattforms?

Thank you very much.

Sascha


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



Re: [PHP] Is it possible to restart Windows Apache (service) on a PHP script?

2007-10-19 Thread Robert Degen
Why don't you try a 

  passthru('net apache restart')
  
perhabs another parameter order, but I think It won't work.
Stopping it might work, but restarting...



On Fr, Okt 19, 2007 at 04:32:45 +0800, Louie Miranda wrote:
 Is it possible to restart Windows Apache (service) on a PHP script?
 
 i have installed PHP/Apache on a Windows machine. Added the ext windows32
 service.
 But could not find any how to or information online.
 
 Please help!
 
 -- 
 Louie Miranda ([EMAIL PROTECTED])
 http://www.axishift.com
 
 Security Is A Series Of Well-Defined Steps
 chmod -R 0 / ; and smile :)

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



[PHP] Is it possible to restart Windows Apache (service) on a PHP script?

2007-10-19 Thread Louie Miranda
Is it possible to restart Windows Apache (service) on a PHP script?

i have installed PHP/Apache on a Windows machine. Added the ext windows32
service.
But could not find any how to or information online.

Please help!

-- 
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com

Security Is A Series Of Well-Defined Steps
chmod -R 0 / ; and smile :)


[PHP] Re: PHP/MySQL CMS for Articles/Studies/Research Papers?

2007-10-19 Thread Colin Guthrie
Jason Paschal wrote:
 just wanted to know if any of you have seen anything geared for this sort of
 content, something professional-looking that doesn't come with a huge
 learning curve.  it wouldn't have to be TOO fancy, i could probably make
 something, but didn't want to re-invent the round-thing-that-rolls.

I've not played with it but I saw mention of moodle.org on this list the
other day and went to it to see what it was. Turns out to be a CMS
targeted at learning programs. It's not exactly what you want but it may
be the closest match

Other people on this list may have other suggestions.

Col

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



Re: [PHP] IF statement

2007-10-19 Thread Simon
I'd suggest a tutorial or something on BOOLEAN or LOGICAL OPERATORS.

For example:
true and false = false
true or false = true
not true and not false = false
not true or not false = true
and so on...

The IF statement will simply take the result of a logical operation,
and the result will either be true or false.  The magic with IF is in
the logic that you write.

Simon

On 10/18/07, ron.php [EMAIL PROTECTED] wrote:
 I just tried to send this to the list.  I am not trying make it post again, I
 don't think I had the e-mail address correct the first time.

 I am trying to stop $component_reference from doing the echo below when the
 value is 5 or 19.  I don't have the syntax right though.  What did I miss?

 Ron

 if ( ($component_reference != 5) OR ($component_reference != 19) ) {
 echo lia href=\index.php?request= . $request . \ .
 $component_name . /a;
 }

 --
 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] problem calling functions

2007-10-19 Thread afan pasalic
Stut wrote:
 afan pasalic wrote:
 why then the code doesn't work?
 the error I'm getting is: Fatal error: Call to undefined function
 solution1() in ... even the function itself is just above the line that
 calls function?

 I can only guess that you're not showing us the code you're actually
 running. See the example I put in another reply - that works and is
 based on the code you sent.

 -Stut


true. it's not original code than simplified one.
let me try with one more time with your solution.

-afan

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



Re: [PHP] This, then that. [solved?]

2007-10-19 Thread Philip Thompson
On 10/19/07, Philip Thompson [EMAIL PROTECTED] wrote:

 On 10/19/07, tedd [EMAIL PROTECTED] wrote:
 
  Hi gang:
 
  I think I found a solution.
 
  Here's the url:
 
  http://www.webbytedd.com/bbb/image-test1/
 
  The point is that the image is only accessible via this script, is
  this correct?
 
  The technique I used simply runs the first php script, which creates
  the page that has uses ajax to trigger another php script to run.
 
  It was a question of timing.
 
  Cheers,
 
  tedd



 My original thought was to use AJAX, but wasn't sure if it was the
 direction you wanted to go...

 I went to the site, copied the image url, and was able to visit the image
 directly. I thought you weren't wanting to do this??

 ~Philip



Sorry, having major issues not posting to the *list* today


RE: [PHP] problem calling functions

2007-10-19 Thread Jay Blanchard
[snip]
?php
function solution1($var1){
// some code
}

function solution2($var2){
// some code
}

function solution3($var3){
// some code
}

if ($function == 'solution1' or $function == 'solution2' or $function ==
'solution3')
{
$my_solution = $function($var); # this supposed to call one of
solution functions, right?
}
?
[/snip]

I don't think you can put a function name in a variable and call it like
$function($var). You'd be better of with a case statement in one
function and call the proper solution (quick syntax, may need a little
fixing;

function my_solution($function, $var){
switch $function{
case function1:
...do stuff...
break;
case function1:


etc.
}
}

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



[PHP] upgraded apache won't start

2007-10-19 Thread Pat Jones
Hi;

I upgraded to Apache 2.2.6 and it ran fine when I tested it after 
configuring the httpd.conf file (although instead of getting the PHP 
configuration page I got a page that said simply It works.) After I 
rebooted though, I can't get it to run. The error log refers to a syntax 
error in the following line in the apache conf/httpd.conf file.
LoadModule php5_module c:/php5/php5apache2.dll

It says the specified module can't be found. The module certainly is there 
and it worked with apache 2 before the upgrade. What am I missing here ?

Thanks;

Pat 

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



Re: [PHP] problem calling functions

2007-10-19 Thread Zoltán Németh
2007. 10. 19, péntek keltezéssel 11.15-kor afan pasalic ezt írta:
 hi
 I have a problem with calling functions:
 
 ?php
 function solution1($var1){
 // some code
 }
 
 function solution2($var2){
 // some code
 }
 
 function solution3($var3){
 // some code
 }
 
 if ($function == 'solution1' or $function == 'solution2' or $function ==
 'solution3')
 {
 $my_solution = $function($var); # this supposed to call one of
 solution functions, right?
 }
 ?

what's wrong with this?

greets
Zoltán Németh

 
 suggestions?
 
 thanks.
 
 -afan
 

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



Re: [PHP] This, then that.

2007-10-19 Thread Zoltán Németh
2007. 10. 19, péntek keltezéssel 12.07-kor tedd ezt írta:
 At 8:19 PM -0400 10/18/07, TG wrote:
 Describe the process a little more.
 
 Ok, here's what I want to do.
 
 I want to prohibit an image from being shown to anyone who is not 
 permitted (i.e., logged in).
 
 The way I want to do this is to:
 
 1. Set the image permissions to 0640. That way no one can get to the image.
 
 2. Then my application (part 1) will show the images to whomever is 
 approved by changing the permission and then loading the image. Of 
 course, the image can be taken at that point, but only by the person 
 who was approved.
 
 3. After the application (part 1) runs, I want another application 
 (part 2) to come along and change the permissions of the image back 
 to 0640.
 
 Now, I have no problems with anything other than getting part 2 to 
 run after part 1 runs. So, that's the problem.
 
 As to any server questions, I would like the answer to be generic or 
 a way to determine which server type it is and make adjustments 
 accordingly.
 

why not put the image outside of the webroot? I don't think anyone can
access it there, if not using your imageserving php which authenticates
the user.

greets
Zoltán Németh

 Cheers
 
 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] problem calling functions

2007-10-19 Thread afan pasalic
hi
I have a problem with calling functions:

?php
function solution1($var1){
// some code
}

function solution2($var2){
// some code
}

function solution3($var3){
// some code
}

if ($function == 'solution1' or $function == 'solution2' or $function ==
'solution3')
{
$my_solution = $function($var); # this supposed to call one of
solution functions, right?
}
?

suggestions?

thanks.

-afan

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



Re: [PHP] This, then that.

2007-10-19 Thread tedd

At 8:19 PM -0400 10/18/07, TG wrote:

Describe the process a little more.


Ok, here's what I want to do.

I want to prohibit an image from being shown to anyone who is not 
permitted (i.e., logged in).


The way I want to do this is to:

1. Set the image permissions to 0640. That way no one can get to the image.

2. Then my application (part 1) will show the images to whomever is 
approved by changing the permission and then loading the image. Of 
course, the image can be taken at that point, but only by the person 
who was approved.


3. After the application (part 1) runs, I want another application 
(part 2) to come along and change the permissions of the image back 
to 0640.


Now, I have no problems with anything other than getting part 2 to 
run after part 1 runs. So, that's the problem.


As to any server questions, I would like the answer to be generic or 
a way to determine which server type it is and make adjustments 
accordingly.


Cheers

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] json_encode/json_decode

2007-10-19 Thread Christoph Boget
Please take a look at the following code and tell me what I'm doing wrong
here.  I'm just not understanding why this isn't working:

?php

  $myArr = array( 'Key 1' = array( 'Key 1 1' = array( array( 'Key 1 1 1'
= 'Value' ),
array( 'Key 1 1 2'
= 'Value' )),
'Key 1 2' = array( array( 'Key 1 2 1'
= 'Value' ),
array( 'Key 1 2 2'
= 'Value' ))),
  'Key 2' = array( 'Key 2 1' = array( array( 'Key 2 1 1'
= 'Value' ),
array( 'Key 2 1 2'
= 'Value' )),
'Key 2 2' = array( array( 'Key 2 2 1'
= 'Value' ),
array( 'Key 2 2 2'
= 'Value' ;
  echo '$myArr: pre' . print_r( $myArr, TRUE ) . '/prebr';
  $myArrEncoded = json_encode( $myArr );
  echo var_dump( $myArrEncoded ) . 'brbr';
  echo '$myArr encoded: ' . $myArrEncoded . 'brbr';
  try {
echo '$myArr decoded: pre' . json_decode( $myArrEncoded ) .
'/prebrbr';  // this is line 16
  } catch( Exception $e ) {
echo 'Error: ' . var_dump( $e );
  }

?


When I run the above, I get the following.  Please note that line 16 is in a
TRY block yet it still gives the error seen below:

$myArr:

Array
(
[Key 1] = Array
(
[Key 1 1] = Array
(
[0] = Array
(
[Key 1 1 1] = Value
)

[1] = Array
(
[Key 1 1 2] = Value
)

)

[Key 1 2] = Array
(
[0] = Array
(
[Key 1 2 1] = Value
)

[1] = Array
(
[Key 1 2 2] = Value
)

)

)

[Key 2] = Array
(
[Key 2 1] = Array
(
[0] = Array
(
[Key 2 1 1] = Value
)

[1] = Array
(
[Key 2 1 2] = Value
)

)

[Key 2 2] = Array
(
[0] = Array
(
[Key 2 2 1] = Value
)

[1] = Array
(
[Key 2 2 2] = Value
)

)

)

)


string(245) {Key 1:{Key 1 1:[{Key 1 1 1:Value},{Key 1 1
2:Value}],Key 1 2:[{Key 1 2 1:Value},{Key 1 2 2:Value}]},Key
2:{Key 2 1:[{Key 2 1 1:Value},{Key 2 1 2:Value}],Key 2 2:[{Key
2 2 1:Value},{Key 2 2 2:Value}]}}

$myArr encoded: {Key 1:{Key 1 1:[{Key 1 1 1:Value},{Key 1 1
2:Value}],Key 1 2:[{Key 1 2 1:Value},{Key 1 2 2:Value}]},Key
2:{Key 2 1:[{Key 2 1 1:Value},{Key 2 1 2:Value}],Key 2 2:[{Key
2 2 1:Value},{Key 2 2 2:Value}]}}


*Catchable fatal error*: Object of class stdClass could not be converted to
string in */path/to/my/file.php* on line *16


*Now, if I change it so that I pass the second parameter as TRUE for
json_decode (ie, change my code as follows:

echo '$myArr decoded: pre' . json_decode( $myArrEncoded, TRUE ) .
'/prebrbr';  // this is line 16

), then here is what I get:

$myArr:

Array
(
[Key 1] = Array
(
[Key 1 1] = Array
(
[0] = Array
(
[Key 1 1 1] = Value
)

[1] = Array
(
[Key 1 1 2] = Value
)

)

[Key 1 2] = Array
(
[0] = Array
(
[Key 1 2 1] = Value
)

[1] = Array
(
[Key 1 2 2] = Value
)

)

)

[Key 2] = Array
(
[Key 2 1] = Array
(
[0] = Array
(
[Key 2 1 1] = Value
)

[1] = Array
(
[Key 2 1 2] = Value
)

)

[Key 2 2] = Array
(
[0] = Array
(
[Key 2 2 1] = Value
)

[1] = Array
(
[Key 2 2 2] = Value
)

 

[PHP] Catching/handing out of memory errors...

2007-10-19 Thread John Parker
Hi, all.
 
I've tried using a error handler and try/catch block, but it doesn't
seem to be possible.
 
Is this the case, or am I missing something obvious?
 
Regards,
John Parker.


Re: [PHP] Re: Strange behaviour of static declared content.

2007-10-19 Thread Stut

Colin Guthrie wrote:

PS I know the above examples are contrived and that constructors would
be more appropriate for the above - but using constructors is not always
possible due to how you deal with failed initialisations where
exceptions are not desirable.


I see what you mean. You thought that static variables in a member 
function of a class would be different for each instance of that class. 
Indeed that's not the case, statics are attached to the class not the 
object.


As for the problem of dealing with failed initialisations there are two 
ways to deal with that. The first is to us a separate initialisation 
method - this allows it to return a value. Your constructor would simply 
fill the object with sensible defaults.


The second is to have a member variable that stores whether the object 
has been successfully initialised. Either of these would be far better 
than using a static variable since initialisation status is a property 
of the object not the class.


Anyways, glad we both understand some things a bit better now. On to the 
next problem!


-Stut

--
http://stut.net/

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



Re: [PHP] Strange behaviour of static declared content.

2007-10-19 Thread Stut

Nathan Nobbe wrote:

On 10/18/07, Nathan Nobbe [EMAIL PROTECTED] wrote:

On 10/18/07, Joshua Bacher [EMAIL PROTECTED] wrote:

thats the solution for the wrong problem. it's not up to me to change
the API. the API is designed like i noted and i need a way to get around
this behaviour.

thanks for your idea any further suggestions?

josh


unfortunately i dont know of a way to modify the value of that variable
from anywhere outside
the function in which it is defined.

-nathan




i bet even Robert cant change that one ;)


Runkit could probably do it, but I wouldn't recommend that to anyone.

-Stut

--
http://stut.net/

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



Re: [PHP] Need a hint how to use an anker on the next page

2007-10-19 Thread Per Jessen
Ronald Wiplinger wrote:

 I have a long page (form), where the user has to return to the place
 he left last time, or where in that page a question has not been
 answered.


Hi Ronald

When you send the user back (maybe using a redirect), you supply the
anchor on the URL by appending #anchor.  


/Per Jessen, Zürich

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



Re: [PHP] This, then that.

2007-10-19 Thread Simon
I think I would flush the output at the end before starting the second
script with functions (off my memory) like flush() and ob_flush()

This will ensure that the browser at the other end has received the
whole document and can in fact display it all.

I haven't looked into that myself but, best would be to close the
connection to the client as well, if that's possible, without
terminating the script.  This will prevent that browsers would display
Loading... after the page is shown until your second script
terminates.

Simon

On 10/19/07, Nathan Hawks [EMAIL PROTECTED] wrote:
 If by creates a web page you just mean it echos output to the browser,
 and you want to do something else after that, then:

 After you have sent your /html and have no more output for the
 browser, just use the include() function to run your extra process.

 e.g

 /html
 ?php include('secondary_script.php'); ?



 On Thu, 2007-10-18 at 20:19 -0400, TG wrote:
  Describe the process a little more.
 
  PHP script outputs HTML to the browser?
 
  PHP script outputs HTML to a file?
 
  Is the file created then displayed?
 
  Is the PHP script run via command line?  If so, then exec() and some of the
  other ideas would probably be the way to go.
 
  If it creates and displays a page online, you can use a headler(Location:
  someurl) to redirect.  This is subject to user interference of course.
 
  Do you need it to spawn the other PHP script and exit or is it ok if it's a
  child process of the original php script (or whoever that works.. sorry,
  not 100% familiar with the internal stuff).
 
  -TG
 
  - Original Message -
  From: tedd [EMAIL PROTECTED]
  To: php-general@lists.php.net
  Date: Thu, 18 Oct 2007 15:04:36 -0400
  Subject: [PHP] This, then that.
 
   Hi gang:
  
   I would like to run a php script that creates a web page and AFTER it
   is finished creating the page, then it runs another php script -- how
   you do that?
  
   Cheers,
  
   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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] This, then that.

2007-10-19 Thread Instruct ICC

 I want to prohibit an image from being shown to anyone who is not 
 permitted (i.e., logged in).
 
 The way I want to do this is to:
 
 1. Set [file] permissions...



What if 2 or more users access the application at the same time?

Set the permissions so only the PHP application can access it.
Have the PHP application decide if this present user running this instance 
should see the image.
If approved, display image.

_
Climb to the top of the charts!  Play Star Shuffle:  the word scramble 
challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct

[PHP] directory modification dates

2007-10-19 Thread Marek
I have a simple directory listing script - you can move up and down
directories and it shows the files/dirs inside. Now I have to figure out
a way to display the latest modification time for each directory.

The problem is that filemtime() works only if the modifications are done
on the first level. For example, if I add files in dir1/dir2/dir3/, then
 the modification time for dir1 doesn't update.

My first instinct was to find the correct time recursively on each load
but there are so many files and so many visitors that it clogs the
server. I have a few other ideas but they seem rather ugly (like hidden
files with stored info in each directory).

Can you suggest any better ways to approach this problem?

Marek

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



[PHP] Influence direction for database tooling support in NetBeans

2007-10-19 Thread David Van Couvering
Yes, I'm from NetBeans, that Java IDE.  But we're actually thinking
very seriously about PHP for the next release of NetBeans.  I know
emacs and vi are pretty darn good tools, but we're looking to see how
NetBeans may be able to provide some value for PHP developers.

My area of focus is on database tooling, and right now I am looking at
what features we could provide for the next release of NetBeans.

I've written up a *very short* survey (max 10 minutes) to get some
clarity on some specific features and focus areas that I'm just not
sure about.  I've gotten good response from Java developers, but I
want to hear from you all.

Here is the un-spammable survey link

FreeOnlineSurveys dot com / rendersurvey.asp?sid=jbk4vr915xv9qr0350286

Your assistance and guidance are much appreciated!

Thanks,

David Van Couvering
Database Architect, NetBeans
Blog: david dot vancouvering at blogspot dot com

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



[PHP] Re: Strange behaviour of static declared content.

2007-10-19 Thread Colin Guthrie
Stut wrote:
 Colin Guthrie wrote:
 Stut wrote:
 Stut wrote:
 In that case you need a new foo. That's the only way you're going to
 reset the internal static if the API doesn't give you a way to do it.

 $f=new foo();
 $f-bar();
 $f-bar();
 $g=new foo();
 $g-bar();
 Actually, scratch that, won't work. Not even unsetting $f before
 creating the new object works. This kinda sucks since it means PHP does
 not support static function-scoped vars.

 Yeah I tried that same thing too and then wondered if I had
 misinterpreted how function-scoped statics worked.

 I've often used a method like:

 function Init()
 {
  static $bln_inited = false;
  if (!$bln_inited)
  {
   // Do stuff
   $bln_inited = true;
  }
 }


 I had always assumed that the static definition here was
 function-scoped... I guess I should have tested more but still it caught
 me off guard this morning when I played with it.

 Correct me if I'm wrong but does C++ not do it as both of us initially
 thought? e.g. static is function scoped rather than globally scoped when
 used within a class method?
 
 Yes it does, which is why I assumed PHP would do it like that too. I
 knew I should have tried it before sending the reply.
 
 I've tried various ways of accessing that variable via a derived class
 but it doesn't seem to be possible. Again I'm just assuming, but my
 theory is that the line...
 
 static $foobar = false;
 
 ...actually is static to the function and therefore cannot be accessed
 from outside it in any way, shape or form.
 
 So using function statics as you have above will work fine. And they
 also work fine when used in a method of a class. This behaviour is
 correct because if a function-scoped static is to work correctly there
 should be absolutely no way to get at it from outside the function.

I completely agree that there should be no way to access it outside the
function/method it is defined within. The problem is that in PHP the
static keyword seems to be globally unique but function/class scoped.
e.g. that if it is used in a class method, regardless of how many
instances of that method you create with new there is only ever one
instance of the variable.

So the case where it wont work fine is when you have the above function
as a method of a class which can have multiple instances, all of which
need to be Init()'ed independently.

In such cases, I guess you'd have to use a private member variable
instead which just isn't quite a neat and tidy.

If you only ever have one instance of the class then all is well but
still could have unexpected side effects if you later extend the system
to have more than one instance. I guess if you use a singltron method
with a private constructor then it's safe enough but then you can just
do your initialisation in the singletron method in that case so there's
little point!

Hey ho.

/me scuttles of to grep code for static :s

Col

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



Re: [PHP] Re: Strange behaviour of static declared content.

2007-10-19 Thread Stut

Colin Guthrie wrote:

Stut wrote:

Stut wrote:

In that case you need a new foo. That's the only way you're going to
reset the internal static if the API doesn't give you a way to do it.

$f=new foo();
$f-bar();
$f-bar();
$g=new foo();
$g-bar();

Actually, scratch that, won't work. Not even unsetting $f before
creating the new object works. This kinda sucks since it means PHP does
not support static function-scoped vars.


Yeah I tried that same thing too and then wondered if I had
misinterpreted how function-scoped statics worked.

I've often used a method like:

function Init()
{
 static $bln_inited = false;
 if (!$bln_inited)
 {
  // Do stuff
  $bln_inited = true;
 }
}


I had always assumed that the static definition here was
function-scoped... I guess I should have tested more but still it caught
me off guard this morning when I played with it.

Correct me if I'm wrong but does C++ not do it as both of us initially
thought? e.g. static is function scoped rather than globally scoped when
used within a class method?


Yes it does, which is why I assumed PHP would do it like that too. I 
knew I should have tried it before sending the reply.


I've tried various ways of accessing that variable via a derived class 
but it doesn't seem to be possible. Again I'm just assuming, but my 
theory is that the line...


static $foobar = false;

...actually is static to the function and therefore cannot be accessed 
from outside it in any way, shape or form.


So using function statics as you have above will work fine. And they 
also work fine when used in a method of a class. This behaviour is 
correct because if a function-scoped static is to work correctly there 
should be absolutely no way to get at it from outside the function.


-Stut

--
http://stut.net/

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



[PHP] Re: Rename does not work

2007-10-19 Thread Christian Hänsel
Sascha Braun | CEO @ BRAUN Networks [EMAIL PROTECTED] schrieb 
im Newsbeitrag news:[EMAIL PROTECTED]

Hi everyone,

I am using the rename function on my local development
system fine. But as soon as I upload the script, the
rename function does not work anymore.

Is there a specific compiler flag needed, to make rename
work on both plattforms?

Thank you very much.

Sascha



Hi Sascha,

What is the error? Did you check for folder permissions (chmod)?

Cheerio!

Chris 


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



[PHP] picture upload within a form

2007-10-19 Thread Ronald Wiplinger

I have a form, where I upload a picture and a corresponding text.

Is it possible to have a form (upload picture) within a form (text)?
As I have it now, the submit button just does nothing.

bye

Ronald  


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



[PHP] Re: Strange behaviour of static declared content.

2007-10-19 Thread Colin Guthrie
Stut wrote:
 Colin Guthrie wrote:
 Stut wrote:
 Colin Guthrie wrote:
 Stut wrote:
 Stut wrote:
 In that case you need a new foo. That's the only way you're going to
 reset the internal static if the API doesn't give you a way to do it.

 $f=new foo();
 $f-bar();
 $f-bar();
 $g=new foo();
 $g-bar();
 Actually, scratch that, won't work. Not even unsetting $f before
 creating the new object works. This kinda sucks since it means PHP
 does
 not support static function-scoped vars.
 Yeah I tried that same thing too and then wondered if I had
 misinterpreted how function-scoped statics worked.

 I've often used a method like:

 function Init()
 {
  static $bln_inited = false;
  if (!$bln_inited)
  {
   // Do stuff
   $bln_inited = true;
  }
 }


 I had always assumed that the static definition here was
 function-scoped... I guess I should have tested more but still it
 caught
 me off guard this morning when I played with it.

 Correct me if I'm wrong but does C++ not do it as both of us initially
 thought? e.g. static is function scoped rather than globally scoped
 when
 used within a class method?
 Yes it does, which is why I assumed PHP would do it like that too. I
 knew I should have tried it before sending the reply.

 I've tried various ways of accessing that variable via a derived class
 but it doesn't seem to be possible. Again I'm just assuming, but my
 theory is that the line...

 static $foobar = false;

 ...actually is static to the function and therefore cannot be accessed
 from outside it in any way, shape or form.

 So using function statics as you have above will work fine. And they
 also work fine when used in a method of a class. This behaviour is
 correct because if a function-scoped static is to work correctly there
 should be absolutely no way to get at it from outside the function.

 I completely agree that there should be no way to access it outside the
 function/method it is defined within. The problem is that in PHP the
 static keyword seems to be globally unique but function/class scoped.
 e.g. that if it is used in a class method, regardless of how many
 instances of that method you create with new there is only ever one
 instance of the variable.

 So the case where it wont work fine is when you have the above function
 as a method of a class which can have multiple instances, all of which
 need to be Init()'ed independently.

 In such cases, I guess you'd have to use a private member variable
 instead which just isn't quite a neat and tidy.

 If you only ever have one instance of the class then all is well but
 still could have unexpected side effects if you later extend the system
 to have more than one instance. I guess if you use a singltron method
 with a private constructor then it's safe enough but then you can just
 do your initialisation in the singletron method in that case so there's
 little point!

 Hey ho.

 /me scuttles of to grep code for static :s
 
 Nope, not globally unique: http://dev.stut.net/php/funcstatic.php
 
 So what you have will be fine.

No it wont work as I *intended* but that is purely due to my own
misinterpretation of how statics in a method works.

I've satisfied my own understanding now by testing it in C++ and it
behaves the same as in PHP here, so I'm completely in the know (now!).

I did however think it worked differently! Like I say it's just my own
misunderstanding.


Here is what I meant for completeness:

Try the following code and note especially the last two lines of the
output (change the \n to br / if you want if for web output.. I tested
on cmdline).

?php
$GLOBALS['eol'] = \n;
class c
{
public function a($nm)
{
static $var = 0;
print $nm.'a: '.$var.$GLOBALS['eol'];
$var++;
}

public function b($nm)
{
static $var = 0;
print $nm.'b: '.$var.$GLOBALS['eol'];
$var++;
}
}


$c = new c();
for ($i = 0; $i  10; $i++)
{
$c-a('C');
if ($i % 2)
  $c-b('C');
}

$d = new c();
$d-a('D');
$d-b('D');

?

Ca: 0
Ca: 1
Cb: 0
Ca: 2
Ca: 3
Cb: 1
Ca: 4
Ca: 5
Cb: 2
Ca: 6
Ca: 7
Cb: 3
Ca: 8
Ca: 9
Cb: 4
Da: 10
Db: 5


i.e. the $d object just carries on where $c left off. This is not what I
had in my head how things worked.

I had originally thought that the static keyword within a class method
was only static in the context of that *instance* of the class. This is
clearly mince now I look into it and think about it a bit.


e.g. consider the following class.


?php
$GLOBALS['eol'] = \n;
class foo
{
private $mVar = Uninitialised;

public function Init()
{
static $bln_initialised = false;
if (!$bln_initialised)
{
  $this-mVar = 'Initialised';
  $bln_initialised = true;
}
}

public function Display($nm)
{
echo $nm.': 

Re: [PHP] problem calling functions

2007-10-19 Thread afan pasalic

Jay Blanchard wrote:
 [snip]
 ?php
 function solution1($var1){
 // some code
 }

 function solution2($var2){
 // some code
 }

 function solution3($var3){
 // some code
 }

 if ($function == 'solution1' or $function == 'solution2' or $function ==
 'solution3')
 {
 $my_solution = $function($var); # this supposed to call one of
 solution functions, right?
 }
 ?
 [/snip]

 I don't think you can put a function name in a variable and call it like
 $function($var). You'd be better of with a case statement in one
 function and call the proper solution (quick syntax, may need a little
 fixing;

 function my_solution($function, $var){
   switch $function{
   case function1:
   ...do stuff...
   break;
   case function1:


   etc.
   }
 }
   

that's exactly what I'm doing now. though, I was thinking if it's possible.
:-(

thanks jay

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



Re: [PHP] problem calling functions

2007-10-19 Thread Stut

afan pasalic wrote:

why then the code doesn't work?
the error I'm getting is: Fatal error: Call to undefined function
solution1() in ... even the function itself is just above the line that
calls function?


I can only guess that you're not showing us the code you're actually 
running. See the example I put in another reply - that works and is 
based on the code you sent.


-Stut

--
http://stut.net/


Stut wrote:

Jay Blanchard wrote:

I don't think you can put a function name in a variable and call it like
$function($var).

Yes you can - it's basically the same as variable variables.

-Stut



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



Re: [PHP] problem calling functions

2007-10-19 Thread afan pasalic
actually, what example you are talking about? I got jay's example only?


Stut wrote:
 afan pasalic wrote:
 why then the code doesn't work?
 the error I'm getting is: Fatal error: Call to undefined function
 solution1() in ... even the function itself is just above the line that
 calls function?

 I can only guess that you're not showing us the code you're actually
 running. See the example I put in another reply - that works and is
 based on the code you sent.

 -Stut


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