Re: [PHP] remove a line from a text list

2003-03-05 Thread Chris Wesley
On Wed, 5 Mar 2003, Richard Kurth wrote:

 This script will remove a line from a text list of email address and
 then re-write the list. The only problem I am having is when it
 re-writes the list it adds a extra line between each record. How can I
 stop this from happening

Your code works as you'd expect ... on my mod_php 4.2.2  Apache 1.3.26
setup.  It's amazing though, because implode() is used incorrectly.
See below:

 $recordsarray = file($members);
 $remove = [EMAIL PROTECTED];
 $temp = array();
 for ($i=0;$icount($recordsarray);$i++)
 {
   if (!strstr($recordsarray[$i], $remove))
   {
 $temp[] = $recordsarray[$i];
   }
 }
 $recordsarray = $temp;
 $lines = implode($recordsarray,'');

The above line:
I'm assuming you want to collapse $recordsarray into a sting, with the
elements of $recordsarray separated by a null char.  Well, you told
implode() to collapse a null char into a string with the elements of null
char separated by $recordsarray ... inverted the arguments to implode().
I have no idea why an error isn't raised instead of kind-of working, but
anywho 

Try switching the arguments around in the call to implode(), to:
$lines = implode('',$recordsarray);

http://www.php.net/manual/en/function.implode.php

If that doesn't correct the problem you're experiencing, let us know.
I have other ideas for you, but they may not be necessary if that solves
it.

HTH,
~Chris


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



Re: [PHP] print $array[$i][0] pukes

2003-03-05 Thread Chris Wesley
On Wed, 5 Mar 2003, David T-G wrote:

   $m = count($manilist) ;
   for ( $i=0 ; $i$m ; $i++ )
 { print $i :: $manilist[$i][0]\n ; }

 I simply get 'Array[0]' out for each inner..  Clearly php is seeing that
 $manilist[$i] is an array, telling me so, and then happily printing the
 [0]; how do I get to the value itself without having to use a temporary
 array?

Actually, it's literally printing [0] after it prints Array.  PHP is
detecting that $manilist (not $manilist[0]) is an array (for which it
prints Array), then you get a literal [0]  afterwards because you put
it all within quotes.

If you print this way, you'll get what you want:

print $i ::  . $manilist[$i][0] . \n;

HTH,
~Chris


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



Re: [PHP] open_basedir Option

2003-02-19 Thread Chris Wesley
On Wed, 19 Feb 2003, Joachim Krebs wrote:

 How do I set the php.ini setting open_basedir on a per-directory
 basis? Ideally, I would like to set it using .htaccess files...

open_basedir can only be set in php.ini or httpd.conf.

You might be able to set it in Directory stanzas within your httpd.conf,
but you cannot set it in .htaccess files within directories (nor with
ini_set()).

~Chris


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




Re: [PHP] By reference

2003-02-13 Thread Chris Wesley
On Thu, 13 Feb 2003, Chris Boget wrote:

 $firstVar = 123ABC;

 $secondVar = $firstVar;

= is a bitwise AND, and an assignment.
This didn't do what you expected it to do.

 $thirdVar = $firstVar;

= is a reference assignment.
This did what you expected it to do.

 Why?  I thought that = made it so that the left operand was
 pointing to the memory location of the right?

You make the left operand point to the memory location of the right
operand with =.  = is the only reference assignment available, besides
passing/returning by reference with functions.

$stuff = 1234;
$ref = $stuff;// $ref points to $stuff's data
print $ref . \n; // prints 1234
$stuff = 5678;
print $ref . \n; // prints 5678

hth,
~Chris


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




Re: [PHP] Sorting multidimensional arrays

2003-02-13 Thread Chris Wesley
On Thu, 13 Feb 2003, Sean Brown wrote:

 Let's say I've got an array like so:

 $myarray[0][firstname] = Mickey;
 $myarray[0][lastname] = Mouse;
 $myarray[0][score] = 20;

 $myarray[1][firstname] = Donald;
 $myarray[1][lastname] = Duck;
 $myarray[1][score] = 10;

 I'd like be able to sort the array using different dimensions before I
 cycle through a while loop to print out the results.  For instance, by
 lastname, or by score.  I can't seem to get array_multisort() to do it.

array_multisort() isn't what you want.

 Any ideas?

I've seen this question too many times go through here w/ lots of links,
and no code ... so here ya go.  (And I think someone else asked a similar
question today too ... you too, listen up ;)

You can use the usort() function to your advantage.  This is how:

?php
// your $myarray definition here, unmodified

$sortKey = score;
function myCompare( $arrayA, $arrayB ){
global $sortKey;
if( $arrayA[$sortKey] == $arrayB[$sortKey] )
return 0;
return( $arrayA[$sortKey]  $arrayB[$sortKey] ? -1 : 1 );
}

usort( $myarray, myCompare );

var_dump( $myarray );
?

Obviously, you could sort by the other keys by changing the value
of $sortKey, in the code above, or sort in reverse order by flipping
the inequality comparison operator in myCompare().

http://www.php.net/manual/en/function.usort.php ... for all your usort()
goodness.

g.luck,
~Chris



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




Re: [PHP] PHP FTP a security risk?????

2003-02-11 Thread Chris Wesley
On Tue, 11 Feb 2003, Christopher Ditty wrote:

 errors, no nothing.  I talked to his host and found out that they do
 not allow PHP FTP because it is a security risk.  ?  U, ok?

I consider FTP a security risk, period.  (There /are/ ways to run an FTP
server securely, but I won't assume everyone, or even anyone, knows this.)
The possibility of having plain-text authentication flying around ...
security risk.  This is probably the perspective of your hosting company.

You may want to only access a server which provides anonymous FTP.  You
might not use the same username and password to the FTP server that you
use on the hosting server.  You might only be accessing a server on a
trusted network.  But you're just one user.  From a sysadmin perspective,
that's a lot of assumptions made about all the other users who could
potentially use those FTP functions and not take the precautions you took.
(Not to mention, that it's a bit rude to expose someone's FTP server to
compromise just because the security issue doesn't affect the hosting
server.  Plain-text authentication, such that FTP and Telnet use, are the
bane of sysadmin existence ... usernames and passwords are sniffed too
easily.)

That said ... FTP is a protocol;  there's nothing stopping you from
opening a socket and talking FTP back  forth across it (unless your host
has disabled fsockopen() too).  If you know the protocol, you probably
know how and why to avoid its security concerns.

Other options:  Move to a less security-minded hosting provider (looks
like you've already started that), or ask the FTP server admin to provide
download access to your file via HTTP.

... hope that provides some insight.

~Chris


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




Re: [PHP] PHP FTP a security risk?????

2003-02-11 Thread Chris Wesley
On Tue, 11 Feb 2003, Chris Wesley wrote:

 On Tue, 11 Feb 2003, Christopher Ditty wrote:

  errors, no nothing.  I talked to his host and found out that they do
  not allow PHP FTP because it is a security risk.  ?  U, ok?

 That said ... FTP is a protocol;  there's nothing stopping you from
 opening a socket and talking FTP back  forth across it (unless your host
 has disabled fsockopen() too).  If you know the protocol, you probably
 know how and why to avoid its security concerns.

 Other options:  Move to a less security-minded hosting provider (looks
 like you've already started that), or ask the FTP server admin to provide
 download access to your file via HTTP.

You might find this interesting too -- straight from Example 1 for fopen()
in the PHP manual:  http://www.php.net/manual/en/function.fopen.php

$handle = fopen (ftp://user:[EMAIL PROTECTED]/somefile.txt;, w);

b.careful ... g.luck,
~Chris



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




Re: [PHP] PHP FTP a security risk?????

2003-02-11 Thread Chris Wesley
On Tue, 11 Feb 2003, Christopher Ditty wrote:

 Chris, Did you read the rest of the message?  It sounds like the web

Yes, I read your entire message.

 host is saying that
 someone can access PHP FTP from an outside server and hack into the
 server.

That's precisely NOT what the hosting provider said (at least it's not
what my appreciation for running a secured web host led me to believe they
said).  I don't expect you to be a security expert, but think with me
through a very common scenario sysadmins must account for.  I'll use the
word you in a general sense:

  You access an FTP server with a user name and a password to retrieve a
  file via PHP FTP.  The user name and password is the same that grants
  you access to your hosting providers server.  (People do this
  v.frequently.  Most people have trouble remembering one
  username/password, so they make the dangerous choice to use one
  username/password over and over again.)  A malicious individual sniffs
  your username and password while you transfer a file via FTP from to you
  hosting provider.  Once the individual has his way with your FTP site
  using your credentials, (s)he does the obvious next step ... attempts to
  use the same credentials to gain access to your hosting providers
  server.

Make sense?  That didn't take much time, effort, or thought to get the
hosting provider compromised.  And note that it had nothing to do with
PHP.  It has everything to do with FTP itself.

Like I said, originally, you and/or your customer might take precautions
against something like this, but there's no way a responsible sysadmin can
assume or be assured that every user on a system will do the same.

The hosting provider isn't trying to protect itself from malicious people
attacking some vulnerability in PHP's FTP extensions.  The webhost is
trying to protect itself from it's own users who might code somthing using
an insecure protocol which might allow malicious people easily gain access
credentials to its servers, or othewise allow abuse of a server's
resources.  PHP's FTP extenstions aren't a security risk.  The security
risk is what users can do with FTP.

At the /risk/ of introducing more reasons for the webhost to disallow the
FTP extensions, forward them this thread and ask if these are indeed
their reasons.

 I am not trying to start a debate on whether or not people should send
 passwords and userids over plain text.  Yes, that is a security risk.
 My concern is that this webhost is telling my customer that PHP FTP
 itself is a security risk when it does nothing more than act like
 ws-ftp.

Ws-ftp uses plain-text authentication.  The FTP extension to PHP uses
plain-text authentication.  (Neither has a choice, since FTP is a
plain-text protocol.)  They both present security risks for the same
reason.

~Chris



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




Re: [PHP] PHP FTP a security risk?????

2003-02-11 Thread Chris Wesley
On Wed, 12 Feb 2003, Jason Wong wrote:
 On Wednesday 12 February 2003 07:46, Chris Wesley wrote:
You access an FTP server with a user name and a password to retrieve a
file via PHP FTP.  The user name and password is the same that grants
you access to your hosting providers server.  (People do this
v.frequently.  Most people have trouble remembering one
username/password, so they make the dangerous choice to use one
username/password over and over again.)  A malicious individual sniffs
your username and password while you transfer a file via FTP from to you
hosting provider.  Once the individual has his way with your FTP site
using your credentials, (s)he does the obvious next step ... attempts to
use the same credentials to gain access to your hosting providers
server.

 Even they they are not clueless and they were trying to say what you're
 saying, it is still a very poor argument.

Why?  What's a better argument?  It's certainly just a piece of a much
larger argument, but avoiding a full-fledged lecture outside the immediate
context of the original question (and trying to keep it related to PHP
somehow) makes it brief.

 So they allow incoming FTP (presumably that's what people use to upload their
 site) but disallow outgoing FTP because someone might sniff the
 username/password? Does it make sense?

 [snip]

  Ws-ftp uses plain-text authentication.  The FTP extension to PHP uses
  plain-text authentication.  (Neither has a choice, since FTP is a
  plain-text protocol.)  They both present security risks for the same
  reason.

 A security risk in that someone might be able to get your login credentials
 and upload stuff to your FTP space, BUT not necessarily a security risk to
 the server itself. Modern FTP servers support virtual users and chroot so the
 risk of server compromise is minimised.

Not so.  Nevermind gaining access to the hosting server via FTP.  With
stolen credentials, one might log into the server via SSH, or gain access
to other services on the box with the stolen credentials.  It doesn't
matter what modern service you have running ... once you've stolen the
keys, you're in, and you can do /something/ you're not supposed to do.

I've seen chrooted home directories in exactly one place.  You'll almost
never find them in a shared hosting environment.  Most likely, there are
quotas.  Even so, the risk of having unauthorized users on your server(s)
is not acceptable under any circumstances, especially through one avenue
you know you can shut down.  With the quotas in todays shared hosting
offerings, there's enough space to distribute/run/launch a myriad of
malicious software, or simply replace the account owner's content with
warez for a short time.  The risks range from a minor pain in the ass to
becoming a platform for launching [D]DoS attacks, worms, or viruses.

On the Internet, risk is risk, big or small, and none if good.  Do away
with as much of it as you can.

~Chris




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




Re: [PHP] PHP FTP a security risk?????

2003-02-11 Thread Chris Wesley
On Wed, 12 Feb 2003, Jason Wong wrote:

 On Wednesday 12 February 2003 14:02, Chris Wesley wrote:

  Why?  What's a better argument?  It's certainly just a piece of a much
  larger argument, but avoiding a full-fledged lecture outside the immediate
  context of the original question (and trying to keep it related to PHP
  somehow) makes it brief.
 
  On Wed, 12 Feb 2003, Jason Wong wrote:
   So they allow incoming FTP (presumably that's what people use to upload
   their site) but disallow outgoing FTP because someone might sniff the
   username/password? Does it make sense?

 OK, in keeping with the original question, again, why would they allow
 incoming FTP but disallow outgoing FTP? What is the incremental risk?

The original question dealt with making an FTP connection to an outside
FTP site from a web host.  The FTP server and the web server aren't run by
the same people/company.  The web hosting provider objected to allowing
outgoing FTP connections.  Nowhere in this thread is the opinion of the
owner of the FTP site about incoming or outgoing FTP connections.  Also,
nowhere in this thread is mentioned how files are uploaded to the web
host.  That's left to our imaginations, I guess.

If you assume the users use FTP for uploads, then you have to assume the
hosting company is a band of hypocrites.

If you assume the users use SFTP or SCP for uploads, then you have to
assume the hosting company's objection to outgoing FTP is actually
addressing a security concern.  I erred to this side so as not not unduely
ridicule anyone, and to share some pertinent insight from my experiences
with running a secure shared host.  Also, the manager-speak in the
original message included verbiage from the hosting company stating that
the company had already been burned by a similar circumstance.  They
apparently learned from it and are being somewhat smart about what they
enable and disable.  I gave them the benefit of the doubt on whether they
were really addressing a security concern ... and I agree that there is a
security concern to address.

~Chris





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




Re: [PHP] default php sessions in a database

2003-02-11 Thread Chris Wesley
On Tue, 11 Feb 2003, Robin Mordasiewicz wrote:

 Is there a way to configure php to use a database for sessions rather than
 a text file.
 I have a server farm and want the session files to be accessible to all
 machines in the cluster. I can have the session file on nfs but I am
 worried  about file locking.
 I have read tutorials on how to set session.save_handler = user and then
 each script configures their seesion variables and connections, but I
 want this to be transparant to my users. I do not want users to have to
 change anything in their scripts.

Consider this (Warning: I haven't tried this, yet):

Write your session handling functions and put them in a file ... say,
/var/www/server/custom_session.php.  Call session_set_save_handler() with
your function names as arguments in that file.
(Good explanations here:
 http://www.php.net/manual/en/function.session-set-save-handler.php)

In your php.ini file, set:
session.save_handler = user
auto_prepend_file = /var/www/server/custom_session.php

This will cause PHP to use your custom session handler system-wide,
while remaining transparent to your users, I believe.  (If anyone knows
this to be not the case, let me know.)

Caveats:

You'd have to make sure you custom handler function names are unique
enough so as to not conflict with functions names your users can create.

I'm not sure what will happen if your users call
session_set_save_handeler() again, but with their own functions as
handlers.

If after some consideration it still seems like a workable solution and
you try it, let us know how it pans out!

g.luck,
~Chris




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




Re: [PHP] Allowing . in $_POST variable

2003-01-28 Thread Chris Wesley
On Tue, 28 Jan 2003, Mike Potter wrote:

 sense to me that this feature get another look.  I can see no logical
 reason to not allow . in the global $_POST variable...
   Basically, what I'd like is to be able to post a form element with
 id=myvariable.whatever and access it on the next page with
 $_POST[myvariable.whatever].

Here's just one of many good reasons ...

// obviously this is some busted garbage
$name.Array[first]=Chris;
$name.Array[last]=Wesley;
$name=$name.Array[first]. .$name.Array[last];

// and this is not
$name_Array[first]=Chris;
$name_Array[last]=Wesley;
$name=$name_Array[first]. .$name_Array[last];

You'd make both your Lex and your Yacc puke while parsing the first one ;)

~Chris


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




Re: [PHP] Allowing . in $_POST variable

2003-01-28 Thread Chris Wesley
On Tue, 28 Jan 2003, 1LT John W. Holmes wrote:

 Basically, what I'd like is to be able to post a form element with
   id=myvariable.whatever and access it on the next page with
   $_POST[myvariable.whatever].
 
  // obviously this is some busted garbage
  $name.Array[first]=Chris;
  $name.Array[last]=Wesley;
  $name=$name.Array[first]. .$name.Array[last];

 That assumes register_globals is ON, though, which isn't recommended. If you
 read the questions, the poster talks about using the value such as

There aren't two different lexigraphical parsers if you turn
register_globals on or off.  So, PHP either allows ALL variables to have a
. in their name, or disallow it altogether.  So, moving outside of the
narrow case of POST variable names is what I did *after thoroughly reading
and thinking about the question*.  (Somebody missed the Lex  Yacc hint.)

 $_POST['name.Array'], which is valid. Since it's encouraged to have register
 globals OFF, I think they should do aways with this period to underscore
 thing, also. It will only jack up people's code that rely on
 register_globals and they should be changing it anyhow.

As long as it's possible to turn register_globals on, this will have to be
a problem.  I'd vote for tearing this bandaid off, getting rid of
register_globals altogether, and undo all the idiosyncrasies it causes,
but that's just me (and others who think similarly).

~Chris


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




Re: [PHP] Cannot show reuploaded image file on page unless manualrefresh

2003-01-20 Thread Chris Wesley
On Mon, 20 Jan 2003, Phil Powell wrote:

 I am using the following header() functions to force view.php to not cache:

 header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);// Date in the past
 header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);
 header(Cache-Control: no-store, no-cache, must-revalidate);  // HTTP/1.1
 header(Cache-Control: post-check=0, pre-check=0, false);
 header(Pragma: no-cache);  // HTTP/1.0

view.php will never be cached ...

 However, when a user reuploads a file in manage.php, it does a form post
 onto manage.php and reuploads the file (which I verified works).
 However, when redirected via header() to view.php, they still see their
 OLD image file, NOT the new one!  Unless I manually refresh the page,
 they never see it, until they manually refresh the page, then the new
 image file appears!

but you failed to address the caching of images in any of your code or
setup.  The cache headers on the view.php script have /no/ affect on
anything but view.php.  You're fighting the communication betweneen the
browser and the web server, so configure one or the other to play nicely.

- Disable caching in your browser.
- Configure your web server to include cache-control  expires headers on
  all pertinent image requests.  (For example, see mod_expires for Apache:
  http://httpd.apache.org/docs/mod/mod_expires.html)

In lieu of those, change the way you handle uploads.

Instead of using the exact filename of the uploaded file, rename the file
slightly, to include a timestamp or some other changing identifier each
time the file is uploaded.  For exampple, when myImage.jpg is uploaded,
save it as myImage-001.jpg the first time, myImage-002.jpg the second
time.

g.luck,
~Chris



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




Re: [PHP] building web album - design questions

2003-01-09 Thread Chris Wesley
On Thu, 9 Jan 2003, Anders Thoresson wrote:

   I'm planning to build a web album for my digital photographs, and have
 some questions regarding the design:

I don't want to discourage you from hacking your own code ... that's phat,
so plz take this just as some heads-up info:

IMHO, Gallery can't be beat for a web photo album.  It's got some of its
own problems and lacking features, but it's a solid idea with a lot of
code for doing, well, just about everything you'd want to do with a web
photo album.  I didn't write it nor know the people who do.  However, I do
use it, and have hacked at it for my own albums:

http://gallery.menalto.com/index.php

If for no other use, it's probably a valuable project to study.  Check it
out, and dive into its code for features you like.  You may find ways to
implement some things well, and, like I, find ways to NOT implement things
poorly.  (BTW, it doesn't use a database for anything!)

That said 

   1) Is it better to store the images within the database, or just store
 pointers to the images which is put outside, in the filesystem?

Keep files in the filesystem :)

   2) At log in, I want to show to which albums new pictures have been added
 since last visit. For performance reasons, should information about last
 added pictures be added to the database, or is it ok to make a MySQL-query
 each time, comparing the add-date for every picture in every album with the
 users last log in date?

Personal photo albums tend to be low-traffic.  And you're aiming for a
very specific functionality ... a repeating query is probably a safe
solution (seems like the only one, too).

   3) If I've understood things right, there is functions within PHP that
 can handle picture resizing? Is that correct?

Yes.  http://www.php.net/manual/en/ref.image.php

g.luck,
~Chris


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




Re: [PHP] stripslashes and quoted material

2003-01-08 Thread Chris Wesley
On Wed, 8 Jan 2003, Gerard Samuel wrote:

 a href=\http://www.apache.org/\; target=\_blank\

 When trying to apply stripslashes, the slashes remained.  So I applied
 str_replace('\', '', $var) and that worked.
 Any idea as to why stripslashes would not remove the slashes in the string?

stripslashes() will unescape single-quotes if magic_quotes_runtime = Off
in your php.ini.  If you have magic_quotes_runtime = On, then it will also
unescape double-quotes (and backslashes and NULLs).

~Chris



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




Re: [PHP] Looping through directories?

2003-01-08 Thread Chris Wesley
On Wed, 8 Jan 2003, Jeff Lewis wrote:

 pattern for the name if the indexes, I assume I need to create an array
 holding the directory name and the associated index file name like so
 $dirs = array(Sports = spindex.xml, Business News =
 business.xml) etc

 Now, I need help with the loop to whip through each directory. Would I
 do a foreach on the array I just created? Any help would be greatly
 appreciated. I need to be able to access both the directory name and
 index name.

foreach() would work for you ...

foreach( $dirs as $dirName = $indexName ){
$indexPath = ${dirName}/${indexName};
$fh = fopen( $indexPath, r );
// ...
fclose( $fh );
// I'm just guessing; do whatever you want in this loop
}

hth,
~Chris


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




RE: [PHP] Adding HTTP URL Code

2003-01-08 Thread Chris Wesley
On Wed, 8 Jan 2003, ELLIOTT,KATHERINE A (HP-FtCollins,ex1) wrote:

 OK, so I've gotten NO responses to my query below so I
 thought I'd ask for something slightly different and see what
 I get.

The follow-up inquery makes much more sense than the original ;)

 If I have a bunch of plain text data, how can I pull out the
 strings containing http.  I've tried several different things
 but what I end up with is more or less than what I want.
 Once I have this, I can add the URL code and replace the
 string but I haven't figured out how to do this.

Say that the paragraph you gave is a string in a variable, $TEXT ...

$allowedChars = /:@\w.#~?%+=!-;
preg_match_all(
  {\bhttp:[$allowedChars]+?(?=[$.:?\-]*[^$allowedChars]|$)}x,
  $TEXT,
  $URLS
);
foreach( $URLS[0] as $link ){
print( a href=\${link}\${link}/a\n );
}

That should get ya started.  Read up on regular expressions, and the
regexp functions in PHP to make heads  tails out of the code, other than
it works.  (So far it works well for my intentionally limited purposes
... I wouldn't be surprised that someone finds a case where my code
breaks, or someone can/does easily extend the regexp to grok more stuff.)

http://www.oreilly.com/catalog/regex2/
http://www.php.net/manual/en/ref.pcre.php
http://www.php.net/manual/en/ref.regex.php

g.luck,
~Chris



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




Re: [PHP] help - WHILE in FOREACH

2003-01-07 Thread Chris Wesley
On Tue, 7 Jan 2003, James Brennan wrote:

 The while statement is only executing correctly for the first run through
 the foreach loop. Why?

It's /real/ hard to tell when you don't give any context or otherwise
explain what it is you want to achieve.  Since the code in fact executes
correctly, we can only explain what's going on in your code, not why it
doesn't work for your needs ...

You while() loop runs through a mysql result set in its entirety the
first time through the foreach() loop and leaves the result pointer at the
end of the result set.  All subsequent runs of the while() loop will start
fetching results from the end of $show_names ... and get /nothing/.

If you want to use all the results out of $show_names again, you have to
reset the result pointer to the beginning of $show_names.  Use
mysql_data_seek().  http://php.net/mysql_data_seek, and see below.

 foreach($desc as $key=$value) {
   printf(Show %s Description select name='show%sDesc', $key, $key);
   echo option value = ''/option;
   while($row = mysql_fetch_row($show_names)) {
 printf(option value='%s'%s/option, $row[0], $row[1]);
   }
if( mysql_num_rows( $show_names )  0 ){
  mysql_data_seek( $show_names, 0 );
}
   echo /selectbr;
 }

g.luck,
~Chris


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




Re: [PHP] Multiple forms

2002-12-30 Thread Chris Wesley
On Mon, 30 Dec 2002, Doug Coning wrote:

 However, I want to add another form in the same page.  My current form acts
 upon itself (i.e. Action = the same page).  If I set up another form to do
 the same, how would my PHP determine with action submit button was acted
 upon?

Give your submit buttons names and values, then you can check the button
element's value as submitted and made available in $_POST.
i.e. -
In your HTML (notice the button /names/ are the same) :

form name=form1 action= method=POST
  input type=submit name=submitButton value=form1
/form

form name=form2 action= method=POST
  input type=submit name=submitButton value=form2
/form

And in your PHP:

if( $_POST['submitButton'] == form1 ){
// do something for form 1;
} elseif( $_POST['submitButton'] == form2 ){
// do something for form 2;
} else {
// some tardnugget is playing games with your form ;)
}

There are several variations on this ... hope this one helps.

g.luck,
~Chris



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




Re: [PHP] Include Problems

2002-12-26 Thread Chris Wesley
On Thu, 26 Dec 2002, Mike Bowers wrote:

 I have a file named header.php stored in the includes folder:
 Inside includes is anohter folder called editable.
 When I open my page for the first time (before it is cached) or after I
 edit my header file I get these errors:
 Warning: Failed opening 'editable/meta.php' for inclusion
 (include_path='') in

Your include_path in php.ini is null, as indicated by the line above.

What you're assuming will happen is that include will automatically look
in the includes dir for files, so you have to set this:
include_path=./includes

I set mine:
include_path = .:./:../:./include:../include

g.luck,
~Chris


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




Re: [PHP] How To Get Last Item Of An Array?

2002-12-25 Thread Chris Wesley
On Wed, 25 Dec 2002, @ Nilaab wrote:

 I have an multi-dimensional array called $cat_data, which is info extracted
 from a MySQL DB. I want to retrieve the very last item of that array. How
 would I do that? I know the first item can be retrieved by simply asking for
 $cat_data[0][0], which contains an id number. But I can't figure out how to
 get the last item in that same array -- $cat_data[x][0] where x is the last
 item in the array.

Naturally, the index of last item of an array is one less than the total
number of elements in the array.

$num_elements = count( $cat_data );
$last_element = $cat_data[$num_elements-1][0];
// 0 being what you were seeking

Cheers!
~Chris



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




Re: [PHP] Problem with comma in mail form

2002-12-25 Thread Chris Wesley
On Wed, 25 Dec 2002, Ben Edwards wrote:

 I have a fairly simple mail form which gets email, subject and message and
 posts to itself.
 It then use mail() function to send a email.
 mail( $admin_email, $subject, $message, From: $email );
 Problem is the message gets truncated if there is a comma in the message
 after the comma.

I have forms that have identical functionality, but don't exhibit that
erroneous behavior.  I can't tell what you've done to the arguments to
mail() before using them, but the only thing I do is run them through
stripslashes() and trim().  i.e. -

$message = trim( stripslashes( $_POST['message'] ) );

If that's what you do too ... weird!  If not, give it a try and see what
happens.

g.luck  cheers!
~Chris


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




Re: [PHP] $_COOKIE and include() or require()

2002-12-23 Thread Chris Wesley
On Mon, 23 Dec 2002, Luke Sneeringer wrote:

 However, then in the script I have a require tag (essentially like
 require('http://www.mydomain.com/common.php')) line. I call this line,
 and within that file (same domain) the $_COOKIE[] array as well as
 variables such as $cookiename are all blank. I cannot figure out for the
 life of me why this is occuring.

The most likely scenario is that common.php is being processed by the web
server  PHP before being included into your code.  This would be causing
a second HTTP request from your web server to your web server for the
included code ... there are no cookies on the HTTP request for the
included code, /and/ the variables available to the parent are not
available to the included code.  You effectivly get the output of
common.php, not included code.

Try this:
- copy common.php to common.inc (or some other extension that your web
  server is not configured to hand off to be parsed by PHP).
- in the parent code, include() the common.inc URL instead of the
  common.php URL.

Let us know if that helps or not.

g.luck,
~Chris



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




Re: [PHP] Plotting Data Graphics

2002-12-23 Thread Chris Wesley
On Mon, 23 Dec 2002, Alexandre Soares wrote:

 Where I can get more information about a free library to plot 2d and
 3d data information,

Check out phpclasses.org.  A quick search for graph returned 10 classes.
Another 3 for plot.  One may work out for you, or lead to something else
more helpful.

g.luck,
~Chris


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




Re: [PHP] ¡¾help¡¿how can I put the pull down menu in a frame and display.....

2002-12-23 Thread Chris Wesley
On Wed, 18 Dec 2002, dreamyman wrote:

 1.I want to put my menu in a top frame and when I select a Item ,it can
 display it in the frame below.
 2.my web has 2 frame ,lefe and right.
 but the right has a menu ,so I want to change left frame when select
 different menu of left frame.

HTML questions.  You'll be interested in the HTML spec, specifically:
Frames: http://www.w3.org/TR/html4/present/frames.html
http://www.w3.org/TR/html4/present/frames.html#adef-target
Links:  http://www.w3.org/TR/html4/struct/links.html

In both of your examples, you need to put a target on your anchors as
specified by the HTML spec in the section about frames.

g.luck,
~Chris


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




Re: [PHP] $_COOKIE and include() or require()

2002-12-23 Thread Chris Wesley
On Mon, 23 Dec 2002, Luke Sneeringer wrote:

 That doesn't seem to work. This might be because my require tags also
 send variables (e.g. common.php?variable=1)--would this make a call to
 a non-PHP extention file fail?

You've already demonstrated that you know included code inherits the
parent's variables at the scope where require() is called ... so I'll
leave it up to you to determine whether or not the ?variable=1 is
necessary.  I dont' know if it breaks require(), but I doubt it.

Here's the trick:  visit the URL of the require()'d code with a web
browser.  If you don't see /code/, then your require() won't work.  If you
do see the php code ... all of it, including the start  end tags ...  in
plain text, then you're on the right track; your code should be able to be
included into the parent.

You're trying to include /code/ into some parent code, so you don't want
the processed result of the PHP script (unless it's more PHP code).

If this doesn't get you closer, post a simple example of what you're
trying to do.  I routinely include PHP across domains for various reasons
... I know it works, and works well ... it will for you too, I hope!

hth,
~Chris


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




Re: [PHP] case statement?

2002-12-19 Thread Chris Wesley
On Thu, 19 Dec 2002, Max Clark wrote:

 I was wondering if php had a case function?

 Instead of building a large if/elseif/else block I would like to do a
 case $page in (list).

switch function ...

http://www.php.net/manual/en/control-structures.switch.php

~Chris


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




Re: [PHP] Re: problems with jsp php

2002-12-12 Thread Chris Wesley
I'm pretty sure everyone else is as confused by your description as I am.
(Hence, I didn't answer.)  It looks like you're trying to generate
JavaScript w/ PHP, but your subject mentions JSP.  In a nutshell, I don't
know if what you're doing is over my head, or just not explained clearly.

I can man an uncomfortable assumption, though:  You mean to generate
JavaScript and JSP has nothing to do with this problem.  Try quoting your
JavaScript variable values ...

Change:
var action = ? echo $_GET['action']; ?;

To:
var action = ? echo $_GET['action']; ?;

... likewise with the rest of your JavaScript variables.

g.luck,
~Chris

On Thu, 12 Dec 2002, Jeff Bluemel wrote:

 somebody has to have an answer to this...


 Jeff Bluemel [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I cannot figure out where my problem is with the following script.  I know
  I've used this syntax successfuly in the past.  when I take out the
  variables, and just set link to something without using php then this
 works.
  know when I click on the form that activated the button it does nothing.
 
  function batch_close()
  {
  if (parent_window  !parent_window.closed)
  {
   var action = ? echo $_GET['action']; ?;
var batch = ? echo $_GET['batch']; ?;
var begin = ? echo $_GET['begin']; ?;
var end = ? echo $_GET['end']; ?;
var amount = ? echo $_GET['amount']; ?;
var link = maintain.html?action= + action + batch= + batch +
  begin= + begin + end= + end + amount= + amount;
  parent_window.document.location.href=link;
  parent_window.focus();
  }
  window.close();
  }



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




Re: [PHP] Move Decimal Point

2002-12-11 Thread Chris Wesley
On Wed, 11 Dec 2002, Stephen wrote:

 I have a question. How would you move the decimal left or right,
 depending on if the number a user enters is negative or not, and then
 move it that many spaces? If needed, it would add zeros.

Math ... multiply  divide ... I assume you're using a base-10 number
system, so multiply or divide by 10 when your user's input indicates you
should do so.

 One other question. How would I find the first 0 of a repeating zero.
 Like 204,000. How would you find the 0 in the 4th column.

I have one for you first.  Are you using this list to do your homework?
I've noticed that over the past couple days you've been asking
not-necessarily PHP questions, but /basic/ programming questions.

For your repeating zeors question, you'll have to make use of some string
functions or a regexp function.  Look for a pattern of more than 1 zero.

g.luck,
~Chris


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




Re: [PHP] strstr-pls help

2002-12-11 Thread Chris Wesley
On Wed, 11 Dec 2002, Mekrand wrote:

 i solved problem, -not a good solution-
 i changed only
 $adam=fread($ip,filesize($ip));

You have:
$string = fread( $fileHandle, filesize( $fileHandle ) );

The example at php.net you looked at has:
$string = fread( $fileHandle, filesize( $fileName ) );

Just change your call to filesize() to use the file name as the argument.
No need to have a dirty solution, if you don't want to :)

g.luck,
~Chris


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




Re: [PHP] 2 dates, difference in days AARGH!!

2002-12-11 Thread Chris Wesley
On Wed, 11 Dec 2002, Curtis Gordon wrote:

 future date:
 ?$maturity_date = mktime (0,0,0,$mday_row[3],$mday_row[2],$mday_row[5]);?
 current date:
 ?$today = getdate();?
 ?$now_date = mktime
 (0,0,0,$today['month'],$today['wday'],$today['year']);?

$today['month'] is text, ie. December, and mktime()  requires all
integer arguments.  If you use $today['mon'] instead, it seems like
you'll get what you want.

g.luck,
~Chris


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




Re: [PHP] 2 dates, difference in days AARGH!!

2002-12-11 Thread Chris Wesley
Oh, and $today['wday'] ... that's the day of the week.  I'm almost
positive you want the day of the month: $today['mday'].

hth,
~Chris

On Wed, 11 Dec 2002, Chris Wesley wrote:

 On Wed, 11 Dec 2002, Curtis Gordon wrote:

  future date:
  ?$maturity_date = mktime (0,0,0,$mday_row[3],$mday_row[2],$mday_row[5]);?
  current date:
  ?$today = getdate();?
  ?$now_date = mktime
  (0,0,0,$today['month'],$today['wday'],$today['year']);?

 $today['month'] is text, ie. December, and mktime()  requires all
 integer arguments.  If you use $today['mon'] instead, it seems like
 you'll get what you want.



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




Re: [PHP] Using fopen() to open a php file with variables.

2002-12-11 Thread Chris Wesley
On Wed, 11 Dec 2002, Jay (PHP List) wrote:

 Okay, I need to retrieve the output of a php file with variables being
 passed to it.  Example:

 $calendar_file = make_calendar.php3?month=$monthyear=$year;
 $fp = $fp = fopen($calendar_file, r);

Oh my!  That's not going to work, because
make_calendar.php3?month=$monthyear=$year is not a file in your
filesystem.  I'd start making suggestions on what you can do to achieve
the same effect, but I think it'd be easier if you told us what it is you
want to achieve by doing that.  (It would for me, at least.  Then I'll
start making suggestions.)

THX,
~Chris



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




Re: [PHP] Bug with + sign when using CLI?

2002-12-06 Thread Chris Wesley
On Fri, 6 Dec 2002, Charles Bronson wrote:
 I found nothing about a + splitting argument variables anywhere in the
 CLI documentation though I know this is a CGI characteristic. I've tried
 escaping the + character to no avail.

Check out the bug:

http://bugs.php.net/bug.php?id=18566

I experienced the same thing (Linux 2.4.17, Apache 1.3.26, PHP 4.2.2
mod_php  CGI).  I can't really tell if there is a fix, or intent to fix
it, since the bug is still open.  Perhaps there is a mention of this issue
in the changelogs of more recent versions.

g.luck,
~Chris




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




Re: [PHP] Re: XSLT failing when DOCTYPE declaration present

2002-12-06 Thread Chris Wesley
no, that's not it.  everything was configured properly.  everything
conformed, except the xslt processor.  the correct people were contacted
many many weeks ago now.

again, thanks for your time ...
~Chris

On Fri, 6 Dec 2002, Dave wrote:

 oops,

 file permission problem, if it isn't set to right permissions, it won't read
 and
 act as if there wasn't one, which then makes it work. so it does look like
 your doc
 doesn't conform.

 Chris Wesley [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  On Wed, 4 Dec 2002, Dave wrote:
 
  Whoah ... was this reply sent several weeks ago when I sent the original
  message and I'm just getting it now, or was it sent just recently?
 
   without seeing the specifics, and assuming that PHP is never wrong (in
 the 4
   years i've used it, it hasn't been!)... your xml doc doesn't conform to
   the DTD. if you think this isn't the case, well, double check. if you
 
  Re-read my original message, and it's painfully obvious that I did
  check, and that the XML did in fact conform to the DTD I used.
  (The XSLT was fine when the DTD was referenced locally, rather than
  remotely.)
 
   still feel it is an error, you may want to email a bug issue to the
   sablotron people (i'm assuming that's what you're using).
 
  Yes, I used the Sablotron extension to PHP 4.2.2.  Thanks for the
  insightful advice 
 
  ~Chris
 
   Chris Wesley [EMAIL PROTECTED] wrote in message
  
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
I'm using the xslt capabilities in PHP 4.2.2 and running into an odd
problem.  I'm transforming an XML document which has a DOCTYPE
declaration referencing an external DTD.
   
!DOCTYPE RootNode SYSTEM http://my.host.org/foo.dtd;
   
When I have xslt_process() attempt to transform the XML document, with
 an
XSL document I provide, it fails.  These are the errors I get back
 from
xslt_error()  xslt_errno.
  error: XML parser error 4: not well-formed (invalid token).
  errno: 2
   
If I remove the DOCTYPE declaration from the XML, xslt_process() has
 no
problem transforming the XML.
   
If I change the DOCTYPE declaration to:
!DOCTYPE RootNode SYSTEM file:///path/to/docroot/foo.dtd
then xslt_process() has no problem transfoming the XML.
   
However, I need to make this work with the external DTD reference
 being to
some other host (http://other.my.host.org/foo.dtd).
Has anyone gotten this to work properly, have any insight into the
 error
information above, or know what I might have to do differently?
 
 



 --
 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] Sending no content-type header?

2002-12-05 Thread Chris Wesley
On Thu, 5 Dec 2002, Leif K-Brooks wrote:
 I'm running a few simple php scripts from the (windows) command line.
  Since I'm not using a web browser to view it, the HTTP headers are
 annoying and pointless.  I've turned expose_php off in php.ini, but
 commenting out default_mimetype changes nothing, and setting it to an
 empty string sends a blank content-type header.  Is there any way to do
 this?

php.exe -q

~Chris


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




Re: [PHP] md5 question

2002-12-05 Thread Chris Wesley
On Fri, 6 Dec 2002, conbud wrote:

 Hey. Is there a way to get the actual word/phrase from the long string that
 the md5 hash creates. Lets say, is there a way find out what
 b9f6f788d4a1f33a53b2de5d20c338ac
 stands for in actuall words ?

In all cases, an md5sum string means, You've got better things to do
besides trying to figure out what this string means, trust me.  ;)

Check RFC 1321.  http://www.ietf.org/rfc/rfc1321.txt

~Chris


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




Re: [PHP] Re: XSLT failing when DOCTYPE declaration present

2002-12-04 Thread Chris Wesley
On Wed, 4 Dec 2002, Dave wrote:

Whoah ... was this reply sent several weeks ago when I sent the original
message and I'm just getting it now, or was it sent just recently?

 without seeing the specifics, and assuming that PHP is never wrong (in the 4
 years i've used it, it hasn't been!)... your xml doc doesn't conform to
 the DTD. if you think this isn't the case, well, double check. if you

Re-read my original message, and it's painfully obvious that I did
check, and that the XML did in fact conform to the DTD I used.
(The XSLT was fine when the DTD was referenced locally, rather than
remotely.)

 still feel it is an error, you may want to email a bug issue to the
 sablotron people (i'm assuming that's what you're using).

Yes, I used the Sablotron extension to PHP 4.2.2.  Thanks for the
insightful advice 

~Chris

 Chris Wesley [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I'm using the xslt capabilities in PHP 4.2.2 and running into an odd
  problem.  I'm transforming an XML document which has a DOCTYPE
  declaration referencing an external DTD.
 
  !DOCTYPE RootNode SYSTEM http://my.host.org/foo.dtd;
 
  When I have xslt_process() attempt to transform the XML document, with an
  XSL document I provide, it fails.  These are the errors I get back from
  xslt_error()  xslt_errno.
error: XML parser error 4: not well-formed (invalid token).
errno: 2
 
  If I remove the DOCTYPE declaration from the XML, xslt_process() has no
  problem transforming the XML.
 
  If I change the DOCTYPE declaration to:
  !DOCTYPE RootNode SYSTEM file:///path/to/docroot/foo.dtd
  then xslt_process() has no problem transfoming the XML.
 
  However, I need to make this work with the external DTD reference being to
  some other host (http://other.my.host.org/foo.dtd).
  Has anyone gotten this to work properly, have any insight into the error
  information above, or know what I might have to do differently?



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




Re: [PHP] Looping Addition

2002-12-04 Thread Chris Wesley
On Wed, 4 Dec 2002, Stephen wrote:

 I already have that. $_POST['vars'] is a number and I already check that you
 on a page before. All I need to know is how to keep adding numbers until
 there are no more to add...

If you mean that $_POST['vars'] is an array of numbers:

$total = 0;
foreach( $_POST['vars'] as $number ){
$total += $number;
}

If you mean that all vars in the POST data are numbers you want to add:

$total = 0;
foreach( $_POST as $number ){
$total += $number;
}

g.luck,
~Chris


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




Re: [PHP] Looping Addition

2002-12-04 Thread Chris Wesley
On Wed, 4 Dec 2002, Stephen wrote:
 This is only a snippet, there is more to it but for simplicities sake...
 Then I calculate it. My question is, how would I loop the adding? I hope you
 understand this now...

Ah!, I think I understand better now.  You want to add num1, num2, num3,
... numN, which are inputs from the second form in your sequence.  Gotcha.

If you name /all/ the form elements as nums[] instead of individually as
num${current}, the numbers put into the form will all be accessible in
one array to the PHP script that does the adding.  Then you can just loop
over the array of numbers.

In your second form, change this:
input name=num?php echo $current; ? type=text id=vars value=0
 size=25

To this:
input name=nums[] type=text id=vars value=0 size=25

Then in the script that adds the numbers:
$total = 0;
foreach( $_POST['nums'] as $number ){
$total += $number;
}

Hopefully I understood your problem this time!  Let me know if I missed
again.
g.luck,
~Chris


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




Re: [PHP] PHP Problem or MySQL (Match ... against)?

2002-12-02 Thread Chris Wesley
On Mon, 2 Dec 2002, jtjohnston wrote:

 SELECT id,AU,ST,BT,AT FROM jdaxell.ccl WHERE MATCH
 (TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) AGAINST
 ('ready maria' IN BOOLEAN MODE) ORDER
 BY id asc

 When I run the same (copied and pasted) SQL in PHP, it is as though
 MySQL is doing a boolean search for `+ready +maria` without the double
 quotes and finding results in every database. if you search for ready
 maria it should only find one entry.

Escape the double quotes.('\ready maria\' IN BOOLEAN 

g.luck,
~Chris


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




RE: [PHP] Passing arguments to the same script

2002-12-01 Thread Chris Wesley
On Sun, 1 Dec 2002, Troy May wrote:

 The only thing that EVER gets displayed is the final else. (Main content
 goes here.)  What am I doing wrong?  Once again, the links are in this
 format: a href=index.php?samples

a href=index.php?samples=1

To get the desired results with the code you posted, you have to give your
query string parameter(s) a value (as above).  If you don't want to give
samples a value, then examine the query string as a whole:
$_SERVER[QUERY_STRING]

if( $_SERVER[QUERY_STRING] == samples ) ...

g.luck,
~Chris


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




Re: [PHP] Read Files

2002-11-30 Thread Chris Wesley
On Sat, 30 Nov 2002, Randum Ian wrote:

 I have a directory of files which are split up into sections based on
 'full', 'summary' and 'competitions'. This is shown in the filename as
 follows:

 ministry-full-6122002.inc

 I want to be able to search thru the dir looking for all the 'full'
 files, then sorting them by date and including them in my html page in
 date order.

To get an array full of the file names you want:

$interestingFiles = array();
$dir = opendir( /path/to/directory ) or die( Could not open dir );
while( $dirEntry = readdir( $dir ) ){
  if( ereg( full, $dirEntry) ){
   array_push( $interestingFiles, $dirEntry );
  }
}

I'll leave it up to you to sort $interestingFiles by the date in the
element values, since I don't recognize a date in your file-naming
convention.

g.luck,
~Chris



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




RE: [PHP] Read Files

2002-11-30 Thread Chris Wesley
On Sat, 30 Nov 2002, Randum Ian wrote:

 Ministry is the name of the club.
 Full is the type of the content.
 6122002 is the date - It is in the form ddmm so the example here is
 6th December 2002.
 Is there a simple way I can just grab the date and sort it by order?
 Should I change the format of the date to make it easier or something?

It'd be easier to sort if you changed your date format a bit ... what you
have is rather difficult to work with, unless you take the string apart.
(i.e. - How is '7102002' not greater than '6122002'?)
For simplicity  ease, I work with date strings formatted as MMDD.
If your files were named something-full-MMDD, you could get a sorted
array of your files easily.

$interestingFiles = array();
$dir = opendir( /path/to/directory ) or die( Could not open dir );
while( $dirEntry = readdir( $dir ) ){
  if( ereg( full-([0-9]{8}), $dirEntry, $MATCH ) ){
   $interestingFiles[$MATCH[1]] = $dirEntry;
  }
}
ksort( $interestingFiles );

g.luck,
~Chris


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




Re: [PHP] ob_output

2002-11-22 Thread Chris Wesley
On Fri, 22 Nov 2002, Uros Gruber wrote:

 ob_end_flush();

This turns off output buffering after flushing, the first time it gets
called in the first iteration of your for() loop.

 I can make this work on php and apache. I always get output
 in one shot not line by line. If i try this code with php and
 iis it works.

Try using ob_flush() instead.  http://www.php.net/ob_flush
This function does not destroy the output buffer like ob_end_flush()
 does.

What's odd is that it works like you want it to in IIS 

g.luck,
~Chris


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




Re: [PHP] ill sprintf() behavior w/ HEX type

2002-11-21 Thread Chris Wesley
On Thu, 21 Nov 2002, Jason Wong wrote:

 That's because it's expecting a _decimal_ and will automatically convert it to
 hex for you.

AH!  Must've been a longer day than I thought ... dunno how that escaped
me.  Somehow I was reading x - the argument is treated as in integer and
presented as a hexadecimal number as if it meant the function would
recognize the argument as a integer, even though it's in hex format
(resembling a string).

Thanks for clearing that up for me!
~Chris


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




Re: [PHP] Why $ on variable names?

2002-11-12 Thread Chris Wesley
On Tue, 12 Nov 2002, brucedickey wrote:

 I've searched, but haven't found the answer -- from a language design point
 of view, why are there $ on the front of PHP variable names?

... so Perl converts know where there variables are ;)

~Chris


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




Re: [PHP] Lynx/Apache PHP execution vs. PHP interpreter

2002-11-08 Thread Chris Wesley
On Fri, 8 Nov 2002, Jason Young wrote:

 I've edited the reporting functions so that instead of throwing it up on
 the console like it normally does, it instead calls lynx with the -dump
 parameter to the PHP page, and that in turn puts the variables into a
 DB... (Basically I can access my full CallerID information from anywhere)

 My question is ... is there any difference for me to call system() to
 lynx, or for me to call the PHP interpreter directly? I've noticed a lot

Not getting lynx involved would improve performance.  (system() off a
process that does an HTTP GET/POST to your web server w/ a script parser
... bit of an expensive operation to get a piece of data into a database.)

It'd be more straight forward to have elcid insert into your DB.
Then you could reserve your PHP scripts for displaying what's in the DB.

g.luck
~Chris


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




[PHP] XSLT failing when DOCTYPE declaration present

2002-11-07 Thread Chris Wesley
I'm using the xslt capabilities in PHP 4.2.2 and running into an odd
problem.  I'm transforming an XML document which has a DOCTYPE
declaration referencing an external DTD.

!DOCTYPE RootNode SYSTEM http://my.host.org/foo.dtd;

When I have xslt_process() attempt to transform the XML document, with an
XSL document I provide, it fails.  These are the errors I get back from
xslt_error()  xslt_errno.
  error: XML parser error 4: not well-formed (invalid token).
  errno: 2

If I remove the DOCTYPE declaration from the XML, xslt_process() has no
problem transforming the XML.

If I change the DOCTYPE declaration to:
!DOCTYPE RootNode SYSTEM file:///path/to/docroot/foo.dtd
then xslt_process() has no problem transfoming the XML.

However, I need to make this work with the external DTD reference being to
some other host (http://other.my.host.org/foo.dtd).
Has anyone gotten this to work properly, have any insight into the error
information above, or know what I might have to do differently?

THX,
~Chris


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




Re: [PHP] Code Advice

2002-11-06 Thread Chris Wesley
On Wed, 6 Nov 2002, Jason Young wrote:

 So then can anyone tell me why its working so far? ;)

It doesn't work at all like you want it to.  I assume you've already put
this script up on a web server to test, so watch this:

After this line:
$$key = $val;
Insert this line for debugging:
echo $key .  --  . $val . br\n;

Then visit the script:

scriptname.php?foo=22=1

You've created something far worse than register globals.

Someone already posted a decent solution, something like this:
foreach( $get_allow as $get_key = $get_val ){
if( isset( $_GET[$get_val] ) ){
${$get_val} = $_GET[$get_val];
echo $get_val .  --  . $_GET[$get_val] . br\n;
}
}

g.luck,
~Chris



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




Re: [PHP] how to user select multiple=true

2002-10-15 Thread Chris Wesley

On Wed, 16 Oct 2002, Khalid El-Kary wrote:

 If i have a form that has a select with multiple=ture how would i be
 able to retireve it's multiple values in the PHP script, i tried the
 $_REQUEST['fieldname'] it gave me only the last selected value

You need to make sure you get back an array holding the select element's
data.  Do this by naming the select element like this, name=choose[].
When selecting multiple values, they'll be in the $_REQUEST[choose] array.

See this for an example (I used $_POST instead of $_REQUEST):
http://www.cwwesley.net/code/php/combobox/combobox.php

~Chris


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




Re: [PHP] Just cant figure out how this could be happening...

2002-10-03 Thread Chris Wesley

SELECT CURDATE() - 14 ... this isn't doing what you think it's doing.

The CURDATE() function returns a string like 2002-10-03.
Subtracting 14 from that gets you 20020989 as a result from MySQL.
Pretty useless, right?  If that ever worked for you, it was a total
coincidence.

Try this instead:
  SELECT DATE_SUB( CURDATE(), INTERVAL 14 DAY )
That will get you the date from 14 days ago.

See the MySQL manual for descriptions of the functions.
I'm sure that the MySQL site has references to MySQL mailing lists too, to
help with MySQL questions.

g.luck,
~Chris

On Thu, 3 Oct 2002, Owen Parker wrote:

 hi all

 have a really simple query:

 $twowksworth = mysql_query(SELECT updates.MODELCODE, updates.SETNO,
 updates.FRPICNO, updates.TOPICNO, updates.CPOSTDATE, updates.ZIPFILENAME,
 updates.TOTPICS, models.MODELNAME FROM updates LEFT JOIN models ON
 updates.MODELCODE = models.MODELCODE WHERE updates.CPOSTDATE = (
 CURDATE() - 14 )AND updates.CPOSTDATE = CURDATE() ORDER BY
 updates.CPOSTDATE  ) ;

 When this was originally written it worked like a charm.  I purposefully
 let it 'run out' of data by not adding any more to the table.  each day for
 two weeks the list resulting from this query got shorter as expected.  The
 day after there was no data, it started listing the entire contents of the
 table.  What the...

 So i added a few weeks worth of data and now it correctly cuts off at
 today's dat but it completely ignores the curdate() - 14 portion and lists
 the entire table up to today's date.

 this is so basic i cant figure it out.  besides, it used to work.  what
 gives?  I'm really new to php and mysql, but until now felt i had made good
 progress in the past couple
 weeks.  just cant figure out how to troubleshoot this error due to lack of
 experience and knowledge.

 is there something really basic i am missing here?  any pointers would be
 greatly appreciated!!

 tia

 owen






 --
 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] checkbox objects returning false for isset() when submittedvia a form.

2002-10-01 Thread Chris Wesley

On Tue, 1 Oct 2002, DonPro wrote:

 Within my form, I have some checkbox objects.  If I check them and submit my
 form, isset(variable) returns true.  However, if I do not check them and
 submit my form, isset(variable) returns false.
 I am confused as I though that isset() returns true if the variable exists
 regardless if it is empty or not.  Is there a way to do what I want?

Checkbox values are only sent if they are on (checked).

http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.2

~Chris


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




Re: [PHP] Re: submitting a form to multiple places!

2002-10-01 Thread Chris Wesley

Your problem is tough to understand.  Submitting form data to multiple
places isn't normal, and your need to do so wasn't clear to me.
When you have total control of your environment, the need to re-submit
submitted data is superfluous.

If you must have a PHP script that handles submitted data and also submits
it to someplace else, check out the CURL functions.  You can create any
kind of HTTP transaction you like with CURL in a PHP script, including a
form submission.   http://www.php.net/manual/en/ref.curl.php

g.luck,
~Chris

On Tue, 1 Oct 2002, Henry wrote:

 No takers?

 Is this such a difficult problem?

 Please help.

 Henry

 Henry [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hi All,
 
  I have a problem that I hope you can help me with.
 
  I'm using a third party shopping cart solution which is quite frankly
 naff.
  They bundle some autoresponders with it. Unfortunately the autoresponders
 do
  not work!.  I want to find a temporary solution  to this. The easiest way
  would be to allow a form to be submitted to more than one place!
 
  Basically I would lke to have an intermediate php page that will submit
 the
  details (submitted to it) to two other pages and then follow the response
 of
  one of those other pages (the primary page). That way I can insert a
  different autoresponder handling system into the submission process but
  continue to use the shopping carts pages for the time being.
 
  Any suggestions?
 
  Henry
 
 



 --
 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] PHP version

2002-10-01 Thread Chris Wesley

On Tue, 1 Oct 2002, Alex Shi wrote:

 Is there any way to report PHP version?

Sure.  What version of PHP are you using?  ;)

~Chris

P.S. - if you didn't find that amusing, just check out
   http://www.php.net/manual/en/function.phpversion.php


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




Re: [PHP] HELP - fwrite(...PHP code...)

2002-09-12 Thread Chris Wesley

On Thu, 12 Sep 2002, Hankley, Chip wrote:

 fwrite($fp, ? echo $LayerScale);
 If $LayerScale is defined, then fwrite outputs the value of $LayerScale to
 the target, NOT the string $LayerScale.
 How can I overcome this?

fwrite($fp, ? echo \$LayerScale);

g.luck,
~Chris


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




Re: [PHP] Problem updating post on a basic weblog system

2002-09-12 Thread Chris Wesley

code snippet
   if ($post == post) {
  postBlog ($post,$input,$title);
   }elseif ($post == edit){

  updateBlog ($input,$edit_post);  //   BINGO!
   }
/code snippet

Just looking at the code you posted to your site, there's only one thing
obvious to me: You want to use $edit_blog in that call to updateBlog
instead of $edit_post?

g.luck,
~Chris

On Thu, 12 Sep 2002, Jesse Lawrence wrote:

 Hello all,

 I've got a bit of a code problem that's been baffling
 me for a while now.

 I'm working on a basic weblog system for personal use,
 using MySQL.  I've got the new post and delete a
 post aspects working fine, but for some reason, I
 can't get the update a post part happening.

 What happens is I select a post to update, and then
 the post comes up in a textarea box.  You then make
 your update, and submit.

 Doing this calls the following function:

  function updateBlog($input,$edit_blog) {


  include 'db_connect.php';
 $update_query = update $table set blog='$input'
 where id='$edit_blog';
 if(mysql_db_query ($database, $update_query,
 $link)) {
print Successfully Edited!!;
 }else{
 print no;

 }

  The variables being passed to the function are:
   $input = The body of the post
  and
   $edit_blog =  id # of post

 At this point everything appears to have been a
 success.  The Successfully Edited!! confirmation
 appears, and everything seems fine, but when I look at
 my database, nothing has been updated or changed in
 any way.

 Does anyone have any suggestions or help they could
 lend me?  I've been facing this problem for a while
 now, and can't seem to get my head around it.

 You can view the entire code here:
 http://soniceast.d2g.ca/~jalaw/blog/admin.txt


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




Re: [PHP] PERMISSIONS

2002-09-12 Thread Chris Wesley

On Thu, 12 Sep 2002, Breno Cardoso Perucchi wrote:

 system(mkdir /home/hosting/test);
 but the PERMISSION IS DENIED and I am the root on my server.
 How I change the user to root?

Dude, you don't change to the root user ... you'll get yourself owned that
way.  Change the permissions on the directory to allow the web server's
user to write files and create subdirectories.

For example, most of my boxen run apache as user 'www-data' --
# chown root:www-data /home/hosting
# chmod 2775 /home/hosting

~Chris


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




Re: [PHP] header question

2002-09-11 Thread Chris Wesley

On Wed, 11 Sep 2002, Meltem Demirkus wrote:

 I want to know if there is any way to send data in
 header(Location:login.php) .I know how to send like this   a
 href=\login.php?id=$ID\  but I need to use header and I dont know howto
 do this?...

header( Location: login.php?id=${ID} );

~Chris


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




Re: [PHP] split() - not working in this case

2002-09-08 Thread Chris Wesley

On Sun, 8 Sep 2002, N. Pari Purna Chand wrote:

 $to =  abcd [EMAIL PROTECTED], efgh [EMAIL PROTECTED] ;

 Now split() in the following function*** is notworking as needed.
 ie, I'm getting
 $tos[0] = abcd;
 $tos[1] = efgh;

split didn't do anything wrong.  use your browser's view source to see
the desired output.  funny things, those less-than  greater-than
characters ... they make browsers think you've created an HTML tag!

Two things you can do to make displaying such data in a browser:

1) if you're trying to display text that has HTML entities in it,
   within a HTML page, use the htmlentities() function when
   printing output.   http://www.php.net/htmlentities

2) if you don't care about HTML at all, send a Content-type header that
   tells the browser what you're sending is text.
   header( Content-type: text/plain );

g.luck,
~Chris





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




Re: [PHP] XSLT - Sablotron

2002-09-05 Thread Chris Wesley

On Thu, 5 Sep 2002, Devin Atencio wrote:

 I am trying to find out a way I can pass a variable that is basically
 an XML document to xslt_process and make it all work. My script

$xmldata = a whole boatload of well-formed XML;
$xsltArgs = array( '/_xml' = $xmlStr );
$xp = xslt_create();
$result = xslt_process( $xp, 'arg:/_xml', 'file.xsl', NULL, $xsltArgs );

Don't waste the code/resources on putting the xml into a file.

g.luck,
~Chris


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




Re: [PHP] Function expects string but receiving array Warming??

2002-09-03 Thread Chris Wesley

On Tue, 3 Sep 2002, Jean-Christian Imbeault wrote:

 Warning: header() expects parameter 1 to be string, array given in
 /www/htdocs/jc/administration/edit_products/show_products.php on line 96

 How can I fix my code to get rid of this error (while keeping the var as
 an array)?My code looks like this:

 header(array(ID,Name,Maker's Code,Maker Name,Label Name,Product Type));

header() is a PHP function.  You're calling it with an invalid arguement.
(I think you're just calling the function you want by the wrong name, tho.)

 function header_row($aH) {

Try calling header_row(), instead of header(), with your array argument,
since it seems that you already have the proper function defined.

g.luck,
~Chris


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




Re: [PHP] help, array values echoed as Array on loop!

2002-09-02 Thread Chris Wesley

On Mon, 2 Sep 2002, Victor wrote:

 $ID_arr[] = explode(',', $pictures); # make db data into array
 This is the string:
 15,16,17,18,19

 why does it echo as Array?

... because you've created an array ($ID_arr) with an array as the first
value (the result of the call to explode()).  Take the brackets off
$ID_arr, and you'll get what you want.  You don't want your array in an
array ... you just want an array.

$ID_arr = explode(',', $pictures);

If you really wanted your array in the array, then loop over $ID_arr[0].
(I doubt that's what you were going for, though.)

hth,
~Chris



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




Re: [PHP] problems with cookies

2002-09-02 Thread Chris Wesley

A couple problems may exist:

1) If you're trying to do this all in the same script, it's not going to
  work.  You can't set a cookie and use it (with the value you've just
  set) in the same script (in the same request).  You can only use cookies
  that have been sent back to your script from the browser.  If you
  require the use of a cookie value you're trying to set, use your local
  variable's value, instead of trying to get the cookie.

2) I'm pretty sure there is not timeset() function in php.

setcookie(cookiename1,$domin,timeset()+1800);

   And you've used it as a quoted string ... set a very funky, if not very
   invalid, expiry time, and hence didn't set the cookie at all.  Try this
   instead:   setcookie( cookiename1, $domin, time()+1800 );

   On a different request, you can retrieve $_COOKIE['cookiename1']

g.luck,
~Chris

On Mon, 2 Sep 2002, skitum wrote:

 Hi all,

 I'm using a cookie like this:
 setcookie(cookiename1,$domin,timeset()+1800); at the top of my
 script. $domin is a text field that belongs to a post form. This
 form is in function one(); well, i try use $domin in function
 two(); writing $_COOKIE['cookiename1']; Here you are the code:

 ?
 setcookie(cookiename1,$domin,timeset()+1800);
 $cookiename1=$domin;
 echo $cookiename1; // here it works
 ?
 --- HTML code ---
 ?
 function one(){
 ?
 --- HTML code ---
 input name=domin type=text size=40 maxlength=63
 --- HTML code ---
 ?
 }
 function two(){
 $othervar=$_COOKIE['cookiename1'];
 echo $othervar; // here it doesn't work
 ?
 --- HTML code ---
 ?
 }
 ?
 --- HTML code ---

 What am I doing wrong?  Any tips?  Any Ideas?
 Thanks for help

 Peace  Love
 skitum



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




Re: [PHP] empty php.ini

2002-09-02 Thread Chris Wesley

On Mon, 2 Sep 2002, timo stamm wrote:

 I am new to PHP. I am running the module version 4.2.2 from Marc
 Lyanage (entropy.ch) on OS X 10.1 and noticed that my
 /usr/local/lib/php.ini is empty!?

... that package doesn't ship with a php.ini.  You'll have to get/make
your own.

 Is there a way

Haha ... I'm sure there is.

Get one from a knowledgable friend, or download one from php's cvs server.
http://cvs.php.net/cvs.php/php4/php.ini-dist

g.luck,
~Chris


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




Re: [PHP] Arrays misbehaving!

2002-08-30 Thread Chris Wesley

On Fri, 30 Aug 2002, Cameron Thorne wrote:

 Can anyone explain why the following code operates the way it does in my
 comments?

Sure.

 ?php

 $test = array ( 'a' = 'A', 'b' = 'B', 'c' = 'C');

An associative array, $test.


 if (array_key_exists(2, $test)) echo It works by key number!;  // Does not
 work.

... for subjective definitions of work.  It works alright.  Nothing
prints because there isn't an array key '2' in $test.

 if (array_key_exists('c', $test)) echo It works by key name!;  // Works.

Of course.

 print_r(array_keys($test));// outputs Array ( [0] = a [1] = b [2] =
 c ) 

You've done two things with this statement.  (1) Got all the keys from
$test, then (2) printed out the keys in human readable format.
print_r() is printing information about the array which was returned from
the call to array_keys().

Examine the output from print_r($test) and check the documentation for
print_r()  array_keys() to get a glimpse into what might be the source
of what's got you a bit confused.

 ?

 Any ideas?  According to the documentation, it seems like I should be able
 to access any key in the array by either name or number (which is what I
 want to do).

You can access array indicies by number for non-associative arrays:
$test = array( A, B, C, D );
OR associative arrays that use numbers for keys:
$test = array( 0 = A, 1 = B, 3 = C, 4 = D );

echo( $test[2] ); ... will work for either of those,
but the indicies of your original $test:
 $test = array ( 'a' = 'A', 'b' = 'B', 'c' = 'C');
have to accessed with the appropriate key.

hth,
~Chris


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




Re: [PHP] Arrays misbehaving!

2002-08-30 Thread Chris Wesley

On Fri, 30 Aug 2002, Cameron Thorne wrote:

 I was hoping I could access by either name OR number, but apparently not.

Just for kicks ... here's something pretty ugly (I'd never use it), but
neat if you're interested (or somehow really have your heart set on using
integers).  There are probably a handful of other ways to do this:

$test = array ( 'a' = 'A', 'b' = 'B', 'c' = 'C');
$test_keys = array_keys( $test );
print $test[$test_keys[2]];  // Prints C - Same as print $test['c'];

~Chris


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




Re: [PHP] Encrypting Passwords - Is it really necessary??

2002-07-29 Thread Chris Wesley

On Mon, 29 Jul 2002, Monty wrote:

 Is it really necessary to store passwords encrypted in a mySQL DB for a
 membership site if you're not storing sensitive info such as credit card
 numbers? How much security does that offer, really, and for whom?

I'm going to go with YES on this one.  The problem with being able to
retrieve actual passwords from your database is this:  Most people re-use
passwords across multiple applications.  So, while you may fully intend to
stash passwords access to only your application, you may actually be
storing passwords to people's online banks, work logons, pr0n sites, etc.

You can save yourself a lot of time in the future by taking a little time
now to make sure that plain-text passwords are not retrievable from your
application/database.  If your database server were to be compromised, you
can rest assured that you didn't leak any passwords.  Otherwise, you'll
have to really worry that somebody didn't walk away with a list of names,
usernames and passwords that could be used elsewhere.

 The reason I ask is because I'm trying to implement a forgot password
 feature on a membership site. But if I store passwords encrypted, I can't
 just send the password to their e-mail address, I have to generate a new one
 before sending it, which essentially locks that member out of the site until
 they get their new password. This has the potential to be abused by a
 vindictive person. All they need to know is the member's username or e-mail
 address and they can keep re-generating new passwords (locking the member
 out of their own account) for a member to annoy them.

While this is true, what I've found in practice is that this rarely
happens (actually hasn't happend yet, for my sites ... knock on wood).
If you find that this becomes a problem, some logic around how often, and
by what method passwords can be changed may help alleviate the problem.

g.luck,
~Chris


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




Re: [PHP] Paying Job...

2002-07-25 Thread Chris Wesley

On Thu, 25 Jul 2002, Gerard Samuel wrote:

 Do you charge by the page, script or by the hour (that would be nice).

It's a tough thing to do, but consider charging by the project.  You'll
find a most equitable payment/compensation when you establish up front how
valuable the project is to the client, and how valuable your time and
services are.  I find this is the best way to put a client at ease [(s)he
knows what (s)he's paying ... no surprises, unless they're
client-inspired], and you can concentrate on the project instead of how to
make the site fit into X pages or how to justify or fit the project into Y
hours.

Get a couple small projects under your belt, just for the learning
experience, and you'll get a good feel for a process that suits your
needs.

Things I did to get become acquainted with a good process:
- did small projects for free, just to prove (to the client and myself)
  that my code and I can survive
- did small projects for an undervalued price to get my foot in the door
  of potential future paying clients, to build a decent portfolio, and to
  assemble a good list references
- did projects just because I love to code and solve problems, not for the
  cash.  (YMMV.  There are a myriad of reasons I employ this philosophy,
  that I won't preach about here.)

Typically what I try to establish up front:
- the total project specs
- terms on deliverable(s) (how many stages a project is divided into)
- a reasonable estimated time of delivery for each stage, and the project
  as a whole
- documentation requirements
- feature-creep clauses (it's such a pain to have the project change
  in mid-development ... you have to watch your own back for this.)
- maintenance requirements (to fix bugs for X number of days/months after
  delivery ... NOT FOR ADDING FEATURES: do that in separate projects)
- compensation/fees
- payment terms (25% upon delivery of stage1, 100% by stage3, etc.)

For FREE projects ... just leave off the last two points.  Even though a
project may be done pro bono, it should still be relatively chaos-free.
A chaotic project done for free will probably just end up being a waste of
time for your client, and mostly for you.

g.luck,
~Chris


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




Re: [PHP] Difference between executable and Apache server

2002-07-08 Thread Chris Wesley

On Mon, 8 Jul 2002, Jay Blanchard wrote:

 We have some cases where we run PHP as a standalone executable for scripting
 certain processes that can be called from CRON, and we also have PHP for
 Apache. Does the php.ini affect both? Specifically script times?

Check the output of phpinfo() for each and see.  You're looking for the
line that's tagged Configuration File (php.ini) Path.  Usually there are
different files for the module and the cgi.  (i.e. - the packages from
Debian Linux distribution(s) puts separate php.ini files into
/etc/php4/apache and /etc/php4/cgi.)

g.luck,
~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net


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




Re: [PHP] returning more than 1 value from function

2002-07-04 Thread Chris Wesley

On Thu, 4 Jul 2002, andy wrote:

 i am wondering if it is possible to return more than 1 value from a
 function?

You can pass your arguments by reference.

?php
function test( $arg1, $arg2 ){
$arg1 = foo;
$arg2 = bar;
}

$var1 = ;
$var2 = ;

test( $var1, $var2 );  // Note the  before the arguments.
?

The result will be that $var1 == foo and $var2 == bar.

You can mix it up too ... if you want the function to return a value (say,
true or false) AND modify arguments, modify only a subset of the
arguments, etc.

(see http://www.php.net/manual/en/functions.arguments.php)

g.luck,
~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net


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




Re: [PHP] returning more than 1 value from function

2002-07-04 Thread Chris Wesley

Sorry ... busy morning ... I misplaced the  for the reference.  They
should be on the arguments on the function definiton, not the function
call.

?php
function test( $arg1, $arg2 ){  // Note the  before the arguments.
$arg1 = foo;
$arg2 = bar;
}

$var1 = ;
$var2 = ;

test( $var1, $var2 );
?

Sorry if I caused any confusion.

~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Thu, 4 Jul 2002, Chris Wesley wrote:

 On Thu, 4 Jul 2002, andy wrote:

  i am wondering if it is possible to return more than 1 value from a
  function?

 You can pass your arguments by reference.

 ?php
 function test( $arg1, $arg2 ){
   $arg1 = foo;
   $arg2 = bar;
 }

 $var1 = ;
 $var2 = ;

 test( $var1, $var2 );  // Note the  before the arguments.
 ?

 The result will be that $var1 == foo and $var2 == bar.

 You can mix it up too ... if you want the function to return a value (say,
 true or false) AND modify arguments, modify only a subset of the
 arguments, etc.

 (see http://www.php.net/manual/en/functions.arguments.php)

   g.luck,
 ~Chris /\
\ / Microsoft Security Specialist:
 X  The moron in Oxymoron.
/ \ http://www.thebackrow.net




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




Re: [PHP] Question about using XSLT_Process?

2002-07-03 Thread Chris Wesley

You just need the XML and/or XSL as a string.  xmldoc() is creating a DOM
object, which xslt_process() can't use.

In you example that does not work properly, change this:

$xsl = xmldoc(implode(,file(test.xsl)));
$xml = xmldoc(implode(,file(test.xml)));

to not use xmldoc(), like this:

$xsl = implode(,file(test.xsl));
$xml = implode(,file(test.xml));

xslt_process() should be happy with the strings in the arguments array.

g.luck,
~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Wed, 3 Jul 2002 [EMAIL PROTECTED] wrote:

 Hello,

 I'm trying to use xslt_process with $arguments like in the third example in
 the online documentation, but I'm not having any luck.  I can run the same
 .xml and .xsl using the simple examples, but I cannot when using the
 $arguments example.  I would really like to get this figured out, but I've
 run into a brick wall and I can't seem to understand why it doesn't work.

 I've pasted my .xml, .xsl and .php files below.

 Thanks,

 John



 This does transform the xml and produce results:
 ---
 ?php
 // Create an XSLT processor
 $xh = xslt_create();
 xslt_set_base($xh, file://D:/Inetpub/wwwroot/phpxml/);

 // NEED TO FIGURE OUT HOW TO SPECIFY THE INPUT XML and XSL FILE LOCATIONS!!!

 // Process the XML
 $result = xslt_process($xh, 'test.XML', 'test.xsl');
 if ($result){
 //print SUCCESS, book.xml was transformed by book.xsl into
 result.xml;
 //print result.xml has the following contents\nbr/\n;
 //print pre\n;
   print $result;
 //print /pre;
 }
 else {
   print Sorry, failure!;
   print br/;
   echo xslt_error($xh);
   print br/;
   echo xslt_errno($xh);
 }

 xslt_free($xh);
 ?
 ---



 This does not:
 ---
 ?php
 echo one;
 // Grab the XSL and XML files
 $xsl = xmldoc(implode(,file(test.xsl)));
 $xml = xmldoc(implode(,file(test.xml)));

 // Set up the Arguments thingy
 $args = array(
   '/_xml'=$xml,
   '/_xsl'=$xsl
   );

 // Create an XSLT processor
 $xh = xslt_create();

 // Process the XML
 $result = xslt_process($xh, 'arg:/_xsl', 'arg:/_xml', null, $args);
 //$result = xslt_process($xh, 'files\book.XML', 'files\book.xsl', NULL,
 $args);

 if ($result){
 //print SUCCESS, book.xml was transformed by book.xsl into
 result.xml;
 //print result.xml has the following contents\nbr/\n;
   print h2 Yes! /h2\n;
   print pre\n;
   print $result;
   print /pre;
 }
 else {
   print Sorry, failure!\n;
   print br/\n;
   echo xslt_error($xh);
   print br/\n;
   echo xslt_errno($xh);
 }

 xslt_free($xh);
 ?
 ---

 The XML File:
 ---
 ?xml version=1.0 encoding=UTF-8?

 book

  !-- Title of the book --
  titleProfessional Php Programming (Programmer to Programmer)/title

  !-- Authors of the book --
  textThis book has been authored by:/text
  authors
author number=1Sascha Schumann/author
author number=2Harish Rawat/author
author number=3Jesus M. Castagnetto/author
author number=4Deepak T. Veliath/author
  /authors

  !-- Image of the book --
  textA picture of the book's cover: /text

 picturehttp://images.amazon.com/images/P/1861002963.01.MZZZ.jpg/pictu
 re

  !-- Pricing info--
  textThe pricing of the book is as follows:/text
  prices
priceList price: $49.99/price
priceOur price: $39.99/price
priceYou save: $10.00/price
  /prices

  !-- Other misc info--
  textHere is some sundry info about the book:/text
  bookinfo
  typePaperback/type
  amazonrank6,337/amazonrank
  pages909/pages
  publisherWrox Press/publisher
  isbn1861002963/isbn
  size2.00 x 9.16 x 7.30/size

 urlhttp://www.amazon.com/exec/obidos/ASIN/1861002963/o/qid=986194881/sr=8-
 1/ref=aps_sr_b_1_1/107-4263716-8514955/url
  /bookinfo

 /book
 ---

 The XSL File:
 ---
 ?xml version=1.0 encoding=UTF-8?
 xsl:stylesheet version=1.0
 xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
 xmlns:fo=http://www.w3.org/1999/XSL/Format;

 xsl:template match=/
   htmlbody
 xsl:apply-templates/
   /body/html
 /xsl:template

 !-- This is the title of the page --
 xsl:template match=title
   bu
 xsl:value-of select=./
   /u/b
 /xsl:template

 xsl:template match=text
   p/nbsp;b
 xsl:value-of select=./
   /bbr/
 /xsl:template

 xsl:template match=authors
   table
 xsl:apply-templates/
   

Re: [PHP] Code Troubles

2002-04-26 Thread Chris Wesley

 if ($db!= and !@mysql_select_db($db))
 die(The site database is unavailable.);

you probably want an or before that die().

g.luck,
~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Fri, 26 Apr 2002, Randum Ian wrote:

 Hi all, Im having trouble with this code, can anyone help?

 ---

 ?php // db.php

 $dbhost = localhost;
 $dbuser = dancepo_db;
 $dbpass = database;

 function dbConnect($db=dancepo_db) {
 global $dbhost, $dbuser, $dbpass;

 $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
 or die(The site database appears to be down.);

 if ($db!= and !@mysql_select_db($db))
 die(The site database is unavailable.);

 return $dbcnx;
 }
 ?

 ---

 Cheers, Ian.
 ---
 Randum Ian
 DJ / Reviewer / Webmaster, DancePortal (UK) Limited
 [EMAIL PROTECTED]
 http://www.danceportal.co.uk
 DancePortal.co.uk - Global dance music media


 --
 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] Code Troubles

2002-04-26 Thread Chris Wesley

if( $db ){
mysql_select_db($db) or die(The site database is unavailable.);
}

To debug, use print( mysql_error ) instead of die to figure out what's
going on.  It's not that far of a leap in logic.

~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Fri, 26 Apr 2002, Miguel Cruz wrote:

 On Fri, 26 Apr 2002, Chris Wesley wrote:
  if ($db!= and !@mysql_select_db($db))
  die(The site database is unavailable.);
 
  you probably want an or before that die().

 How would that work?

 miguel




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




Re: [PHP] embedding php into html

2002-04-24 Thread Chris Wesley

On Wed, 24 Apr 2002, Larry Brown wrote:

 problems.  I have a client whose specific need to to keep the .html
 extention.  I want to embed a php script into the html but the script won't
 run.  I've tried two php enabled servers running apache and neither picks it
 out.  Is there a trick I'm missing?

 Larry S. Brown MCSE

In your Apache config, add .html to the list of extensions handled by php.
e.g. -
AddType application/x-httpd-php .phtml .php .php3 .html .php4

g.luck,
~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net


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




Re: [PHP] HTML select form element

2002-04-12 Thread Chris Wesley

Name your select element majors[] and when the form is submitted, your
form handler will get an array, not a scalar, called $majors.  Step
through the array, and you'll get all the options that were selected.

~Chris /\
   \ / Microsoft Security Specialist:
X  The moron in Oxymoron.
   / \ http://www.thebackrow.net

On Fri, 12 Apr 2002, Brian McLaughlin wrote:

 I have a tag like this on a php-generated web page.

 select name=majors multiple size=6
   option value=ArtArt/option
   option value=BiologyBiology/option
   option value=Business and EconomicsBusiness and Economics/option
etc.
etc.
 /select

 My question is...  since this is a multiple-select list, in the php script
 that this form calls on a submit, how do I determine which options have been
 selected?  If I look at $majors, it is a string whose value is one of the
 several options that were selected.


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