Re: [PHP] replacing multiple spaces with one

2002-07-15 Thread nico_free

Hellorgh !!

$ArticleText = ereg_replace("[[:space:]].*", " ", $ArticleText);
Should be fine... But AFAIK, using preg_replace should be faster, but I
don't know the exact syntax to solve your probem :-(
--
Nayco

- Original Message -
From: David Russell <[EMAIL PROTECTED]>
To: php-general <[EMAIL PROTECTED]>
Sent: Monday, July 15, 2002 6:15 PM
Subject: [PHP] replacing multiple spaces with one


> Hi all
>
> (easy one - I think)
>
> I need to replace all instances of multiple spaces in a string with a
> single space.
>
> I tries the following:
>$ArticleText = str_replace('  ', ' ', $ArticleText);
> but if I have four spaces, I am left with two - this is wrong...
>
> I am sure that I am really looking for a ereg_replace or preg_replace,
> but having no c/perl programming background, I do not know either perl
> or standard regex syntax.
>
> Could someone tell me what the correct ereg/preg expression for this
> would be? I would also like a pointer to regex syntax, if someone knows
> offhand.
>
> Thanks
>
> David R
>
>
> --
> 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




Tr: [PHP] New to PHP - Undefined variable: ??????

2002-05-01 Thread nico_free


- Original Message -
From: nico_free <[EMAIL PROTECTED]>
To: TGL <[EMAIL PROTECTED]>
Sent: Wednesday, May 01, 2002 11:47 PM
Subject: Re: [PHP] New to PHP - Undefined variable: ??


> Well, I think the first 2 lines of your script should be :
>
> echo "\$FILE : $FILE";
> var_dump($FILE);
>
> So, when submitting with no file, you should see some clues
>
> As far as I remember, your first test should be :
>
> <--code-->
> if($File!="none") {
>  print ("File name: $File_name\n");
> ...etc
> <--/code-->
>
> @
>
> - Original Message -
> From: TGL <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, April 30, 2002 10:44 PM
> Subject: [PHP] New to PHP - Undefined variable: ??
>
>
> > I'm new to PHP and can't get through my first script. I want to create a
> > form that will allow the user to attach a file. I started with the file
> > upload part of the form thinking that it ould give me the most problem,
> and
> > it has.
> >
> > This is the error message that shows when I view the page in the
browser:
> >
> > Warning: Undefined variable: File in
> > D:\inetpub\thegospellady\www\kia\form.php on line 8
> > here is the url to the form: http://www.thegospellady.com/kia/form.php
> >
> > Please help.
> >
> >  > /* This next conditional determines whether or not to handle the form,
> > depending upon whether or not $File exists. */
> > if($File) {
> >   print ("File name: $File_name\n");
> >   print ("File size: $File_size\n");
> >   if(copy($File, "/users/$File_name")) {
> >print ("Your file was successfully uploaded!\n");
> >   } else {
> >print ("Your file could not be copied.\n");
> >   }
> >   unlink($File);
> > }
> >
> > print ("Upload a file to the server:\n");
> > print (" > ENCTYPE=\"multipart/form-data\">\n");
> > print ("File \n");
> > print ("\n");
> > ?>
> >
> >
> >
> > --
> > 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] Submitted form doesn't work

2002-05-28 Thread nico_free

Helllorgh,  !!!

I've got a strange problem...

Look at this pseudo-script (news.php) :

--





 
  etc
   
   
   
   
   . and the submit, plus 1 or 2 others...
 



--

Well, this worked fine for nearly a year now, (and still works),  when this
script was named "news.php3", but I wanted to use the "ob_" functions ...
So, a few days ago, I renamed the script in "news.php", added a few lines of
code to add one or two enhancements (I don't think they are a problem), and
now, there is now way to post a "news".
What is happening : I tested this script at home (EasyPHP under windows),
everything worked fine, I was able to post some "news", check for the
correct displaying, correct it if necessary, and then, by checking the
"final version" checkbox, send it definitely.
Well, quite happy at 2 am (:-)), I uploaded it on my provider's server
(Recently upgraded with PHP4.xxx), but there, nothing is working !!!
The script acts as if no (or not enough) field was filled, thus diplaying
the old news, but not the newly posted...
Adding ' echo "\$text : $text\n"; ' shows that the script doesn't see
the posted fields, and the form stays empty (Should display the submitted
values for correction) !!!
The only way to get it to work has been to rename the script in "news.php3",
then commenting the "ob_..." functions (I discovered that extension is
version :-)), and it now works fine !!!
Well, I'd really like to use the "ob_" functions, and simply know where goes
the posted stuff with PHP4... As I've got some other scripts written in PHP4
(".php") with the same kind of programming that work fine on the same server
!!!

Finally, i'm making some tests by replacing "$text" and "$title", etc...,
with $_POST["text"], $_POST["title"], as I've read that it is now standard
and secure programming (Can someone confirm, please ??? Are "$vars"
deprecated ???).
Well, the result is nearly the same no displaying, but the form stays
filled.

Sorry for that ong mail, but I tried to tell the maximum, so maybe
one sees immediately the problem...
Thanx, @+++



 Nayco.

(°-  [EMAIL PROTECTED]
//\  http://refreship.free.fr, redirection pour l'hebergement ADSL.
v_/_ Http://luxregina.free.fr, Forum Live.



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