Re: [PHP] Re: [PHP-DB] Fatal error: Call to undefined function: pg_connect() in .....

2002-07-18 Thread Rick Widmer

At 11:02 PM 7/18/02 -0300, you wrote:
Is PostgreSQL started with the -i switch? (I think that's the one; it 
exposes it to tcp/ip connections.)  Check your PGSQL docs to be certain.

This is not the problem.


Have you run a page with phpinfo? Is PostgreSQL support compiled into your 
installation of PHP? This is a file consisting of
? phpinfo(); ?, named phpinfo.php. Again, I'm doing this from memory but 
I'm pretty certain of the function name.

phpinfo() is correct, but not needed.

Call to undefined function means that PHP was not compiled with this 
function.

Your best bet is to trash the RPM and compile PHP and possibly Apache from 
the distribution tarball.  You can bang you head against various 
combinations of RPMs for weeks and never find the right combination, or 
spend a couple hours collecting the requirements and learning to compile 
the source.  Once I got it down I can compile OpenSSL, Apache, ModSSL PHP 
and all the goodies that go along with it in about 45 minutes, and I don't 
even have to be there for most of it.  I've got a script that compiles it 
with all the options I chose.   I just collect the latest versions, check 
for new options I might want to use, plug the new version numbers into the 
top of the script, run it and go find something else to do while it runs.

Rick


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




[PHP] modify an element of a HTML tag within a string

2002-07-18 Thread Justin French

Hi all,

I've asked simular questions before, but I think I'm finally asking the
*right* question to get the right answer.

I'm look for some suggestions on the best method of parsing a HTML document
(or part thereof), with the view of CAPTURING and MODIFYING a specific
element of a specific tag.

something like:

1. look for a given tag eg DIV
2. capture the tag (everything from 'DIV' up to the '')
3. look for a given attribute (eg ID=foo, ID=foo, ID='foo' -- all valid
ways)
4. capture it
5. be given the opportunity to manipulate the attribute's value, delete it,
etc
6. place captured tag (complete with modifed elements) back into the string
in it's original position
7. return to step 1, looking for the next occurence of a DIV tag


I really don't know where to start.  I REALLY don't expect someone to write
this for me, just some guidance would be great -- or maybe some inspiration
:)


I guess what I'd like to be able to do, in pseudo code is:


while (getTag('DIV',$myHTML))
{
while(getAttribute('ID'))
{
// manipulate
if($attribute == foo)
{
$attribute == foo2;
}
}
}


while (getTag('DIV',$myHTML))
{
while(getAttribute('ID'))
{
deleteAttribute();
}
}


The solution might be a helluva lot more complex, or may be OOP based.


Any inspiration/links/words of wisdom?


Justin French


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




Re: [PHP] rebooting linux using php

2002-07-18 Thread Jason Wong

On Friday 19 July 2002 04:26, Scott Fletcher wrote:
 If you're going to use the cron file (or crontab) then php wouldn't work
 because it is a programming languages for the web pages.  For cron files or
 crontab, you can use the bash shell or ksh or whatever you have.  It's
 simple.  All you had to do is to create a file on hte Unix/Linux machine
 and do the following ...

John's reply was meant to show that it is a very bad idea to allow someone 
reboot the server from a webpage (without the proper safeguards). If he had 
URL he could setup a cron job which would reboot the OP's computer every 
minute and that _wouldn't_ be fun.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
The Public is merely a multiplied me.
-- Mark Twain
*/


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




Re[2]: [PHP] Re: Cookies - good or bad???

2002-07-18 Thread Evgeny Chuykov

Justin French wrote:

JF As has been said on this list MANY times, just have a look at the big sites
JF like amazon.com -- no cookies, no javascript, no reliance on client-side for
JF anything.  Take care of it all server-side, where you have a controlled
JF environment.

And what about yahoo.com? Is it big enough? :)

-- 
Best regards,
 Evgeny


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




RE: [PHP] Password in script

2002-07-18 Thread Jonathan Rosenberg

Yes, but if you're on a shared server, other users of the user will likely
be able to read your PHP files  get the password.

 -Original Message-
 From: Tyler Longren [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 18, 2002 23:10 PM
 To: Sailom
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Password in script


 It's fine.  There's no other way to do it really.  Somebody would have
 to be able to see the source to the php file before they could see the
 password for mysql.  They won't get it just by viewing the webpage
 that's already been parsed by php.

 --
 Tyler Longren
 Captain Jack Communications
 [EMAIL PROTECTED]
 www.captainjack.com



 On Fri, 19 Jul 2002 10:03:02 +0700
 Sailom [EMAIL PROTECTED] wrote:

  I am new to PHP and MySQL and never have experience in this area.  I
  am writing a PHP script that connects to MySQL server.  I have to put
  a password of MySQL into the PHP script.  I think it may not be
  secured.  What do you think?  How can I make it more secure?  Thanks.
 
 
 
  --
  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] Loading a File into Variable - How??

2002-07-18 Thread Monty

Andre, here's the function that worked for me...

function file_get_contents($filename) {
$fd = fopen($filename, r, 1);
$contents = fread($fd, 12000);
fclose($fd);
return $contents;
}

$page_string = file_get_contents(my_file.php);


The third parameter in fopen() [1] can be removed if you don't want to look
for files in your include_path. The second parameter in fread() [12000] is
where I hardcoded the filesize. Increase that number if you'll be opening
larger files.

Originally I had 12000 replaced with filesize($filename) but if the
$filename was opened from the include_path, this seems to always return
zero, which is why I hardcoded the byte size into fread().

Monty


 From: [EMAIL PROTECTED] (Andre Dubuc)
 Reply-To: [EMAIL PROTECTED]
 Newsgroups: php.general
 Date: Thu, 18 Jul 2002 17:45:14 -0400
 To: Monty [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Loading a File into Variable - How??
 
 Hi Monty,
 
 I've been trying to do the same thing with no success. Would you be so kind
 as to show me how you finally did it? I'm not too clear what you meant by:
 
 So, if I replace the filesize($filename) command with a hard-coded number,
 it works.
 
 Tia,
 Andre
 
 On Thursday 18 July 2002 04:28 pm, you wrote:
 I just want to load an entire file into a
 single string variable.
 
 However, I figured out the problem shortly after posting that first message
 (of course). Because the file being opened is in the include_path, it seems
 filesize() doesn't see those files. So, if I replace the
 filesize($filename) command with a hard-coded number, it works.
 
 Monty


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




Re: [PHP] Loading a File into Variable - How??

2002-07-18 Thread Monty

Hi Rasmus,

file_gets_contents() doesn't work in my version of PHP (4.2.1). It says not
a valid function or something like that. Also, I discovered that the
filesize() function won't work on files fopened from the include_path. It
returns a value of zero, so, I had to hardcode the bytes into the fread().


 From: [EMAIL PROTECTED] (Rasmus Lerdorf)
 Newsgroups: php.general
 Date: Thu, 18 Jul 2002 15:14:13 -0700 (PDT)
 To: Analysis  Solutions [EMAIL PROTECTED]
 Cc: PHP List [EMAIL PROTECTED]
 Subject: Re: [PHP] Loading a File into Variable - How??
 
 In 4.3 you would use file_get_contents()
 
 In prior versions I would suggest:
 
 $fp = fopen('filename','r');
 $string = fread($fp, filesize('filename'));
 fclose($fp);
 
 The implode(file()) stuff is very memory-inefficient.
 
 -Rasmus
 


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




[PHP] Passing variables to page via POST - How?

2002-07-18 Thread Monty

This is probably more of an HTML question... Is there a way to pass
variables to another page via POST instead of via the URL? I need to pass
several variables, one that is an array and another that is a fairly long
string, so, I can't really do this via the URL.

My initial idea was to just create a very simple form that only has hidden
fields with the data I want to pass, along with an image Submit button that
would call the page and pass the hidden field variables.

Is that the only/best way to accomplish this?

Thanks.

Monty
 


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




[PHP] Re: modify an element of a HTML tag within a string

2002-07-18 Thread Monty

Okay, this is just very general info to help point you in the right
direction, but, here are some functions you'll probably need to accomplish
this:

  * Regular Expressions
  * pregi() and/or eregi()
  * explode() and implode()
  * str_replace()

Regular expressions will probably be the most important part of doing what
you need to do. If you don't already know how they work, they are hard to
grasp at first, but, very useful once you understand their purpose.

Monty


 From: [EMAIL PROTECTED] (Justin French)
 Newsgroups: php.general
 Date: Fri, 19 Jul 2002 13:50:08 +1000
 To: php [EMAIL PROTECTED]
 Subject: modify an element of a HTML tag within a string
 
 Hi all,
 
 I've asked simular questions before, but I think I'm finally asking the
 *right* question to get the right answer.
 
 I'm look for some suggestions on the best method of parsing a HTML document
 (or part thereof), with the view of CAPTURING and MODIFYING a specific
 element of a specific tag.
 
 something like:
 
 1. look for a given tag eg DIV
 2. capture the tag (everything from 'DIV' up to the '')
 3. look for a given attribute (eg ID=foo, ID=foo, ID='foo' -- all valid
 ways)
 4. capture it
 5. be given the opportunity to manipulate the attribute's value, delete it,
 etc
 6. place captured tag (complete with modifed elements) back into the string
 in it's original position
 7. return to step 1, looking for the next occurence of a DIV tag
 
 
 I really don't know where to start.  I REALLY don't expect someone to write
 this for me, just some guidance would be great -- or maybe some inspiration
 :)
 


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




[PHP] Re: modify an element of a HTML tag within a string

2002-07-18 Thread Richard Lynch

I've asked simular questions before, but I think I'm finally asking the
*right* question to get the right answer.

That's often the tricky part :-)

I'm look for some suggestions on the best method of parsing a HTML document
(or part thereof), with the view of CAPTURING and MODIFYING a specific
element of a specific tag.

something like:

1. look for a given tag eg DIV
2. capture the tag (everything from 'DIV' up to the '')
3. look for a given attribute (eg ID=foo, ID=foo, ID='foo' -- all valid
ways)
4. capture it
5. be given the opportunity to manipulate the attribute's value, delete it,
etc
6. place captured tag (complete with modifed elements) back into the string
in it's original position
7. return to step 1, looking for the next occurence of a DIV tag

If you are only looking for a SPECIFIC tag, you just simplified life
immensely!

?php
  # Get some beautiful sample HTML:
  $html = file('http://php.net/') or die(Could not open php.net);
  $html = implode('', $html);
  
  # Find the DIV tag:
  $div = stristr($html, 'div');
  $divpos = strlen($html) - strlen($div);
  
  # Break the HTML up into before and after DIV tag:
  $before_div = substr($html, 0, $divpos);
  $after_div = substr($html, $divpos);
  
  # Find the *END* of the DIV tag:
  # KNOWN BUG:
  # They *could* bury a  in their attributes if they work at it...
  $end_tag = strstr($after_div, '');
  $endpos = strlen($after_div) - strlen($end_tag);
  $div = substr($after_div, 0, $endpos);
  
  # Now get the after part to *really* be after the *WHOLE* DIV tag:
  $afterdiv = substr($after_div, $endpos);
  
  echo Before DIV tag: BR, htmlentities($before_div), HR\n;
  echo DIV tag itself: BR, htmlentities($div), HR\n;
  echo After DIV tag:  BR, htmlentities($after_div), HR\n;
?

I can pretty much guarantee that I didn't put a +1 or -1 somewhere where it
belongs in the substr() function calls.  I never get that right in my first
pass of coding.  You'll have to fine-tune that part yourself.

But you can now do the same technique to search inside of $div for the ID
attribute, pretty much.

The solution might be a helluva lot more complex, or may be OOP based.


Any inspiration/links/words of wisdom?

If you need to do this for any arbitrary tag all at once, there *HAVE* to be
PHP-based HTML parsers out there in the various PHP script archives...

If all else fails, the PHP source for http://php.net/strip_tags must have
some kind of HTML parsing routine in it.

-- 
Like Music?  http://l-i-e.com/artists.htm


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




Re: [PHP] rebooting linux using php

2002-07-18 Thread Richard Lynch

On Friday 19 July 2002 04:26, Scott Fletcher wrote:
 If you're going to use the cron file (or crontab) then php wouldn't work
 because it is a programming languages for the web pages.  For cron files or

[Perhaps there was even more text missing that made this all out of
context... Sorry.]

I missed other parts of this thread, but I have to say Bull$#!^ to the idea
that you need to use some language other than PHP for your cron jobs and/or
shell scripting.

I routinely use PHP for *all* my shell/cron scripts.

It saves me hours of time, what little hair I have left, and the aspirin I'd
have to down if I was using Perl or some shell script language.

Sure, if it's a one-line cron job to a shell command, I'll use the command
directly.  If I have to think about it any more than that -- with a loop or
any db access or anything remotely complicated, it's PHP.

If you already know Perl or shell scripting, knock yourself out.

If you don't save yourself a lot of pain and suffering and just ./configure
PHP as a CGI (or CLI now) and use #!/usr/bin/php -q

-- 
Like Music?  http://l-i-e.com/artists.htm


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




[PHP] Re: Passing variables to page via POST - How?

2002-07-18 Thread Anup

Hey, I'm new, but I have some advice.
Do you have to POST? becuase you can use sessions, and PHP has a bunch os
session functions.
Secondly, POST will not attach any variables to the URL, this is done by
GET.
To access the POST variables traverse through the $HTTP_POST_VARS (or $_POST
array, i think) to retrieve your values.
But if you can try using sessions, more secure, and as easy to use as POST,
just traverse $HTTP_SESSION_VARS.
Monty [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 This is probably more of an HTML question... Is there a way to pass
 variables to another page via POST instead of via the URL? I need to pass
 several variables, one that is an array and another that is a fairly long
 string, so, I can't really do this via the URL.

 My initial idea was to just create a very simple form that only has hidden
 fields with the data I want to pass, along with an image Submit button
that
 would call the page and pass the hidden field variables.

 Is that the only/best way to accomplish this?

 Thanks.

 Monty





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




Re: [PHP] Password in script

2002-07-18 Thread Sailom

I just checked grant and it said something like...
GRANT USAGE ON *.* TO 'X'@'%' IDENTIFIED BY .
Does this means user named 'X' can log in from any server?  This may be
a silly question.


Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Yes, but if you're on a shared server, other users of the user will likely
 be able to read your PHP files  get the password.

  -Original Message-
  From: Tyler Longren [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, July 18, 2002 23:10 PM
  To: Sailom
  Cc: [EMAIL PROTECTED]
  Subject: Re: [PHP] Password in script
 
 
  It's fine.  There's no other way to do it really.  Somebody would have
  to be able to see the source to the php file before they could see the
  password for mysql.  They won't get it just by viewing the webpage
  that's already been parsed by php.
 
  --
  Tyler Longren
  Captain Jack Communications
  [EMAIL PROTECTED]
  www.captainjack.com
 
 
 
  On Fri, 19 Jul 2002 10:03:02 +0700
  Sailom [EMAIL PROTECTED] wrote:
 
   I am new to PHP and MySQL and never have experience in this area.  I
   am writing a PHP script that connects to MySQL server.  I have to put
   a password of MySQL into the PHP script.  I think it may not be
   secured.  What do you think?  How can I make it more secure?  Thanks.
  
  
  
   --
   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




[PHP] Help with sockets

2002-07-18 Thread Jeremy

How can I do the following with PHP?

1) Accept more than 1 connections without forking
2) socket_read and fgets from 2 connections at the same time

please help!
thanks in advance





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




RE: [PHP] Truncate ::: DAM!!!!!

2002-07-18 Thread Rudolf Visagie

str_replace() is faster and better for simple string replacement.

-Original Message-
From: vins [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 18, 2002 9:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Truncate ::: DAM!


LOL..
So after my last post about updating files i sat and thought about all the
replies i got... and then a slap on the head solved the DUH problem
ereg_replace(\r\n, \n, $DBfile);
I mean. i am a dork as the best of times..

but now there is another problem

the file length is 10 charactes but the new file length is 15
I need to overright everything in the old file and somehow push the file
length to 15
it truncates.what now ???



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

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




[PHP] Re: Password in script

2002-07-18 Thread Monty

The password code will be parsed out by PHP, so, it won't be viewable in the
HTML source delivered to the browser.

Some advice: set up a user for your database that has the minimal amount of
access necessary to perform queries or writing to the database and use that
in your scripts. Don't ever use your master MySQL username and password.

Monty


 From: [EMAIL PROTECTED] (Sailom)
 Newsgroups: php.general
 Date: Fri, 19 Jul 2002 10:03:02 +0700
 To: [EMAIL PROTECTED]
 Subject: Password in script
 
 I am new to PHP and MySQL and never have experience in this area.  I am
 writing a PHP script that connects to MySQL server.  I have to put a
 password of MySQL into the PHP script.  I think it may not be secured.  What
 do you think?  How can I make it more secure?  Thanks.
 
 


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




[PHP] Re: Accessing Ports

2002-07-18 Thread Thomas \omega\ Henning

And what kind of permissions might that be? (server side)
Richard Lynch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 Can i access my paralel or USB port with PHP server side?

 The client's (browser's) parallel or USB port?  No.  See PHP  HASP
thread.

 If the web-server has a parallel or USB port and you want to access that,
 probably, if you have (or can get) sufficient permissions from the OS for
 PHP to do so.

 --
 Like Music?  http://l-i-e.com/artists.htm




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




Re: [PHP] Password in script

2002-07-18 Thread Richard Baskett

Ok I am going to give out my little secret that was passed to me.  Your
worry is warranted in my opinion especially since let's say your isp is in
the middle of an upgrade or something happens to php that breaks it.. Now
your php code is being shown as regular text.. Anybody can see your code.
There are a lot of things that could possibly go wrong.. Maybe an error
happens and it shows where you have the error and it shows your username and
password.. So many things.. So use an external file that is below your
htdocs/www/public_html directory.  I usually use a directory called
phpinc/php_inc/php.  Call it whatever you want :) and then put a file in it
called say.. query.inc

query.inc
?
  function queryDB ($query) {
$connect = mysql_pconnect('host', 'username', 'password');
$result = mysql_db_query('database',$query,$connect);
if ($result) {
  return $result;
} else {
  echo h1Error in Query/h1;
  echo Query: \$query\br /;
  echo mysql_errno($connect).: font
color=\red\.mysql_error($connect)./fontbr /;
  exit;
}
  }
?

Include this file within any file that will be doing database queries. Then
whenever you want to make a call to the database use this syntax:

$result = queryDB(YOUR SQL QUERY HERE);

Plus it will show you where you are getting your mysql errors when you have
them.  It's a great little function.. Thank you John Ash! :)  Gotta give
credit where it's due :)

I hope it helps!

Cheers!

Rick

He who is devoid of the power to forgive is devoid of the power to love. -
Dr. Martin Luther King, Jr.

 From: Sailom [EMAIL PROTECTED]
 Date: Fri, 19 Jul 2002 11:33:59 +0700
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] Password in script
 
 I just checked grant and it said something like...
 GRANT USAGE ON *.* TO 'X'@'%' IDENTIFIED BY .
 Does this means user named 'X' can log in from any server?  This may be
 a silly question.
 
 
 Jonathan Rosenberg [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Yes, but if you're on a shared server, other users of the user will likely
 be able to read your PHP files  get the password.
 
 -Original Message-
 From: Tyler Longren [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 18, 2002 23:10 PM
 To: Sailom
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Password in script
 
 
 It's fine.  There's no other way to do it really.  Somebody would have
 to be able to see the source to the php file before they could see the
 password for mysql.  They won't get it just by viewing the webpage
 that's already been parsed by php.
 
 --
 Tyler Longren
 Captain Jack Communications
 [EMAIL PROTECTED]
 www.captainjack.com
 
 
 
 On Fri, 19 Jul 2002 10:03:02 +0700
 Sailom [EMAIL PROTECTED] wrote:
 
 I am new to PHP and MySQL and never have experience in this area.  I
 am writing a PHP script that connects to MySQL server.  I have to put
 a password of MySQL into the PHP script.  I think it may not be
 secured.  What do you think?  How can I make it more secure?  Thanks.
 
 
 
 --
 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
 


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




[PHP] vertical word match

2002-07-18 Thread Joe Rice


hello,
any regex gurus?
i'm trying to match words put into a textarea
that are in the form of a\np\np\l\e
or any combination of new lines in between, before
or after.  

$answer = hello\na\np\np\nl\ne\n; /*from textarea in form*/
$word = apple;
$word = preg_replace(/(.)/,(.?|\s+|\n+|)$1(.?|\s+|\n+|),$word);
preg_match(/.$word./im,$answer,$match)

works.
but if

$word = red apple;
$answer = r\ne\nd\n\na\np\np\nl\e;

it doesn't match.


thanks in advance,
joe

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




Re: [PHP] Passing variables to page via POST - How?

2002-07-18 Thread Chris Shiflett

Monty wrote:

This is probably more of an HTML question... Is there a way to pass
variables to another page via POST instead of via the URL?


Yes.

form action=another_page.php method=post
... (form fields here) ...
input name=button_name type=submit value=Button Text
/form


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




[PHP] Sorting array based on key string

2002-07-18 Thread Peter J. Pieczora

Pardon my sloppy explanation but here it is:

how can i sort an array based on key element ie.

key values are: a1, a2 ,a3 ..., b1, b2 ,b3, ...c1, c1, c3...
so doing this:
while (list($k, $v) = each($data)) {
for ($i=0; $icount($k); $i++) {
echo $k[0] = $v\nbr;
}
will list all the $k $v .
a = foo
a = bar
b = another foo
...
and so on

Now, how can i sort it according to $k[0]
where $k[0] = a, than the same for all b's and so on.


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




[PHP] best way to delete char# 4-7 from a string?

2002-07-18 Thread Justin French

Hi,

Let's say I have the following string:

$str = 'abcdefghijklmnop';

...and I want to strip out char #'s 4 through to 7 (d,e,f,g)

$strip_start = 4;
$strip_end = 7;

($str would now be 'abchijklmnop';)

THEN I want to plug a new string $filler at position 4

$filler = '4567';

($str would now be 'abc4567hijklmnop')


This is what I think would work (untested), looking for pointers,
optimisation, or a better approach:

?
$str = 'abcdefghijklmnop';
$strip_start = 4;
$strip_end = 7;
$filler = '4567';

$pre = substr($str,0,$strip_start-1);// abc
$post = substr($str,$strip_end+1,strlen($str));  // hijklmnop

$str = $pre.$filler.$post;  //abc4567hijklmnop
?

Thanks,

Justin French


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




[PHP] session_unregister question

2002-07-18 Thread Brad Wright

Is it possible to somehow do a session unregister of all session variables
except for (say) 2 variables. varA and varB

So if my session had :
varA, varB,varC, varD,varE (etc)

I want to unregister all but varA and varB.

Is there an 'elegant' way to do this without testing for all the variables
in the session?



Cheers,

Brad 


Nel vino la verità, nella birra la forza, nell'acqua i bacilli
--
In wine there is truth, in beer there is strenght, in water there are
bacteria


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




[PHP] get line from file

2002-07-18 Thread Yamin Prabudy

I got a file line like this

!-- START --
This is a line1
this is a line2
this is a line3
this is a line4
!-- END --



how can i grep out the line1,line2,line3 ??
do anyone out there have any idea ?


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




[PHP] Re: Searching...

2002-07-18 Thread David Robley

In article [EMAIL PROTECTED], 
[EMAIL PROTECTED] says...
 in ym search page, i construct a sql query from user input to search my
 database, and i run this query to get totalresults. Then run another query
 with a LIMIT 0, 30 ending for each page. So I'm running 2 mySQL queries per
 page. My question is, is this inefficient? is there any better way i dont
 know of? or does the 2 queries not mka emuch of a difference
 

You might consider running the first query just to get a COUNT(), rather 
than extracting all the resulting rows and using mysql_numrows to 
determine how many were returned

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam

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




RE: [PHP] vertical word match

2002-07-18 Thread Martin Towell

try changing the +'s with *'s
+ = 1 or more
* = 0 or more

-Original Message-
From: Joe Rice [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 3:30 PM
To: [EMAIL PROTECTED]
Subject: [PHP] vertical word match



hello,
any regex gurus?
i'm trying to match words put into a textarea
that are in the form of a\np\np\l\e
or any combination of new lines in between, before
or after.  

$answer = hello\na\np\np\nl\ne\n; /*from textarea in form*/
$word = apple;
$word = preg_replace(/(.)/,(.?|\s+|\n+|)$1(.?|\s+|\n+|),$word);
preg_match(/.$word./im,$answer,$match)

works.
but if

$word = red apple;
$answer = r\ne\nd\n\na\np\np\nl\e;

it doesn't match.


thanks in advance,
joe

-- 
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] Sorting array based on key string

2002-07-18 Thread Martin Towell

dunno if this'll work... but here goes...

sort($data);
ksort($data);

but ksort() might mangle the order from sort(). In that case, you'll need to
write your sort routine that retains the old order

-Original Message-
From: Peter J. Pieczora [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 5:35 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Sorting array based on key string


Pardon my sloppy explanation but here it is:

how can i sort an array based on key element ie.

key values are: a1, a2 ,a3 ..., b1, b2 ,b3, ...c1, c1, c3...
so doing this:
while (list($k, $v) = each($data)) {
for ($i=0; $icount($k); $i++) {
echo $k[0] = $v\nbr;
}
will list all the $k $v .
a = foo
a = bar
b = another foo
...
and so on

Now, how can i sort it according to $k[0]
where $k[0] = a, than the same for all b's and so on.


-- 
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] best way to delete char# 4-7 from a string?

2002-07-18 Thread Martin Towell

dunno how much slower it'd be, but it might look better. You could convert
the strings to an array, use array_splice(), and then convert back to a
string.

-Original Message-
From: Justin French [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 3:39 PM
To: php
Subject: [PHP] best way to delete char# 4-7 from a string?


Hi,

Let's say I have the following string:

$str = 'abcdefghijklmnop';

...and I want to strip out char #'s 4 through to 7 (d,e,f,g)

$strip_start = 4;
$strip_end = 7;

($str would now be 'abchijklmnop';)

THEN I want to plug a new string $filler at position 4

$filler = '4567';

($str would now be 'abc4567hijklmnop')


This is what I think would work (untested), looking for pointers,
optimisation, or a better approach:

?
$str = 'abcdefghijklmnop';
$strip_start = 4;
$strip_end = 7;
$filler = '4567';

$pre = substr($str,0,$strip_start-1);// abc
$post = substr($str,$strip_end+1,strlen($str));  // hijklmnop

$str = $pre.$filler.$post;  //abc4567hijklmnop
?

Thanks,

Justin French


-- 
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




<    1   2   3