Re: [PHP] First PHP

2002-11-29 Thread CC Zona
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Khalid El-Kary) wrote:

 http://www.php.net/manual/en/history.php#history.php

First public announcement of PHP by Rasmus:
http://groups.google.com/groups?selm=3r7pgp%24aa1%40ionews.io.org

-- 
CC

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




Re: [PHP] register_global variables on Mac OS X

2002-10-08 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jule Slootbeek) wrote:

 Yeah that's the path to where php.ini should be (/usr/local/lib, in my 
 case, but the Jaguar version of PHP doesn't use a php.ini file, so 
 there's nothing there.

Jaguar uses php.ini if it's in the expected location.  That you don't have 
one yet is a matter easily resolved.

You can use an ASCII text editor (BBEdit Lite, for instance 
http://www.bbedit.com/products/bbedit_lite/lite-download.html) to create 
a new document and fill it with your favorite options.

Or do as others have recommended and download a prewritten one from php.net 
and place it in the designated location (renamed to php.ini if necessary).

Or see the configuration page http://php.net/configuration for 
descriptions of other alternatives (ini_set(), .htaccess).

-- 
CC

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




[PHP] Re: flaking out on foreach

2002-08-27 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Robert McPeak) wrote:

 Why is this code:
 
 ?php
   
   $bob=array(1,2,3,5,6);
   
   foreach($bob as $foo);
   {
   echo $fooBR;
   }
   ?
 
 Rendering only 6.  That's it.  Just 6.  What am I missing here?

What do you see in the HTML source view?

-- 
CC

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




[PHP] Re: Include php code as variable

2002-08-03 Thread CC Zona

In article 00d501c23ada$87050590$3404a8c0@alawi,
 [EMAIL PROTECTED] (Alawi) wrote:

 How can I Include my php code code as variable and excute it ? 

include() can return a value, assignable to a variable.  Some other ways to 
get the content of a file (I assume that's why you're saying include) 
into a variable: file(), fread().

eval() can execute the value of a variable as PHP code.

http://php.net/include
http://php.net/file
http://php.net/fread
http://php.net/eval

-- 
CC

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




Re: [PHP] include hassle

2002-08-02 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Lallous) wrote:

 how can i programmatically set the include path?

http://php.net/ini-set

-- 
CC

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




Re: [PHP] extending class then calling its original function

2002-08-01 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Wong) wrote:

 On Wednesday 31 July 2002 18:36, lallous wrote:
  Hello when I extended a class and overwrite a function, can i after
  overwriting that function call it so it does what it used to do?
 
  for example in Delphi I say:
 
  procedure TMyExtendedClass.Proc1;
  begin
  // do new stuff here
  inherited; // calls the TMyClass.Proc1;
  end;
 
 Yes.

$answer.=http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php;;

-- 
CC

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




Re: [PHP] fullname

2002-07-30 Thread CC Zona

In article 001301c23799$2deb3b30$100a0a0a@skink,
 [EMAIL PROTECTED] (David Freeman) wrote:

 is there some other easyer way to do in one line than this?:
   
   $fullname = $session[f_name];
   $fullname .=  ;
   $fullname .= $session[l_name];  
 
 $fullname = $session[f_name] .   . $session[l_name];

...or *if* f_name and l_name are guaranteed to be the only elements of 
array $session *and* they're in the needed order, you could do:

$fullname=implode( , $session);

But that requires the proper foreknowledge.  Simple concatenation, like 
above, is the safer bet.

-- 
CC

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




[PHP] Re: mod_rewrite problem

2002-07-18 Thread CC Zona

In article 003d01c22e58$dcb45240$6601a8c0@yourwrjlo8t8dt,
 [EMAIL PROTECTED] (Adrian Murphy) wrote:

 the following code redirects www.usersite.mysite.biz  to 
 www.mysite.biz/users/sites/usersite
 
 the problem is when the 'www' is left out it doesn't work.
snip
 RewriteEngine on
 RewriteCond   %{HTTP HOST} ^www\.[^.]+\.mysite\.biz$
 RewriteRule   ^(.+)%{HTTP HOST}$1  [C]
 RewriteRule   ^www\.([^.]+)\.mysite\.biz(.*) 
 http://www.mysite.biz/users/sites/$1
 RewriteCond   %{HTTP HOST} ^www\.[^.]+\.mysite\.ie$
 RewriteRule   ^(.+)%{HTTP HOST}$1  [C]
 RewriteRule   ^www\.([^.]+)\.mysite\.ie(.*) 
 http://www.mysite.biz/users/sites/$1

Change each of those instances of ^www\. to ^(www\.)?

-- 
CC

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




[PHP] Re: Regular expression for correcting proper nouns

2002-07-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Henry) wrote:

 I'm looking for a simple was to correct a list of proper nouns given all in
 lower case!
 
 For example
 
 given $string=london paris rome;
 
 I would like London Paris Rome.
 
 However there is one cavet; if the word already has a captital anywhere in
 it, it should be left alone!!!
 
 Is there a soultion using regular expressions?

Yes.  The topics you'll want to look at (in the PCRE chapter of the manual) 
are: case-sensitivity, character classes, capturing subpatterns, and the 
documentation for preg_replace_callback().  One of the things you'll need 
to do is define for yourself what constitutes a word for your purposes.  
Does a single letter word get counted as a word (i.e. i)?  Is there any 
non-alphabet character that can validly appear within the thing you call a 
word (i.e. hi-fi, mst3k)?  This is why there's no single ready-made 
solution.

 Also is there one for removing multiple spaces?
 
 i..e given A   B C D E it would give A B C D E.

Yes.  Again, character classes will be your friend, as will preg_replace().  
Just decide which of the whitespace characters you mean to include in that 
definition of multiple spaces...

-- 
CC

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




[PHP] Re: preg_replace_callback

2002-07-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Rafael Fernandes) wrote:

 First, sorry for my elementary english...
 I need a function made for PHP3 that works like preg_replace_callback...

Before preg_replace_callback() was introduced, preg_replace() used to have 
another an f modifier which had similar functionality.  I'm not sure 
whether that modifier was available back in PHP3, but here's the relevant 
quote about f from an old set of PCRE Syntax docs:

 F
 If this modifier is set, preg_replace() treats the replacement parameter as a 
 function name that should be called to provide the replacement string. The 
 function is passed an array of matched elements in the subject string. NOTE: 
 this modifier cannot be used along with /e modifier; and only preg_replace() 
 recognizes this modifier.

If I recall correctly (which I may not), an example would look something 
like this:

$output=preg_replace(/(\w+)/f,'***' . strtolower($1) . '***',$input);

-- 
CC

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




[PHP] Re: Does not work

2002-07-14 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Saci) wrote:

 I tried this simple code
 
 html
 body
 Page refered by
 ?php
 echo $HTTP_REFERER.'br';
 echo $_SERVER['HTTP_REFERER'].'br';
 ?
 /body
 /html
 
 and I receive blank reply even if referenced from a link from other site.
 
 What am i doing wrong ? Or perhaps my server does not have referer enabled?

It's possible that your *browser* does not pass referer information.  But 
keep in mind that if there was no referring page, then there is no referer 
value for the browser to set.  Try this instead:

html
body
form method=get
Page refered by
?php
echo $HTTP_REFERER.'br';
echo $_SERVER['HTTP_REFERER'].'br';
?
input type=submit
/form
/body
/html

Load it, check the value, click Submit, then check again.

-- 
CC

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




[PHP] Re: preg_match or not?

2002-07-07 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Steve Fitzgerald) wrote:

 I have been struggling for a couple of hours now trying to write a
 preg_match expression to validate a dollar amount - the user may or may
 not put in the decimals so I want to allow only digits plus a possible
 period followed by two more digits. My eyes are now swimming and I just
 can't seem to get right. This is what I have at the moment:
 
 if (!preg_match(/[\d]+([\.]{1}[\d]{2})?/, $form_data[amount])) //
 wrong amount
 
 but it still allows invalid input. Can anyone help or is there a better
 way to do it?

It sounds like you need an exact match; note that your regex is matching 
against substrings, thus additional invalid characters are allowed to pass. 
Anchor the pattern, so that it essentially says From beginning to end, the 
only chars allowed are one or more digits, optionally followed by the 
combination of a period then two more digits.  (The ^ and $ special 
chars are anchors.)

A regex special character loses it specialness when it's either escaped 
with a backslash, or included within a square-bracketed character class; 
you don't need to do both.

The {1} is implied; you don't need it.

if (preg_match(/^\d+(\.\d{2})?$/, $form_data[amount]))
   {echo Validated!;}
else
  {exit(That's not a dollar amount.);}

-- 
CC

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




[PHP] Re: How to put these 2 IF statements into 1, with regex?

2002-06-30 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] 
wrote:

 I was wondering if there is anyway to combine these two IF statements 
 into one:
 
 if (preg_match(@siteUserList.cgi?group=site177@, $QUERY_STRING))  
 
 and:
 
 if (preg_match(@siteUserList.cgi?group=site177@, $QUERY_STRING))

Remember that preg_* functions aren't equivalent to str_*; you're matching 
against a regex pattern now, not just a simple text string.  So you must 
first escape any regex special characters within your text string if you 
want reliable results.  Otherwise, you're going to eventually end up with 
unintended matches like siteUserList9cggroup=site177.

Regarding the rest of your question: the ? character is what you seek.

if (preg_match(/siteUserList\.cgi\?group=site177?/, $QUERY_STRING))

-- 
CC

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




[PHP] Re: PHP with CSS

2002-06-30 Thread CC Zona

In article 001101c220b8$5338fc30$768c3841@c3,
 [EMAIL PROTECTED] (Bruce Karstedt) wrote:

 Quick question?
 
 Is their anything in Apache or PHP that would keep styles from working. Both
 external (CSS) and inline styles are ignored.

If it was the only the external stylesheet that wasn't working, the first 
thing to do would be to check that Apache is configured to the right 
content type (text/css) for it and that the PHP code isn't doing anything 
silly like sending the dynamically-generating the *.css page with a 
header() declaring a different content type; but with the inline styles 
also not working, that scenario would either be unlikely or only part of 
the story.

Have the HTML and CSS both been validated yet?  If the output of your PHP 
includes syntactically-flawed HTML, that could lead to problems with the 
CSS rendering as well.  And of course, invalid CSS will not render as 
expected.  This final thought may already be obvious to you, but is there 
any chance that the styles you're using are either not supported by your 
browser, or that your page's doctype has accidentally triggered the 
browser's less-forgiving standards mode? (If any of this sounds 
unfamiliar, you can follow-up with a newsgroup or list where CSS is 
on-topic, such as news:comp.infosystems.www.authoring.stylesheets.)

Good luck!

-- 
CC

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




[PHP] Re: Is this a BUG?

2002-06-23 Thread CC Zona

In article 000c01c21b02$4b69e1b0$1aed0dd1@gateway,
 [EMAIL PROTECTED] (César aracena) wrote:

  I have a mainusers.php page, which only calls for functions
 instead of writing them all together inside that page. At one step, it
 calls for an “adduser” function which brings a table that let the
 administrator insert a new user. After the submit button is pressed, it
 calls for a function called “useradded” which resides in the same
 library as the “adduser” function. This useradded function queries the
 database, inserting the user. The problem is that it does not get the
 HTTP POST VARS although they are being passed according to phpinfo.php.

Without an example to look at, I may be mis-understanding your situation.  
But it sounds like this may be a scoping issue: trying to use a global 
($HTTP_POST_VARS) within a function without using the special global 
keyword. 

This won't work:

function adduser()
   {
   echo LOCAL SCOPE:  . $HTTP_POST_VARS['user'];
   }
adduser();

This will:

function adduser()
   {
   global $HTTP_POST_VARS['user'];
   echo GLOBAL SCOPE:  . $HTTP_POST_VARS['user'];
   }
adduser();

If this is the problem you're having, you can find more information at:

http://php.net/variables.scope
http://php.net/global

-- 
CC

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




[PHP] Re: preg_replace

2002-06-16 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Gerard Samuel) 
wrote:

 When you think you got it, you don't get it..
 Im trying to scan the link for =A-Z0-9_=, dump the '=' and evaluate the 
 remainder as a defined constant.
 Yes its funny looking, but if I could get this going Im golden.
 $bar is always returned with '=_L_OL_HERE=' as the link and not 'here' 
 as it supposed to be.
 Any help would be appreciated.
 Thanks
 
 
 ?php
 define('_L_OL_HERE', 'here');
 $foo = 'a href=there.com=_L_OL_HERE=/a';
 $bar = preg_replace('/(=)([A-Z0-9_])(=)/e', ' . constant($2) . ', $foo);
 
 echo $bar;
 
 ?

You're trying to match one or more characters in the class, so add a +.  
And you're not concatenating the expression 'constant($2)' with anything, 
so lose the extra periods.  Parentheses aren't needed around the equals 
signs, so you might as well drop those too.  Ex:

preg_replace('/=([A-Z0-9_]+)=/e', 'constant($1)', $foo);

-- 
CC

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




[PHP] Re: translate perl unpack to php equivalent

2002-06-16 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Danny Kruitbosch) wrote:

 How would I translate this perl unpack statement to the php equiv.
 
 my ($salt, $xor) = unpack('a2 a*', $something)

http://php.net/unpack

-- 
CC

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




[PHP] Re: Regular Expressions Help

2002-06-05 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] (J. Younker) 
wrote:

 Hi,
 I'm trying to use eregi_replace to check a user-submitted URL, but I
 keep getting the following error message:
 Warning: Invalid range end in /var/www/html/_db_db/db_input.php
 This what I'm using:
 $pattern = (http://)?([^[:space:]]+)([[:alnum:]\.-_?/=]);

You've already gotten a working substitute using the superior preg_replace 
function, but FWIW: the invalid range was caused by a misplaced hyphen.  
In the middle of a character class, it delimits a range; to use it as a 
literal, make it the last character in the character class.

-- 
CC

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




[PHP] Re: Register_Shutdown_Function ??

2002-05-18 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Caldwell) wrote:

 Here's my code:
 
 ?
  set_time_limit(1);
  function clean_up()
  {
   if(connection_status()  TIMEOUT)
print(Script timed out.\n);
  }
 register_shutdown_function(clean_up);
 while(1);
 ?
 
 Here's the message I get:  (I should get Script timed out.)

No, you shouldn't/wouldn't, because--as is noted in the docs 
http://php.net/register-shutdown-function--no more output (print is 
specifically mentioned as an example) can be sent to the browser at that 
stage.  Try sending youself an email, or logging to a file instead.

-- 
CC

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




[PHP] Re: php.net sloooooooowwww

2002-05-18 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Caldwell) wrote:

 Is there some place else I can download release 4.2.1 ??? www.php.net is
 dead slow, and us2.php.net is taking forever to prompt me for the
 download -- I keep getting hit with the Page Cannot be Displayed error.

Have you tried any of the other mirrors, for example uk.php.net?  I'm not 
sure why us2 is giving you a problem, but hopefully other mirrors would not 
do the same...

-- 
CC

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




[PHP] Re: getting a function name of the calling function

2002-05-02 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Joshua E Minnie) wrote:

 What I am trying to do is create an error message within in a string that
 whenever each function fails it echos this particular string out with it's
 pertinent information.
 
 i.e.
 ?
 $error_string = Warning: unable to complete query in .__FUNCTION__.name
 in .__FILE__;
 
 function some_funct($var) {
   global $error_string;
   //doing something
   //error detected
   echo $error_string;
 }
 ?
 
 Does this sounds feasible or is there another way to generate a dynamic
 error message without giving the user to much information about the error if
 it occurs?

For this purpose, substitute __LINE__ for __FUNCTION__, and you're in 
business.  A line number is less revealing to an end-user anyway than a 
function name (you don't want Error in function 'log_private_user_info()' 
showing up).  But it's more specific abouty pinpointing the place (or last 
possible place, anyway) that script went wrong.  In a functions several 
hundred lines long and with control structures defining many possible paths 
through it, knowing only that the function had an error *somewhere 
(unknown)* isn't very helpful.

A step up would be to use the error handling functions instead 
http://php.net/errorfunc.  Then you can customize which errors get 
reported to the user, under what circumstances, how, whether to forward the 
reports to you as well, plus the opportunity to know the context (set 
variables and their values) in which the error occured.

-- 
CC

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




[PHP] Re: case-insensitive str_replace

2002-05-02 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (J Smith) wrote:

 Reuben D Budiardja wrote:
 
  I am in need of a case-insensitive str_replace.snip
  
  The feature that I use in str_replace is to put the 'search' and 'replace'
  argument as an array, as described in the documentation for php = 4.0.5
  Some people suggested some functions in the archive and documentation, but
  I cannot find anything that can receive arrays as the arguments.

 preg_replace() can be used with arrays.

Yes, just use the i (for case insensitive) modifier after the closing 
regex pattern delimiter:

$patterns=array(/foo/i,/bar/i);

-- 
CC

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




Re: [PHP] Re: case-insensitive str_replace

2002-05-02 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Reuben D Budiardja) wrote:

 On Thursday 02 May 2002 04:08 pm, J Smith wrote:
  preg_replace() can be used with arrays.
 
 Yeah, but how to make it case-insensitive beside changing the my search and 
 replace strings to a regular expression? The problem is that I have a big 
 array for search and replace, and it would be most labourious to change them 
 to reg exp.

It shouldn't be laborious, if the array's values were--as you 
implied--compatible with str_replace.  You're replacing an array of 
straight string values, correct?  So just escape the regex special values 
(preg_quotes()) in each while you're looping through the array to add the 
pattern delimiters and i modifier.  Then pass that array to preg_replace.

-- 
CC

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




Re: [PHP] eregi

2002-05-02 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Miguel Cruz) wrote:

 On Thu, 2 May 2002, Fredrik Arild Takle wrote:
  eregi($start(.*)end, $rf, $my_var);
  
  And I want it to stop at the first presedence of $end, not the last (thats
  what this is doing).
 
 Try preg, which is faster and gives you more control (here the ? 
 munificence operator).
 
 preg_match(/{$start}(.*?)end/, $rf, my_var);

Leave out the braces.

preg_match(/$start(.*?)end/, $rf, my_var);
  -or-
preg_match(/$start(.*)end/U, $rf, my_var);


(And make sure the value of $start either doesn't have any regex special 
chars, or is using them intentionally, or has them escaped 
http://php.net/preg-quote.)

-- 
CC

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




Re: [PHP] eregi

2002-05-02 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Miguel Cruz) wrote:

 On Thu, 2 May 2002, CC Zona wrote:
  [EMAIL PROTECTED] (Miguel Cruz) wrote:
  preg_match(/{$start}(.*?)end/, $rf, my_var);
  
  Leave out the braces.
 
 Don't they get removed by the parser's handling of double-quoted strings 
 long before anything makes it to preg_match()? 
 
 I almost always use the braces when inserting variables inside string 
 literals, just to avoid any chance of ambiguity.

There's no ambiguity here since parentheses aren't legal in variable names, 
so the curly braces are just excess.  Given the braces' significant as 
special regex characters, it can be a confusing distraction in this 
context, especially for newbies trying to grasp simply regex syntax.  
Better to save the braces for where they're needed to tell the parser or 
programmer how to interpret ambiguous code.

-- 
CC

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




Re: [PHP] Re: getting a function name of the calling function

2002-05-02 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Miguel Cruz) wrote:

 I'm guessing he wants to do something like a stack trace to figure out how 
 a function managed to get itself called with bad data.
 
 With utility functions that may get called hundreds of times in a single 
 run, that would be some really handy stuff.

Being able to trace which function called another would be very useful.  
(The OP just wanted a constant like __FILE__ to identify the current 
function in an error message.)

-- 
CC

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




Re: [PHP] PHP --help

2002-05-01 Thread CC Zona

In article 002b01c1f115$7ae52790$2f7e3393@TB447CCO3,
 [EMAIL PROTECTED] (1lt John W. Holmes) wrote:

 Use $_GET[fn] and $_GET[ln], or $_POST[], depending on your action.
 
 Does anybody read the release notes for a product before you download and
 install it? I'm just going to save a standard message that covers this
 because I see questions like this continuing until everybody upgrades.

Since there are still people using PHP3, that could be a very looong 
time.

-- 
CC

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




[PHP] Re: getting a function name of the calling function

2002-05-01 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Joshua E Minnie) wrote:

 Does anybody know of any constants or predefined functions that will
 retrieve the calling functions name?  For example:
 
 ?
 function new_func($somedata) {
   echo I am function .get_func_name();
 }
 ?

What would be the point of this?  How could you call the function to get 
the info without already having the info in the first place?  If calling 
with a variable ($foo();), then you have the variable.  If the call is 
hardcoded (new_func();) then of course you know the name there too.  
Perhaps if you explained what you're trying to accomplish...

-- 
CC

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




[PHP] Re: Problem with fopen()

2002-04-30 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Ben Turner) wrote:

 I am getting the error that I cannot create the
 file in the directory.  I have tried chmod and chown on the directory but
 nothing is working for me.  I have even gone so far as to make the owner of
 the directory apache and the group of the directory apache but no luck.

Have you already confirmed that Apache is running as  user apache and not 
some other name (nobody, www, web, http, etc.)?

Have you already confirmed that the Apache user has write permissions to 
the directory?

What is the full text of the error message?

-- 
CC

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




[PHP] Re: regular expressions help please

2002-04-30 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Ed Lazor) wrote:

 I've been banging my head against regular expressions all night... help 
 would be greatly appreciated.  Could you give me examples on how to do the 
 following?
 
 Pull everything except a specific word from a sentence.
snip more examples

First you need to decide what you mean by word.  If it's simply the 
stuff separated by a space, then you might find it simpler to explode your 
sentences on the space character, then loop through the resulting array 
using string functions to do your comparisons .  Regex is great for the 
power and flexibility it offers, but if you're really struggling with the 
syntax, using constructs that are more familiar may help you move forward.

On the other hand, it's frequently the case that one needs a more 
sophisticated definition of word.  Is it just adjacent letters?  What if 
they're interrupted by a hyphen?  Are leading/trailing punctuation marks 
included?  Do adjacent digits count as words?   Etc. Once you've defined 
the pattern comprising a word, you can then translate it into regex--or 
get more help from others in making the translation.

-- 
CC

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




Re: [PHP] apps that need register globals 'on' and others require 'off' on same server

2002-04-30 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Sheets) wrote:

  From: Jeff Bearer [mailto:[EMAIL PROTECTED]]
  
  Is there a way to turn register globals on or off in the script at
  runtime?

 Chapter 3 in the PHP manual covers setting PHP configuration directives via
 the .htaccess file.
 
Yes, and these directives can also be used within containers such as 
file, location, and directory within the Apache configuration file.

Since the OP asked about runtime, there is also ini_set() 
http://php.net/ini-set.

-- 
CC

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




[PHP] Re: Looking for an easier regex check...

2002-04-29 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Joshua E Minnie) wrote:

 Does anybody know of a good way to make sure that a string contains ONLY
 certain characters.  I tried using
 ereg([~`!@#$%^*(){}-+=|\\/.,'\:;\[\]], $string); but I get parse
 errors.  Besides that I only want the characters A-Za-z0-9_ in $string.  Is
 there is simpler way to ensure this rather than checking to see if any of
 the characters I don't want are in there?

if(preg_match(/\W/,$string))
   {
   echo Bad characters.;
   }

http://php.net/preg-match
http://www.php.net/pcre.pattern.syntax

-- 
CC

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




[PHP] Re: Stripping characters.....

2002-04-28 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Cditty) wrote:

 ieUser email address is Chris Ditty 
 [EMAIL PROTECTED]  or  Chris Ditty [EMAIL PROTECTED]
 
 I need to be able to strip the quotes and everything between them and the 
   signs from the first one and then the name and the   signs from the 
 second.
 
 Does anyone know how to do this quickly and easily?

http://php.net/preg-replace.  For example:

preg_replace('/^.*(.+).*$/',$1,$mailstring);

-- 
CC

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




[PHP] Re: Stripping characters.....

2002-04-28 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Cc Zona) wrote:

 In article [EMAIL PROTECTED],
  [EMAIL PROTECTED] (Cditty) wrote:
 
  ieUser email address is Chris Ditty 
  [EMAIL PROTECTED]  or  Chris Ditty [EMAIL PROTECTED]
  
  I need to be able to strip the quotes and everything between them and the 
signs from the first one and then the name and the   signs from the 
  second.
  
  Does anyone know how to do this quickly and easily?
 
 http://php.net/preg-replace.  For example:
 
 preg_replace('/^.*(.+).*$/',$1,$mailstring);

Whoops.  Hit send too quickly.  That should be:

$newstring=preg_replace('/^.*(.+).*$/',$1,$mailstring);

Note that this is *just* an example.  It will break where there are 
multiple addressees, a less-than sign in the addressee's name, etc.

-- 
CC

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




Re: [PHP] lookin for a Menuing System...

2002-04-28 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Wong) wrote:

 Konqueror is the only browser (that I've used) which supports per-site 
 javascript policy (deny, allow, disable pop-ups).

iCab too.  It allows suppression of various intrusive JS features on a 
global and per-host basis.  You can surf without the automatic popups, but 
still traverse all those silly a href=javascript: open(...) links by 
authors allergic to the onclick handler.

-- 
CC

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




[PHP] Re: init_set(): auto_append_file doesn't work?

2002-04-27 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Matt Wong) wrote:

 init_set doesn't seem to work for setting auto_append_file, in php 4.1.2. 
 the master setting is NULL, and the local setting is properly set when I do 
 a phpinfo(), but the file never gets appended. Any ideas?

The function is ini_set(), not init_set().

-- 
CC

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




[PHP] Re: Safe mode

2002-04-26 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Ashley M. Kirchner) wrote:

 IfModule mod_php4.c
   php_value include_path .:/usr/local/lib/php
   php_flag safe_mode On
   php_flag magic_quotes_gpc Off
   php_flag track_vars On
   php_flag track_errors On
 /IfModule
 
 And the safe_mode entry doesn't seem to have any effect what so ever.

Safe mode used the admin flag:

php_admin_flag safe_mode on

-- 
CC

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




Re: [PHP] Safe mode

2002-04-26 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Ashley M. Kirchner) wrote:

 Rasmus Lerdorf wrote:
 
  You need to use php_admin_flag for safe_mode.
 
 And I suppose this page has an error on it then:
 
 http://www.php.net/manual/en/configuration.php
 
 Since it states php_flag, not php_admin_flag...

The beauty of the system is that when one spots such errors, one can 
immediately add a correction to the annotated docs.  (Done.)

-- 
CC

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




Re: [PHP] Array wildcard?

2002-04-25 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Leif K-Brooks) wrote:

 One more question.  Is  there any way to use this with part of a string?
 Example:
 function checkfruitlove($string){
 $fruitarray = array(apples,oranges);
 if($string == I love .in_array($fruitarray).!){
 $return = I do too!;
 }else{
 $return = I don't!;
 }
 return $return;
 }
 $answer = chechfruitlove(I love apples!); //returns I do too!
 $answer = chechfruitlove(I love oranges!); //returns I do too!
 $answer = chechfruitlove(I love pears!); //returns I don't! 

http://php.net/preg-match

-- 
CC

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




[PHP] Re: Help PHP 4.2: No more error messages

2002-04-24 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Mark W. Humphries) wrote:

 I am running PHP 4.2 and Apache 1.3.23 on Win2k.
 I am generating png files. Before upgrading to PHP 4.2 whenever I had a bug
 in a png generating script I would get back an error message, now I only get
 back a blank page. I have error reporting set to E_ALL.

Check the value of display_errors too.

-- 
CC

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




[PHP] Re: Why does this not work??

2002-04-22 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jeffrey Means) wrote:

 In using the setcookie function I can not set a cookie if I specify a time 
 period.  ie. setcookie(Cookie_Name, Cookie_Value, time()+30); will not 
 set a cookie, but setcookie(Cookie_Name, Cookie_Value); does work.  What 
 am I dooing wrong??

You need to read the docs more carefully, because time() returns a value in 
seconds, not minutes.  Your time period is too short: the cookie expires 30 
seconds after having been set.  Whereas when you set no expiration, the 
cookie remains set until the window closes.

-- 
CC

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




[PHP] Re: file_get_contents source??

2002-04-19 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Giovanni Lenzi) wrote:

 file_get_contents function is supposed to return the contents of a file in a
 binary safe manner. I tried it on two different servers which has different
 versions of APACHE+PHP but it still not works.
 The server give me this response:
 
 Fatal error: Call to undefined function: file_get_contents() in
 /usr/home/s/a/sauzer/public_html/sfidario/readstreams/1.0/warsupcoming.php
 on line 17

From http://php.net/file-get-contents: file_get_contents (PHP 4 CVS 
only).  That's why it's not in your version.  Reading further, it says 
Identical to readfile(), except that file_get_contents() returns the file 
in a string.  So if don't need to do additional manipulation of the 
contents, there is one viable alternative.  The user annotations suggest 
two additional alternatives.

-- 
CC

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




[PHP] Re: Executing a time intensive script

2002-04-18 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Zach Curtis) wrote:

 Is there a way to get the function to
 execute and let it run on its own within login.php and let the user continue
 on to the authenticated area without that delay?

http://php.net/set-time-limit
http://php.net/ignore-user-abort

-- 
CC

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




Re: [PHP] Would this work? (mod_rewrite)

2002-04-17 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] 
wrote:

 But now I am receiving a 404 error message and the following message in my 
 error log:
 
 [Wed Apr 17 18:31:26 2002] [error] [client 172.131.190.148] File does not 
 exist: /home/swiften/public_html/404.shtml
 
 [Wed Apr 17 18:31:26 2002] [error] [client 172.131.190.148] File does not 
 exist: /home/swiften/public_html/technicians.html
 
 The 404.shtml thing has to do with my ISP.  I think that one's out of my 
 control; so is there a work around so it does not try to find that file??

ErrorDocument directive 
http://httpd.apache.org/docs/mod/core.html#errordocument.

-- 
CC

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




[PHP] Re: mod_rewrite (the solution)

2002-04-17 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] 
wrote:

 RewriteEngine  on
 RewriteBase/
 RewriteRule$.* index.php

RewriteRule takes a regular expression as its first parameter 
http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteRule.

The $ regex meta-character is an end-of-line marker.  It has no special 
meaning at the beginning of a pattern.  If you want a pattern that matches 
anything including nothing, use:

RewriteRule ^.*$ index.php

-- 
CC

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




[PHP] Re: mod_rewrite (the solution)

2002-04-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Cc Zona) wrote:

 In article [EMAIL PROTECTED], [EMAIL PROTECTED] 
 wrote:
 
  RewriteEngine  on
  RewriteBase/
  RewriteRule$.* index.php
 
 RewriteRule takes a regular expression as its first parameter 
 http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteRule.
 
 The $ regex meta-character is an end-of-line marker.  It has no special 
 meaning at the beginning of a pattern.  If you want a pattern that matches 
 anything including nothing, use:
 
 RewriteRule ^.*$ index.php

I shouldn't have copy/pasted, because index.php also is wrong in this 
context.  If one is trying to redirect from, say, 
/dir_that_may_not_exist/ to index.php, then how is apache supposed to 
serve up /dir_that_may_not_exist/index.php.  It can't.  So logically the 
2nd parameter has to be /index.php.  For clarity's sake, using the L 
modifier for parameter #3 is also a good idea:

RewriteRule ^.*$ /index.php [L]

Mod_rewrite is a complex beast, so read the docs closely.  And if all you 
really need is to capture/redirect 404s, check out the ErrorDocument 
directive instead.  Simple to use, easy to learn, and none of the 
mod_rewrite overhead.

-- 
CC

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




Re: [PHP] Nasty DoS in PHP

2002-04-17 Thread CC Zona

In article 000401c1e67b$dd64c820$2fa3f318@blackbox,
 [EMAIL PROTECTED] (Dustin E. Childers) wrote:

 It does not stop after its execution time. We have let this run for 10+
 minutes to see if it would crash the server, and it did. It does not affect
 the person that loads the code in the browser, just affects the server
 running the code.

You say that the script is exceeding both the memory limit and time limit; 
have you run phpinfo() from this script to confirm that those settings are 
in effect?  Perhaps the wrong php.ini file is being used, or the php.ini 
settings are being overridden by settings in httpd.conf, .htaccess, or even 
the script itself...

-- 
CC

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




[PHP] Re: HTTP gzip-compression and fopen

2002-04-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Trond Arve Nordheim) wrote:

 I was writing a slashdot RSS-parser for my homepage, and wrote a simple
 function to fetch the slashdot.rdf-file from slashdot, and parse it
 using PEAR's XML/RSS.php.
 
 Here's the core reading the remote file:
 $fp = @fopen(http://slashdot.org/slashdot.rdf;, r);
 if (!$fp) { return 0; }
 $raw = fread($fp, 1);
 fclose($fp);
 
 Now, it seems like slashdot is doing som on-the-fly gzip-compression (it
 sends a Content-Encoding: gzip-header), and that fopen can't cope with
 this, and I'm stuck with some binary data. I've tried using
 gzuncompress() on the returned data, but that resulted in an error (not
 valid gzip-data).

Since no one else has responded yet, I'm going to take a wild guess that 
your browser's Accept headers are being used on the fopen() request, 
leading the slashdot server to believe that your script can process gzipped 
data...?  FWIW, I'd try using fsockopen() instead, explicitely setting 
Accept (probably to text/html, text/xml, and text/rss--if the latter is a 
valid content type).

BTW, you should take out that @ sign, turn error_reporting all the way up 
to E_ALL, and add some error checking.  Just in case PHP already knows what 
the problem is, and you're not letting it tell you...

-- 
CC

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




Re: [PHP] Nasty DoS in PHP

2002-04-17 Thread CC Zona

In article p05100304b8e3cee5ab0c@[210.49.237.250],
 [EMAIL PROTECTED] (Richard Archer) wrote:

 At 8:55 PM -0400 17/4/02, Justin Farnsworth wrote:
 
 This is a rather meaningless thread.  It is a
 security issue that is displaced.
 
 If PHP is not honoring the time limit and memory usage directives
 when outputting headers, then this is a bug in PHP.

A big if, since the OP has not yet verified that the time limit and 
memory limit are in effect at the outset of the loop as supposed.  Someone 
else want to test for this scenario?  Someone, that is, who can 
deliberately bring down their server without getting kicked off permanently?

Meanwhile...

 If this allows a DoS attack, then this is a very real security problem.

Why should it?  Even if there is a verifiable bug allowing time/memory 
limits to be exceeded when header() goes into an infinite loop, how could 
someone exploit this from the outside?  If a scripter is letting any random 
web visitor put their script into an infinite loop, then the results are at 
*least* as much the scripter's fault as PHP's.  Ditto for the scripter who 
sets the infinite loop himself while allowing the web user to specify what 
function gets executed in the loop.  And if neither of these is happening, 
then where's the DoS?  As has already been pointed out, someone bringing 
down their own server with their own code, isn't a DoS.  It's usually poor 
coding, and _possibly_ (see above) attributable to a bug, but it's not a 
DoS.

As far as I can tell, the only security problem here is the usual one: 
figuring out who is clueful enough and responsible enough to be trusted 
with access to operations which can compromise the server.

Whether there is a bug or not remains an open question.  I'll be curious to 
hear whether anyone is able to reproduce a server crash in spite of 
set_time_limit(30) and ini_set(memory_limit,8M) conditions.

-- 
CC

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




Re: [PHP] Nasty DoS in PHP

2002-04-17 Thread CC Zona

Do you have a PHP binary compiled too?  If Apache can be taken out of the 
equation and the script still exceed memory/time limits, that would sure 
appear to be a PHP bug. (FWIW, I can't find an existing bug report about 
this behavior at bugs.php.net.  Perhaps you and the OP could run backtraces 
and open a new bug report?)


In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Soza) wrote:

 It shows the memory and CPU time being used by apache. I have PHP 
 installed as a module, that may be why. (?)
 
 Jason Soza
 
 - Original Message -
 From: Martin Towell [EMAIL PROTECTED]
 Date: Wednesday, April 17, 2002 6:37 pm
 Subject: RE: [PHP] Nasty DoS in PHP
 
  Is that memory usage used by PHP or apache?
  
  -Original Message-
  From: Jason Soza [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, April 18, 2002 12:35 PM
  To: CC Zona
  Cc: [EMAIL PROTECTED]
  Subject: Re: [PHP] Nasty DoS in PHP
  
  
  For what it's worth, I just ran this script on my server, and despite 
  the 30 second time limit and 8mb memory limit in php.ini, the script 
  ran longer than 30 secs, CPU usage went between 60% and 100% and my 
  memory usage reached 352000 before I stopped it.

-- 
CC

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




Re: [PHP] Nasty DoS in PHP

2002-04-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Soza) wrote:

 Interesting, check out my apache error log:
 [Wed Apr 17 18:35:53 2002] [error] PHP Fatal error:  Maximum execution time
 of 30 seconds exceeded in d:\html\loop.asp on line 7

LOL.  You use *.asp for your PHP scripts?  Wouldn't that be considered 
blaspemous? g

 So PHP recognized the max execution time of 30 seconds being exceeded, but
 neither it nor apache shut down the script.

So that was both as an Apache mod and a CGI binary?  Sounds like it's 
reproducible.  Open a bug report so the developers can track it down 
http://bugs.php.net/report.php.  Even though putting header() into an 
infinite loop sounds like something not to do in general, a bug is still a 
bug even if it's a pretty esoteric one.

-- 
CC

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




[PHP] Re: help required on removing lf-cr from form data

2002-04-16 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Venkateshwar B) wrote:

 I have
 tried to use str_replace and replace \n by . But it does'nt give
 me the desired result of limiting text to single line .

$nobreaks=preg_replace(/[\r\n]+/, ,$hasbreaks);

http://php.net/preg-replace

-- 
CC

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




[PHP] Re: Seeing if a value matches anything in an array

2002-04-15 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Leif K-Brooks) wrote:

 I need some way to check for the presence of any value from an
 array.

http://php.net/in-array
http://php.net/array-search

-- 
CC

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




[PHP] Re: file seems b0rken

2002-04-09 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Thomas Wentzel) wrote:

 $test=@file(some_non_existing_file);
 
 Can somebody explain why count($test) is 1. When $test doesn't hold any
 data

From http://www.php.net/manual/en/function.count.php:

If var is not an array, 1 will be returned

When file() failed to open your non-existing file, it returned false. False 
isn't an array, so count() returned 1.

-- 
CC

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




[PHP] Re: PCRE - catching a caracter set in a negative class

2002-04-09 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Maxim Maletsky) wrote:

 I was scratching my head to accomplish the following perl regular 
 expression. It doesn't want to catch me [^\{php}]. From what I understood 
 reading the docs this is because in a negative class the caracters are being 
 taken litteraly one by one and not as a set. I tied to enclose them by () by 
 that didn't work eigher. What is the work around for this? 

The section of the PCRE Syntax page that you want is the part dealing with 
lookaheads and lookbehinds.

-- 
CC

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




[PHP] Re: How do I use fopen() to overwrite a remote file via ftp?

2002-04-08 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Dalton Hunter) wrote:

 Hi, I want to use fopen to connect to a remote server via ftp and overwrite
 a file like ...
 
 fopen(ftp://username:[EMAIL PROTECTED]/system/path/to/file.php;, w)
 
 ... but after connecting I get the Warning: File already exists error
 message and it fails. What is the proper way to overwrite it?

By using the FTP functions, not fopen (quote from http://php.net/fopen: 
HTTP connections are read-only; you cannot write data or copy files to an 
HTTP resource).

The example on the FTP chapter's intro page http://php.net/ftp 
demonstrates how.

-- 
CC

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




Re: [PHP] Banning javascript?

2002-04-08 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Murray) wrote:

  I want to ban javascript from my site (users can edit some things).  I 
  know how to ban it in script tags, but does anyone have a function 
  that bans javascript in ALL of the ways of puting it on?  It would 
  take me a while to figure them all out. 

 Use strip_tags and only allow basic HTML (basic HTML can be anything
 but I'd make it BIUDIVSPANSTYLETABLETRTD) through.
 
 This will strip all SCRIPT tags.

Just stripping down to a few essential tags isn't sufficient; Javascript 
can still be fired from any of the remaining tags' standard event handlers: 
onclick, ondblclic, onmousedown, onmouseup,  onmouseover, onmousemove, 
onmouseout, onkeypress, onkeydown, onkeyup...  So you'd also have to strip 
all event handlers from each tag.

Then there's the javascript:  pseudo-protocol; so you'd also have to 
check the href value of all anchor tags to make sure they're not not 
invoking javascript.

And since users can edit some/all of the html, then what's to stop them 
from using a frame, server-side includes, etc. to incorporate some else's 
JS-using page into your site? 

OTOH, banning users from any direct editing and running all of their 
submitted content through htmlentities() before serving it up is a pretty 
quick and easy solution.

-- 
CC

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




[PHP] Re: array limits in echo function?

2002-04-08 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Lmlweb) wrote:

 if I use within my html codes:
 
 ?php echo $fname $lname; ?, I get an error message telling me:
 
snip

how do I best combine the two (other than having to create two separate 
?php..? codes in the HTML)?

Any of these work:

?php echo $fname . $lname; ? //concatenation operator

?php echo $fname , $lname; ? //echo takes variable # of args

?php echo $fname $lname; ? //double-quotes interpolate

?php echo $fname; echo ' '; echo $lname; ? //multiple statements

?php echoEOF
$fname $lname
EOF; ? //heredocs interpolate too

-- 
CC

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




[PHP] Re: Function that escapes special caracters from regular expressions

2002-04-07 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Charlie Killian) wrote:

  Is there one?

 I don't now of one.

That's because PHP doesn't have one, it has two: 
http://php.net/preg-quote and http://php.net/quotemeta.  (Read the docs 
carefully; these functions escape slightly different character sets...)

-- 
CC

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




[PHP] Re: Executing functions within ereg_replace() output

2002-04-06 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Adam Wan) wrote:

 $content = 'string string 12463409834234 string string';
 $content = ereg_replace( [0-9]{14} , substr(\\1,0,5) , $content );
 
 // this is the output i want, but the above doesnt seem to be the right way
 to generate it.
 
 string string 12363 string string
 
 
 any ideas?

For future reference:
http://www.php.net/preg-replace-callback

For this instance:
$content = ereg_replace( ([0-9]{5})[0-9]{9} , \\1, $content);

-- 
CC

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




[PHP] Re: regexp for ' replacement

2002-04-05 Thread CC Zona

In article 
[EMAIL PROTECTED],
 [EMAIL PROTECTED] (Thalis A. Kalfigopoulos) wrote:

 If I have as part of a text:
 ...and then 'the quick brown fox jumped over the lazy dog's piano'...
 
 How can I substitute the single quote in dog's with say \'
 I want to aply a substitution for only the single quote that is between two 
 single quotes and leave the rest of the text in between the same.

Does this work for you?

$str=...and then 'the quick brown fox jumped over the lazy dog's 
piano'...;
echo $str=preg_replace(/'(.*)'(.*)'/U,'$1\'$2',$str);

-- 
CC

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




[PHP] Re: conditionaly including classes/functions

2002-04-05 Thread CC Zona

In article f05100303b8d23ce1c0d5@[217.37.50.73],
 [EMAIL PROTECTED] (Andrew Warner) wrote:

 Is it okay practice to condtionally include php files that contain 
 only classes or functions (as opposed to just straight code)?   The 
 result is a class or function inserted right in the middle of an if{} 
 block:
 
 
 } elseif ($var=='a')
 {
  include('temp.php');
 
  $obj = new foo;
  echo $obj-hello();
 
 }

It's fine, but since redeclaring functions is an error, better to use 
include_once() or require_once().

-- 
CC

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




[PHP] Re: Help with Function parameter

2002-04-04 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Simonk) wrote:

 I have programed a function for counting Date:
 
 function Datereturn()
   {
snip
   Return $realday;
   Return $month;
   Return $year;
}
 
 But when I want to echo out the result, I have typed:
 
 Datereturn();
 echo $year, $month, $realday;
 
 Then the server return:
 Undefined variable year, month, realday

Re-read the docs on the return statement 
http://www.php.net/manual/en/function.return.php.  A few pointers:

A) As soon as a 'return' is encountered, function execution ends; it will 
never get to the lines containing additional returns.

B) To return multiple values in a single 'return' statement, return an 
array variable.

C) 'Return' does not set variables in the global scope for you; it's up to 
you to explicity set a variable.

function myFunc()
   {
...
return array ($one, $two, $three);
}

$returned=myFunc();
echo {$returned[0]}, {$returned[1]}, {$returned[2]};

-- 
CC

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




[PHP] Re: Incrementing number by .1 or substracting .1

2002-04-04 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Devin Atencio) wrote:

 I am trying to figure out how to write a script to increase
 a number by .1 or decrease a number by .1 but the number needs
 to be in the syntax of x.x.

$start=1;
$up=$start+ 0.1;
$down=$start-0.1;

http://www.php.net/manual/en/language.types.float.php

-- 
CC

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




[PHP] Re: save page to DB

2002-04-01 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Phil Solomon) wrote:

 Hi all,
 I have a page that dynamically produces itself from a mysql db. It produces
 a form with the prices of scaffolding items and then uses JS as a quote
 calculator. I was wondering whether someone could tell me how to save the
 whole page into one field so that it can be reproduced in what ever state it
 was left?
 It will not ever be necessary for all the individual fields to be saved,
 only a few key totals will be eventually stored if a quote is finalised so I
 am looking for a quick way of storing the page if the quote is in progress
 and has to be left,

Don't save whole pages, just the unique portion of the pages: those totals. 
Then when the person returns, generate the page as usual, plugging in any 
stored values you have for him/her. You'll need a way to uniquely identify 
the user, so that id can be linked back to the right set of stored data.  
Sessions are perfect for this http://php.net/session.  Or, if you had no 
concern about the implications of client-side storage, you could use JS to 
store the values directly in a cookie.

-- 
CC

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




Re: [PHP] class instance name

2002-04-01 Thread CC Zona

   or are you referring to this?
  
   http://www.php.net/manual/en/function.get-class.php

  (a function that I keep forgetting about)
  No because it isn't the name of the class I want it is the name of the
  instance of the class...

 ahh! so the variable name then? don't think you can, unless it's passed to
 the object manually

(Untried, but FWIW--) I suppose you could loop through all defined vars, 
testing whether they are objects, then asking each if the name of its class 
is the same as the name of the current class...but why would one need this 
info?

-- 
CC

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




[PHP] Re: gettext functionality needs configuration flag

2002-03-29 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Thalis A. Kalfigopoulos) wrote:

 Someone with the proper authority should probably put on the manual pages 
 that to get the gettext functionality you have to configure with the 
 --with-gettext flag.

Did you know that anyone is allowed to add an annotation to the manual?  
For instance, if you go to http://php.net/gettext, you'll see several 
user-contributed comments (directly below the official text).  At the top 
and bottom of that block is a image of a plus sign and an image of a 
question mark; click on the plus sign to add your own note to the page.

-- 
CC

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




[PHP] Re: global vars in a function

2002-03-29 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Justin French) wrote:

 Am I missing something? I'm trying to use vars set in my config.php file in
 a function, and can't seem to do it without using $GLOBALS[varname] 
snip
 Is there a way to make global vars available in each function, or is this
 just the way things go?

PHP scope rules are different from C and other languages; you must use the 
'global' keyword.  See 
http://www.php.net/manual/en/language.variables.scope.php for more info.

-- 
CC

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




[PHP] Re: assert in php.ini setting.

2002-03-23 Thread CC Zona

In article Pine.LNX.4.20.0203231339370.28994-10@Larry,
 [EMAIL PROTECTED] (S.Murali Krishna) wrote:

 can any one tell me what is this 
 
 ;assert.active= On  ; assert(expr); active by default
 ;assert.warning   = On  ; issue a PHP warning for each failed
 ;assert.bail= Off ; don't bail out by default.
 ;assert.callback  = 0 ; user-function to be called if an assertion
 ;assert.quiet_eval  = 0 ; eval the expression with current
 
 
 setting in my php.ini file, I don't know what it is for, and it has been
 commented. 

http://www.php.net/assert
http://www.php.net/assert-options

-- 
CC

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




[PHP] Re: dealing with # in urls

2002-03-07 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Mark) wrote:

 in php.ini there is a variable called arg separator.input that looks 
 like it can help but when I add the line:
 
 arg separator.input = #
 
 I still get $id = 0#top

Did you restart the server after modifying php.ini?

As for http://mysite.com/test.php?id=0#top; sometimes resulting in id='0' 
and sometimes id='0#', perhaps this is a situation where letting PHP 
register the globals automatically is not the way to go.  You could instead 
extract the query string from the URL by using parse_url() 
http://php.net/parse-url, then turn that query string into variables by 
using parse_str() http://php.net/parse-str.

-- 
CC

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




[PHP] Re: Value of $_* variables

2002-03-05 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (James Taylor) wrote:

 $result = mysql_query(select user from users where id = $_SESSION['id], 
 $db);
 
 That just doesn't work, so I have to first go:
 
 $sid = $_SESSION['id'];
 $result = mysql_query(select user from users where id = $sid, $db);
 
 Anyway to get around this?

Curly braces:

$result = mysql_query(select user from users where id = 
{$_SESSION['id']}, $db);

-- 
CC

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




Re: [PHP] Re: Value of $_* variables

2002-03-05 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jason Wong) wrote:

  echo $doo[dah]; # is correct

If constant 'dah' is defined, and its value is the name of the key you wish 
to access from array '$doo'.  But if the string literall 'dah' is itself 
the name of the key you are trying to access, then the above is *not* 
correct.  For that, use:

  echo $doo['dah']; # is correct

or

echo $doo[dah]; # also correct

-- 
CC

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




[PHP] Re: Help with functions.

2002-02-28 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Sean Kennedy) 
wrote:

 I need some help with functions. Does anyone know of a good place to learn 
 about functions?

http://www.php.net

  Will someone be willing to teach me what I need to know about 
 functions in PHP?

If you find after reading that that you still need help, posting specific 
questions here will usually get a quick, helpful response.

-- 
CC

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




[PHP] Re: Reading a conf file

2002-02-27 Thread CC Zona

In article 01af01c1bfd7$be373ed0$0200a8c0@wiaka,
 [EMAIL PROTECTED] (Brandon Orther) wrote:

 Does anyone have a good idea of how I can pull the info out of a conf
 file setup like this?  Maybe pull it into an array.
  
  
 ## Conf File ##
 ServerName
 domain.websites.com
 /ServerName
 ServerName
 newsite.worldwideweb.net
 /ServerName

http://www.php.net/file

-- 
CC

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




[PHP] Re: global variables w/o access to global php.ini

2002-02-27 Thread CC Zona

In article Pine.WNT.4.44.0202271857090.3884-10@associate,
 [EMAIL PROTECTED] (Timothy J. Luoma) wrote:

 I have a virtual domain under Apache and do not have access to the global
 php.ini file
 
 Apache lets me set site-wide configuration in an /.htaccess file
 
 Is there something similar for PHP?

Forget similar, you can set PHP config options in the .htaccess file 
itself.  See http://php.net/configuration.

You can also set PHP options on a per-script basis using the ini_set() 
function http://php.net/ini-set.

-- 
CC

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




[PHP] Re: global variables w/o access to global php.ini

2002-02-27 Thread CC Zona

In article Pine.WNT.4.44.0202272245210.1448-10@associate,
 [EMAIL PROTECTED] (Timothy J. Luoma) wrote:

   I have a virtual domain under Apache and do not have access to the global
   php.ini file
  
   Apache lets me set site-wide configuration in an /.htaccess file
  
   Is there something similar for PHP?
 
  Forget similar, you can set PHP config options in the .htaccess file
  itself.  See http://php.net/configuration.
 
 Thanks for your reply.
 
 I'm afraid I did a poor job of asking my question(*).  My apologies.
 
 I would like to set some variables of my own creation (ie $DOMAIN_NAME) on
 a global basis.

In that case, the auto_prepend_file config option may be of interest.  
It's described on the page previously mentioned.

-- 
CC

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




[PHP] Re: regex

2002-02-27 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Paul A. Procacci) wrote:

 ticket_id=3change_name=statuschange_value=3ticket_id=32=1=
 
 And all I want is 2=1=.  Well, the closest I came was :
 
 $string = preg_replace(/[^0-9]+\=/, , $QUERY_STRING);  Assuming 
 QUERY_STRING was the data.

$string=preg_replace(/[^0-9]+=[^]/, '', $QUERY_STRING);

-- 
CC

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




[PHP] Re: unsetting global variables from an function

2002-02-27 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Enrico Weigelt) wrote:

 is there a way for unsetting an global variable from an function ?
 
 global $var; unset ( $var );
 
 does not work since, unset only removes the reference in from 
 local namespace. but i need to remove it from the global one.
 
 any chance to do it ?

Instead of using the 'global' keyword, use the $GLOBALS array:

$var='foobar';

function gUnset()
   {
   echo BEFORE: {$GLOBALS['var']};
   unset($GLOBALS['var']);
   echo AFTER: {$GLOBALS['var']};
   }

gUnset();

-- 
CC

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




[PHP] Re: Changing arguments in the php.ini file

2002-02-25 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Kostas Karadamoglou) wrote:

 When I change an argument from off to on and then restart the Apache server 
 the php.info() function displays thats no changes took place.
 Exambles like register_global and display_errors.
 I dont know what is wrong any idea?

When you call phpinfo(), look for the line near the top which gives the 
path to the current php.ini file.  Does it match the path to the file you 
are altering?

-- 
CC

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




[PHP] Re: multilanguage support

2002-02-25 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Leonid Zilber) wrote:

 On our site, we have page with a form a user puts his/her information such
 as company name, givenname, etc. Currently, if a name entered is anything
 but English characters, PhP fails.
 
 For example, if I enter Norwegian characters lsløæ PhP returns the following
 errors:
Last name field must contain a valid last name
 etc.

That doesn't sound like a PHP error, but rather a custom message from your 
application's developer, based on his/her assumptions about what 
constitutes valid text input.

-- 
CC

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




[PHP] Re: Is there a way to put a scroll in a table ???

2002-02-25 Thread CC Zona

In article 
[EMAIL PROTECTED],
 [EMAIL PROTECTED] (J.F.Kishor) wrote:

   I'am breaking my head by trying to put a scroll in a table, 
 my problem is, using php 'am trying to display a report and the report
 should have three tables, data to display are taken from three different
 tables and number of rows returned are three different values, the number
 of rows returned may be 10, 100 or more then 100, since I have to show
 all three table in a single form, I have decided to display five rows in
 each table, so I need to put a scroll in all the tables through which the
 user could scroll till the last records.
 
 1. Is there any other solution to solve it out ?
 2. Is there a way to put a scroll in a table ?
 
 I tried using layers and its working fine in Internet explorer, and in
 Netscape the scroll does'nt work.

The tbody,thead, and tfoot elements of HTML 
http://www.w3.org/TR/html4/struct/tables.html#h-11.2.3 are intended for 
this purpose, but you may not consider browser support to be sufficient.  
See http://www.blooberry.com/indexdot/html/tagpages/t/tbody.htm, for 
instance.

-- 
CC

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




[PHP] Re: php 4.1.1 vs 4.0.6

2002-02-22 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Ezra Nugroho) wrote:

 I am deciding between 4.0.6 and 4.1.1 (or maybe 4.1.2 if it's comming soon).
 I heard that there is some significant difference between 4.0.x and 4.1.x
 What is the main difference between 4.0.6 and 4.1.1 ?
 Are the 4.1.x completely backward compatible with 4.0.x?

http://www.php.net/release_4_1_0.php

-- 
CC

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




[PHP] Re: unable to process form data

2002-02-21 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jeremy Reed) wrote:

 I was able to fix the 'unable to find dynamic etc.' error thanks to you
 guys.  Now I have a new problem.  It seems that I am unable to process form
 data.  Before upgrading to 4.1.1, you were able to refer to the form data
 simply by concatenating a '$' and the form element name i.e.

As of 4.1, you need to use the new arrays $_GET, $_POST, $_COOKIE, etc. or 
else turn register_globals back on. See 
http://www.php.net/release_4_1_0.php for more info.

-- 
CC

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




[PHP] Re: gzip?

2002-02-21 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jtjohnston) wrote:

 What header do I type to gzip something out on the screen? To make the
 output go faster, such as this text output:
 http://ccl.flsh.usherb.ca/db/export_to_nb_format.php
 I don,t want to actually zip the output, just make it go faster. Someone
 once told me I could do that so the server spits output faster.

http://www.php.net/manual/en/ref.outcontrol.php
http://www.php.net/ob-gzhandler

-- 
CC

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




[PHP] Re: Removing every thing between ( )

2002-02-20 Thread CC Zona

In article 001901c1ba5d$634e3840$89010a0a@bpaulson,
 [EMAIL PROTECTED] (Brian Paulson) wrote:

   What would the regular expression be to remove all the text
 between  (  )
 
 $string = This is a (001 Test) and (002 Test);

$string=preg_replace(/\(.+\)/U,'',$string);

Note that leading/trailing spaces are left in, and the parens are dropped, 
so you may want to adjust it a bit.

-- 
CC

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




[PHP] Re: argh!

2002-02-19 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Richard Baskett) wrote:

 Ok this is getting frustrating!  I am serializing a variable and passing it
 through the url, in the url and when I echo it on the next page it shows
 s:608:, and when I unserialize it and echo it, it doesnt show anything!  How
 can I pull that data out in the next page?

That looks like the full serialization didn't make it through.  After you 
serialize, you also have to urlencode() the serialized value before passing 
it through the url.

-- 
CC

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




[PHP] Re: preg_match vs ereg etc

2002-02-18 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Digitalkoala) wrote:

 I was just wondering what your opinions were on using preg_match, preg_split
 instead of ereg and explode?
 
 I have to write a  script to parse a lot of html and text files.. and I'm
 looking to use the fastest possible functions to do this...

preg_match() vs. ereg(): preg_* functions are supposed to be siginficantly 
faster than their ereg_* equivalents, so preg_match() should be the 
winner here.

preg_split() vs. explode(): these aren't equivalent functions.  The 
former splits on a regular expression; the latter splits on a string value.

-- 
CC

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




[PHP] Re: Frustrating ?

2002-02-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jtjohnston) wrote:

 Heres's a frustrating, and maybe not so stupid question?
 
 I'm getting Warning: Supplied argument is not a valid MySQL result
 resource on this line:
 
 while ($mydata = mysql_fetch_object($news))
 
 So what am I doing wrong here:
 
 $where = id like $id;
 $news = mysql_query('select * from ccl where '.$where.' order by AU
 desc'); //desc = z-a

A) Have you already confirmed that a valid database connection was made?

B) String values in mysql have to be quoted.  For example, where 
foo='bar' or where foo like 'bar%'.

C) Error checking on database operations is a really good idea.  Even just 
a short or die() on the mysql_* calls can help you track down problems 
much more effectively.  For example:

$result=mysql_query($sql) or die(MySQL reports error: . mysql_error() .  
for query  . htmlentities($sql));

For more sophisticated error handling, see 
http://www.php.net/manual/en/ref.errorfunc.php.

-- 
CC

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




[PHP] Re: More: Frustrating ?

2002-02-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Jtjohnston) wrote:

   $where = id like $id;
snip
 So I do?
 
 $news = mysql_query(select * from ccl where '.$where.' order by AU desc);
 
 or ?
 
 $news = mysql_query(select * from ccl where '.%$where%.' order by AU desc);

Neither.  Where $id==1, these would interpolate to:

select * from ccl where '.id like 1.' order by AU desc
select * from ccl where '.%id like 1%.' order by AU desc

This is why repeaterror checking with an echo of your query to the 
browser/repeat is valuable.  You can see exactly what the complete query 
string looks like, and also copy/paste it to the commandline for further 
testing.

 The % are not necessary? because id is an auto_increment number from 0 to
 1,000+.

The like keyword is used with a wildcard operator, either % or _.  If 
you're matching against an exact value, then use the = operator instead 
of like.  See the MySQL manual for more info on the like keyword and 
wildcards.

If id has a numerical field type instead of one of the string types, you 
don't need to quote $id. See the MySQL manual for more info on quoting 
string values.

-- 
CC

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




[PHP] Re: storing arrays

2002-02-16 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Clark) wrote:

 1) Is it possible to write an array to a file?

http://php.net/serialize
http://php.net/fopen
http://php.net/fwrite


 2) Is it possible to specify the name of the key to each item of an array
 when you get the array using file().

You can take the array returned by file() and manipulate its keys however 
you want.  But beforehand...?  No.

-- 
CC

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




[PHP] Re: Implement @-domains with PHP?

2002-02-12 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Christian Blichmann) wrote:

 My problem is much more trivial, how to retrieve the string the user 
 type into the address bar of his/her browser???

You can look over the environment vars available to you with a quick call 
to phpinfo() http://php.net/phpinfo.

-- 
CC

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




[PHP] Re: PHP not parsed in HTML

2002-02-12 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Spyproductions Support Team) wrote:

 I am with a hosting company that doesn't want to parse PHP in HTML files
 because they are afraid it will slow down their server(s) too much.
 
 So.  I really like them and don't want to move the site if I don't really
 *have* to.  There are some neat things I would love to be doing in the HTML
 on it, though.
 
 I was thinking; could I make some sort of little javacript calling on, or
 including the PHP file I want to run on the HTML page?

Does the hosting company support server side includes (SSIs)?  If so, using 
!--#include virtual...-- syntax may be an option.

-- 
CC

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




[PHP] Re: Implement @-domains with PHP?

2002-02-12 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Christian Blichmann) wrote:

 Cc Zona [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  You can look over the environment vars available to you with a quick call
  to phpinfo() http://php.net/phpinfo.
 
 Thanks for replying, but as Philip stated in his reply to my question
 its that the actual location doesn't appear in the environment block.

That's true, the URL does not appear there as a single preset variable; 
it's up to you to re-assemble a URL out of the variables that are 
available, and thus the need to scan the vars phpinfo() has to offer.  
Since you're using PHP as a CGI, somewhat different variables get set than 
when PHP is run as a module, so a call to phpinfo() is the best way to 
identify the right vars for accomplishing your task.

Question: before you dismissed phpinfo() as useless, did you call it and 
look at what's there?  Because more than likely the info that you envision 
extracting in a two step process (access URL, break down into needed 
components) can be directly accessed from one or more environment/server 
vars.

-- 
CC

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




[PHP] Re: Implement @-domains with PHP?

2002-02-11 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Christian Blichmann) wrote:

 Anybody got some code how to access the first part of
 a URI (the string just before the @)? I don't want to use
 HTTP-authentication and I'm using Win2k with IIS as CGI...
 
 Example:
   http:[EMAIL PROTECTED]/myPathTo/myFile.ending
 
 I'd like to retrieve the http://someReallyWeirdAtDomain-part.

http://php.net/parse-url

-- 
CC

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




[PHP] Re: I'm new here is there.....

2002-02-09 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Cyberskydive) wrote:

 I know this php.general -  is there another newsgroup which specifically
 deals with help issues?

PHP General does deal with help issues.  Alternatively, you can post to 
news:alt.php.

-- 
CC

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




[PHP] Re: Table exists?

2002-02-09 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Nick Wilson) wrote:

 What would be the easiest way to see if a MySQL table exists with PHP?
 I can do it by checking against mysql_list_tables() but that seems a
 little clumsy. Is there a better way?

See MySQL's documentation of the CREATE TABLE and DROP TABLE syntax: 
both support table existance checks.

create table if not exists mytablename...
drop table if exists mytablename...

-- 
CC

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




[PHP] Re: !isset ??

2002-02-06 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Erik Price) wrote:

 Pretty confusing.  Can anyone shed some light on whether or not there is 
 a final definite way to do this?  I've used (!($_POST['var'])) with no 
 problems in the past, but does good coding style suggest that I use 
 (!isset($_POST['var'])) now?

!$somevar != !isset($somevar)

isset() evaluates as true only if the variable (or array index) exists.

PHP's loose typing means that !$somevar evalutes as true if the variable is 
null, if it has an (integer, float, or string) value of zero, if it's an 
empty string, or if it is set to boolean false. Or if the variable/index 
does not exist.

Both methods have their place (though for tests of the latter, I prefer 
empty()).  The important part is understanding the implications of a method 
when you use it, so that your code isn't wrongly relying on !$somevar to 
mean the variable isn't set; it may well have been set, to a meaningful 
value which just happens to evaluate to false.

-- 
CC

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




Re: [PHP] secure form handling

2002-02-06 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Obo) 
wrote:

  Sorry, perhaps I've misunderstood. You would like to charge a customer's
  card without the customer knowing how much you're charging them?

 i want the user to be able to see the amount being charged on the 
 screen, but not to be able to view it in a hidden field in the source 
 code. most shopping cart applications are like this.

What would be the point of that?  If they can see it onscreen anyway (as 
they should), why hide it in the source?

Could you point out some URLs where there are shopping carts like this?

-- 
CC

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




Re: [PHP] secure form handling

2002-02-06 Thread CC Zona

In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Wm) 
wrote:

 Cc Zona wrote:
 
  In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Obo)
  wrote:
 
Sorry, perhaps I've misunderstood. You would like to charge a customer's
card without the customer knowing how much you're charging them?
 
   i want the user to be able to see the amount being charged on the
   screen, but not to be able to view it in a hidden field in the source
   code. most shopping cart applications are like this.
 
  What would be the point of that?  If they can see it onscreen anyway (as
  they should), why hide it in the source?
 
  Could you point out some URLs where there are shopping carts like this?

 amazon.com
 vitaminworld

Many shopping carts track persistent data (including running totals) via 
cookies.  If you just want to know *how* to do what they do, the short 
answer is cookies http://php.net/sessions http://php.net/set-cookie.  
But I doubt any of them are doing so with the *intent* to prevent onscreen 
data from being viewable in the source.

-- 
CC

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




Re: [PHP] Re: Address unknown

2002-02-02 Thread CC Zona

In article 001001c1ac45$406eab00$017f@localhost,
 [EMAIL PROTECTED] (Hugh Danaher) wrote:

 Thank you for your help regarding parsing the url (Hey, go figure, they
 named the function almost exactly the same as my question.).
 
 I am still at sea about getting all the information from the url header.  If
 I leave the brackets empty [e.g. parse_url() ] I get an error saying I have
 a parameter mismatch.  When I fill the brackets with $query_string, I get an
 answer but it's in the form of an array.  Finally when I echo the array, the
 query string echos in the path slot.  Any ideas?
 Hugh
 
 $p=parse_url($QUERY_STRING);
 echo $p[host]. 1 .$p[path]. 2 .$p[query]. 3 ;

If you feed parse_url() something other than a URL (a query string being a 
URL *fragment* rather than a URL itself), it's not surprising that it will 
return weird results.

When you echo $QUERY_STRING, what value are you getting?  For...

  file:///C:/php/museum/DB MUSE/someplace.php?98,165

I'd expect it to be 98,165.  IOW, pre-parsed, no need to parse_url().

-- 
CC

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




  1   2   3   4   >