Re: [PHP] string to array

2003-02-12 Thread Steve Werby
Kevin Waterson [EMAIL PROTECTED] wrote:
 What is the best method to convert a string to an array

 I need to able to loop through each letter of the string
 not just use $string[47]

You can find out how long it is using strlen(), then loop through it using
your favorite looping construct.  You could also easily convert it to an
array at that point, but unless you need each character as an array element
for a later operation it doesn't seem very efficient.  I don't think
explode() will let you use a separator of '', but you might look at that as
well.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] numerics

2003-02-10 Thread Steve Werby
Edward Peloke [EMAIL PROTECTED] wrote:
 IS there a way to only allow the user to type in numerics to a text field?
 I do not want to allow them to even type in anything unless it is a
 number.
 Basically, I don't want to allow them to enter hi and then I do checks and
 give them a warning that it isn't a number, I want to force it from the
 start.

PHP is server-side so it can't be accomplished via PHP, but it can via
JavaScript.  Google for something like 'javascript validate numeric'.
Here's JS script that limits entry to alphanumeric characters.  I've seen
better JS code to do the same so if it's not suitable keep looking.

http://javascript.internet.com/forms/val-char.html

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/




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




Re: [PHP] automatically delete records from a table

2003-02-10 Thread Steve Werby
Sunfire [EMAIL PROTECTED] wrote:
 was wondering about how you could run a script that automatically ran at
 midnight every day and deleted records that matched a certain date stored
in
 a mysql table? any ideas how that supposed to work?..

 i think the script has to be a chron task on linux but im not really sure
 how to go about doing such a job..

man cron and man crontab.  If PHP is compiled as a CGI or CLI then you can
call the script directly, otherwise call it via the web using lyxn or wget.
I'd opt for CGI or CLI if at all possible so that you don't need to send a
request to the web server.  I figure you know how to write the script and
that it's just a matter of scheduling it.  If not please be specific about
the problem.  This is asked pretty frequentl on php-general so between the
archives and Google you should find what you're looking for quickly.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] MySQL vs. basic text file

2002-09-23 Thread Steve Werby

Doug Parker [EMAIL PROTECTED] wrote:
 i was wondering
 if there is anything i'm not thinking of that perhaps would push me to
 favor using php and mysql instead of the plain old text file.


It sounds like you're basically asking why one would want to use a
relational database.  Standardization, speed and flexibility for starters.
MySQL and many other databases use the SQL language for accessing db data.
If your dataset is large a SQL statement to return records from indexed
tables will be much faster than code at the application level.  And a
relational database allows you to store data in separate logical tables
instead of one large table - for example tables of products, inventory,
customers and orders.  Using SQL to query these tables to find out something
like the quantity and total revenue of widgets sold in August to customers
in New Jersey whose company name begins with R would be much easier with a
relational database than 1 or more text file datasets.  There are many other
benefits, though that's not to say that text files aren't sufficient for
your current needs.  I recommend reading about relational database online or
in a book and playing with one of the more popular open source databases
such as MySQL or PostgreSQL.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] OT - php/mysql/cron

2002-06-03 Thread Steve Werby

Tobyn Baugher [EMAIL PROTECTED] wrote:
 This line's gonna wrap, but it all goes on the same line :P

 0 0 * * * /usr/local/bin/mysqldump -u username --password=password
 database  outputfile

 Obviously replace username, password, database, and outputfile
 with the values you want to use for each.

 Of course, I would never recommend putting a secure password in a text
 file like your crontab, so if you have admin rights on the server maybe
 consider setting up a read-only account with no password, or maybe a
 unique password that won't work on any other accounts.

Or create a .my.cnf file in the home directory of the user the cron job runs
as, chmod 600 .my.cnf and include the following in it:

[client]
user=mysql_user_here
password=mysql_password_here

Then you don't need to supply the -u and --password parameters to mysqldump.
Only that user can read .my.cnf and you won't need to supply those
parameters to the mysql commandline program or other MySQL programs if you
want to login as that default user.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] Workaround for no cron?

2002-04-07 Thread Steve Werby

Leif K-Brooks [EMAIL PROTECTED] wrote:
 I have to wait for my host to compile php as binary for cron to work with
 php, and a lot of things on my site depend on cron.

It's not my favorite solution from a security standpoint, but you could call
the PHP scripts from cron using wget or lynx.  wget even supports HTTP
authentication and I *think* lynx does as well so you can password protect
the scripts using .htaccess.  And I'm assuming you have cron access since if
you don't, having your host install PHP as a CGI won't cure that.  g

 Does anyone have some
 sort of code that I could put at the top of all my pages so when they get
 visited, it checks to see if a script has been executed yet this time
 petiod, and if not yet, it does?

Better to teach a man to fish...?  Either create a db entry or text file
entry with the timestamp of the last run of the scheduled script and have
your calling scripts check the timestamp to see if it's time to run.

 Or any type of workaround for not having
 cron?  Thanks!

You just need access to a machine (can even be a Windows desktop) which can
launch a URL at a specified time or you just need someone who can do the
same via a cron job on one of their boxes.  Hope that helps.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] Searching 'Help' Text

2002-02-26 Thread Steve Werby

Nick Richardson [EMAIL PROTECTED] wrote:
 So i have a 'help' secion for an app i have done... and i'm lazy, so just
 wanted to check if anyone knows where i can get this:

It's refreshing to see someone who admits his laziness.  g

 I want users to be able to search through the help section for specific
 text... anyone know of a script out there that will do this...?

Maybe the edit, find feature of the user's browser?  Please elaborate on
what you're trying to do.  What you described is very vague.  Is the help
section all on a single page?  Is the text stored in a db?  Do you want the
text matching the user's search term to be highlighted?  ...

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] Difference between two dates

2002-02-20 Thread Steve Werby

Uma Shankari T. [EMAIL PROTECTED] wrote:
 If i gave the str date as 31-01-2001; and  $str1=04-02-2001; then it
 is displaying the wrong result

 Plz tell me how can i rectify this problem...

Uma,

I wrote a function last year that calculates the time between 2 dates in
whatever unit is preferred (everything from seconds to years).  My function
expects the date in a slightly different format, but it would be trivial to
switch the order of the date parts in one line and hard-code something for
the hours, minutes and seconds it expects in the date format.  It wouldn't
matter what you hardcode them as since it would use the same time of day for
both dates.

http://www.befriend.com/code_gallery/php/get_elapsed_time/

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] Timed Jobs.

2002-02-20 Thread Steve Werby

Argh!  Please drop the purple bakground from your email.  HTML email is bad
enough since many of us use mail readers that can't read it, but black on
purple is just plain hard to look at!


webmaster mbtradingco [EMAIL PROTECTED] wrote:
 I was wondering if it is posible to make in PHP a cron job, that will
 trigger an event (i.e. send an e-mail) long after the process of the
 data has taken place, like programming an e-mail to go out, on an
 specified date.

I recommend inserting the data into a database (perhaps MySQL) which
includes the email data, recipients and date/time to send.  Then setup a
cron job which to run every X minutes which checks for pending emails, runs
them after the date/time has been reached and either deletes the records
when complete, moves them to a different table or changes a status flag so
the next query won't process the same records.  Personally, I'd install PHP
as a CGI to do it, but if you can't or want to avoid that you could use wget
or lynx to call the script over the web (of course you could always use perl
or your favorite scripting language).  If you do that, you should consider
password protecting the script so others can't access it.  Others accessing
it may not be a security risk, but it could add load you don't want.  Both
lynx and wget allow you to pass a HTTP user/password.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] mass mail

2002-02-20 Thread Steve Werby

Kancha . [EMAIL PROTECTED] wrote:
 I've users in a database classified by differnet
 catagories. Now based on category I need to send mail
 to all the users in a category.

 Calling mail() function in a loop would be a kill for
 the server as there are more than 1000 users in each
 category.

 Is there any way of doing this ?? Creating a mailing
 list is not possible.

You may want to use a PHP class that uses SMTP directly.  There's one
Manuel Lemos has written one which is available at
http://phpclasses.upperdesign.com/.  Another option is to write the emails
and recipients to a database and use a cron job to query the db every X
minutes and deliver the messages Y recipients at a time until complete.
You'd just need to flag the messages and recipients after they've been
processed or delete them.  I discussed the solution in a reply to a poster
with a slightly different problem just a few minutes ago under the subject
Timed Jobs.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] Chatroom sounds

2002-02-20 Thread Steve Werby

Mick Fitzpatrick [EMAIL PROTECTED] wrote:
 This my first post and I hope I can understand any replies :-)

 I download a chatroom from webscriptsworld.com  very nice it is as
well.

 What I would achieve is to make a sound when someone enters and when
someone
 leaves. I'd also like to to replace some words with sounds. I was hoping
 there might be some code I can add to achieve this?

 Sorry in advance for any lack of tech speak

Well, tech speak isn't the problem.  It sounds like you need a solution that
uses JavaScript or Flash, not PHP.  You'll probably get better help if you
post a URL to the specific chatroom script you're talking about and post to
a list that deals with JavaScript or Flash.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] Pulling Variables from URL

2002-02-20 Thread Steve Werby

Phillip S. Baker [EMAIL PROTECTED] wrote:
 Is there an easy way to pull all the variables after the URL?

 Let use say that the page I am looking at is this.

 www.somewhere.com/pages.php?id=27color=redbgcolor=green

 Now on the page I want a link to have the 3 variables from above.
 I know I can do this.
 a href=another_page.php?id=?php echo $id ?color=?php echo $color
 ?bgcolor=?php echo $bgcolor ?Click Here/a

 But I am wondering if there is a basica funciton or call I can use to pull
 all the values and variables.
 So the code might be as simple as

 a href=another_page.php??php call_to_some_function(); ?Click
Here/a

phpinfo(); is your friend.  Insert into a PHP script which has a query
string (the part of the URL after the ?) and look at the environment
variables available and listed in the output generated by phpinfo().  The
variable you're looking for is $QUERY_STRING, but you really should get
familiar with all of the other variables available since there are many that
are quite useful.  Also see parse_url() in the manual since it lets you grab
each of the URL's components separately and you can supply the URL as
$SCRIPT_URI, $SCRIPT_URL or something similar.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] Pulling Variables from URL

2002-02-20 Thread Steve Werby

Phillip S. Baker [EMAIL PROTECTED] wrote:
 Thanks that is what I needed.
 I am starting to learn more about phpinfo.

 Is there a really good place that documents all the options and variables
 and such?

You can find info about the environment variables and PHP variables in the
PHP manual and apache.org (assuming you run Apache webserver).  I'm sure a
quick search of google or a few Linux / PHP tutorial sites will turn
something up.  I don't have any references offhand.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



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




Re: [PHP] md5 decrypt

2001-12-05 Thread Steve Werby

Dan McCullough [EMAIL PROTECTED] wrote:
 Is there away to take a md5 encrypted password and decrypt it and give
that to the client, if they
 fogot their password.

Short answer is no, long answer below.  I just answered this on another list
10 minutes ago so I'm pasting in part of my reply unedited.

You could use something like John the Ripper, which is a password cracker
you can install on the server.  It works by taking a list of words,
word-number combinations, etc. from a dictionary and encrypting them, then
comparing the encrypted results with the encrypted passwords stored on your
server.  If there's a match it notes the cracked password.  It's good for
detecting weak passwords and can actually detect them very quickly, but if
the passwords are strong then it's not effective for your purposes (that's a
good thing) since by the time it cracked the password (if it did) your user
would have likely taken their business elsewhere.  On a few servers I manage
I run it periodically to check for weak passwords, then I contact the users
with weak passwords and ask that they change them.

John the Ripper: http://www.openwall.com/john/

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Logic

2001-12-04 Thread Steve Werby

Dan McCullough [EMAIL PROTECTED] wrote:
 Question.  I am trying to check to see if a certain piece of code should
be run.  Here is an
 example.
 if ($type != add) || ($type != edit) || ($type != delete) {//if this
or this or this then
 then run this code

As pointed out, your paranthesis will give an error.  Also, || means OR and
I suspect you mean  which means AND.  Why?  Go through the logic and
you'll see that no matter what $type is, one of the 3 inequalities will be
true and since you use an || the entire if statement will evaluate to true.
Not what you want.

It might be easier to edit and follow your code if you rewrite as:

if ( ! in_array( $type, array( 'add', 'edit', 'delete' ) ) )
{
}

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] howto run shell script

2001-12-03 Thread Steve Werby

Danar Prabandaru [EMAIL PROTECTED] wrote:
how do I run a shell script from PHP web interface??
 
assume /path/to/my/script.sh as the path and the owner and group of
this script are belong to apache

See exec(), system(), etc.

-- 
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Good host needed

2001-11-29 Thread Steve Werby

Rudi Ahlers [EMAIL PROTECTED] wrote:
 I know this is OT, but I don't know where else to ask. I'm in South
Africa,
 and I'm looking for a GOOD webserver host in the States.

I suggest visiting http://www.webhostingtalk.com/ and searching the archives
in the dedicated hosting forum and then posting to that forum with specific
questions.  With thousands of members and tens of thousands of messages
about hosting it's a better place to do your homework.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] What kind of looping ?

2001-11-27 Thread Steve Werby

Steve Maroney [EMAIL PROTECTED] wrote:
  Now $file_list[] has some number a file names. I want print 4 file names
 into a row. Each file name has to be in its on cell.

  table
   tr tdFILE 0/td tdFILE 1/td tdFILE 2/td tdFILE 3/td
/tr
   tr tdFILE 4/td tdFILE 5/td tdFILE 6/td tdFILE 7/td
/tr
  /table

 I would image I would use a for loop, but I cant figure it out.
 Can somone assist me ?

The % (modulus) operator is the key to this type of looping.  I didn't test
the code below, but I've done this enough times that I'm pretty sure it's
correct.  If not it should be pretty easy to correct after you test it.

$columns = 4;
$array_count = count( $file_list );

for ( $i = 0; $i  $array_count; $i++ )
{
if ( $i % $columns == 0 ) { $o .= 'tr'; }
$o .= td{$file_list[$i]}/td;
if ( $i % $columns == $columns - 1 ) { $o .= '/tr'; }
}

// Create blank table cells if final row doesn't use all columns.
// You can get away without this on broken browsers like IE, but
// then you'll generate invalid HTML and browsers like NS
// won't display your pages.
if ( $array_count % $columns  0 )
{
$o .= str_repeat( tdnbsp;/td, $columns - ( $array_count %
$columns ) ) . /tr;
}

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Directory Contents Listing

2001-11-27 Thread Steve Werby

Deependra B. Tandukar [EMAIL PROTECTED] wrote:
 How do I display the directory contents using PHP?

See readdir() in the online manual.  I'm pretty sure it even has example
code you could paste in.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how to transfer a local DB to a DB on Server ?

2001-11-27 Thread Steve Werby

trongduc [EMAIL PROTECTED] wrote:
 does anyone know ?
 pls help me, thanks...

Very open-ended, do you have some details?  What type of database?  Is this
really PHP related?  The short answer is to use a program to generate SQL
statements for all of the source db's tables and pipe the SQL statements to
the target db to recreate the database.  For example, mysqldump and pg_dump
are available for mysql and postgresql respectively.  Or if your db supports
it and the source and target machines are similar you may be able to copy
the database files directly from the source machine to the destination
machine using FTP.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: failure notice

2001-11-26 Thread Steve Werby

[EMAIL PROTECTED] wrote:
 For those running php 4 on raq 3, how did you compile freetype?

 ./configure
 make
 make install

 or just 2 make's?

Read the INSTALL file for freetype.  2.0.4 says:

make setup
make
make install

Then install PHP with the options you need in ./configure.  You'll get
better bang for your buck searching the archives for cobalt-users and
posting there.  After all, *everyone* on that list runs Cobalt servers
whereas probably only a small percentage do on the PHP list.  See archives
at marc.theaimsgroup.com and list subscription at www.cobalt.com.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Installing PHP 4 on a RAQ3

2001-11-25 Thread Steve Werby

Miles Thompson [EMAIL PROTECTED] wrote:
 You mentioned .pkg files, might Cobalt be using a Debian distribution? Log
 in and try executing dpkg or dselect -- it could be that Cobalt have the
 installation pointing only to their server. If so, go to the Debian web
 site and locate some additional servers.

Cobalt (which became a division of Sun earlier this year) runs a modified
Redhat distribution.  The RaQ4 runs 6.2, RaQ2 runs 5.2 and I'm not sure on
the RaQ3, but I believe it's 6.1 (again, a modified version, not the full
standard version).  The pkg file is not a Debian format.  Instead of
searching the PHP archives I'd recommend searching the cobalt-users archives
and joining the cobalt-users list.  The AIMS Group site has a searchable
archive of the list.  Instructions, hints and tips have been posted there
many times.  I've installed PHP countless times on dozens of Cobalt boxes so
it definitely can be done.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] floating point exception after php 4 upgrade on raq 2

2001-11-20 Thread Steve Werby

Paul Schreiber [EMAIL PROTECTED] wrpte
snip snip
 From /var/log/httpd/error:
 [Mon Nov 19 19:53:19 2001] [notice] child pid 30261 exit signal Floating
 point exception (8)
 # uname -a
 Linux www 2.0.34 #1 Thu Feb 25 21:04:19 PST 1999 mips unknown
 # gcc -v
 Reading specs from /usr/lib/gcc-lib/mipsel-redhat-linux/egcs-2.90.27/specs
 gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
/snip snip


 What's going on / how do I fix this / what other information do you need?

I believe it's related to a documented bug in PHP on the mips processor.
Before you do ./configure edit line 105 in the PHP source distro of
ext/standard/crypt.c
and change it to:

php_srand(time(0) * getpid() * (php_combined_lcg() * 1.0));

I've upgraded Apache/PHP/MySQL dozens (maybe hundreds) of times from sourrce
on the RaQ1/2 so if you still have problems after that let me know.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL and GROUP BY

2001-11-20 Thread Steve Werby

David Freeman [EMAIL PROTECTED] wrote:
 SELECT * FROM My_Table ORDER BY Business_Name, Last_Name, First_Name;

 What I would _like_ to have happen is that the select list will end up
 sorted by business name as well as last name and then first name.  At
 the moment this query is resulting in all business names (sorted) and
 then, following all business names, all last/first names (also sorted).

 I want them all integrated into a single alphabetical list.

This is really an SQL question so the MySQL mailing list would have been a
better place to ask, but...

You need to do an IF() to check whether to use Business_Name or a combo of
Last_Name/First_Name, then you need to join Last_Name/First_Name if
Business_Name is empty and name the column something and order by that
column.


SELECT IF( Business_Name'', 'Business_Name', CONCAT( Last_Name, ', ',
First_Name ) ) AS mylist
FROM My_Table
ORDER BY mylist

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Conversion number two?

2001-11-20 Thread Steve Werby

Brandon Lamb [EMAIL PROTECTED] wrote:
 Here is the php version
 $required = array('name','address','phone');
 
 Here is the perl version
 @required = qw( name address phone );
 
 
 So is there an easy way in perl for us lazy people so i dont have to use
 commas and enter every variable name in single quotes?

I think you mean PHP not perl, but there is a way.

$required = explode( ' ', 'name address phone' );

The code above turns the space separated list into an array.

-- 
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Piping into script...

2001-11-20 Thread Steve Werby

Ashley M. Kirchner [EMAIL PROTECTED] wrote:
 If I want to pipe, say an incoming email to a PHP script (assuming I
 have php compiled as a cgi binary), how do I deal with when it needs to
 receive the stream of data, how to figure out when there is no more
 coming before it actually start to parse the information?

$fp = fopen( 'php://stdin', 'r' );

Then treat as if its a normal file.  There's nothing special to do.

 And how do people deal with multiple requests and such?  There may
 be cases where there could be more than one email incoming at the same
 time...while theoretically the MTA only passes them one by one to
 whatever's next in line (whether it's procmail, or any other type of
 program)

I don't think you'll have a problem.  Each call to the program should run as
a separate process.  If I'm missing something post some more info.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Piping into script...

2001-11-20 Thread Steve Werby

David Robley [EMAIL PROTECTED] wrote:
 On Wed, 21 Nov 2001 14:52, Ashley M. Kirchner wrote:
  David Robley wrote:
   The OS will take care of this by firing up another instance of
   your script. All you need to do is be aware of the possibility of
   multiple instances doing ?things? at around the same time and make
   sure that you don't have say several instances all writing to the
   same file at the same time - use locking where it is not provided by
   the tool you are using.
 
  About the only worry I have there is the interaction with the
  database itself.  If two scripts start accessing the db for writing at
  the same time, I can smell trouble, yes.

 That'll be something else burning, then. The DB should be able to handle
 that sort of thing just fine. It is what they are supposed to do, after
 all :-)

Exactly.  It sounds like you're doing INSERTs so unless you're doing an
UPDATE or SELECT that can give unexpected results if another instance of the
script is running at the same time or you have other scripts accessing the
same files/tables that may run at the same time you're ok.  If there are
potential conflicts look at explicit LOCKing in the database.  FYI,
potential problems related to database and file writes are not just a
product of piping to a script - the same potential exists in web pages doing
the same things when multiple users can access scripts manipulating the same
tables/files simultaneously.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Piping into script...

2001-11-20 Thread Steve Werby

Ashley M. Kirchner [EMAIL PROTECTED] wrote:
 Steve Werby wrote:

  Exactly.  It sounds like you're doing INSERTs so unless you're doing an
  UPDATE or SELECT that can give unexpected results if another instance of
the
  script is running at the same time or you have other scripts accessing
the
  same files/tables that may run at the same time you're ok.

 Well now, I didn't say I was only doing INSERTs.

Best guess based on limited information.  My bad.  :-)

 After parsing the email, I
 need to do a quick select in the DB to see if the customer (placing the
order)
 already exists in our DB, and if they don't, just plain INSERT.
Otherwise, I
 need to do some more work, which will require an UPDATE on that same
record.

It sounds like the only possible conflict is if a customer not in the system
places two orders that arrive at about the same time and the second SELECT
is done before the first INSERT is committed.  Experience suggests this
isn't very likely...so unlikely I wouldn't even worry about it unless
there's a reasonable probability that INSERTs would take a long time and new
customers would fire off two orders at the same time (double send in Outlook
or refreshing via a web form?)...and since I don't have all of the details
and I'm likely misinterpreting the whole application I'll leave it at that.

 I'm probably going to break the DB into separate tables (one
containing the
 customer info, with a matching ID in another table which contains the
customer
 orders).

FWIW, that's how I'd approach it.

 (I know, this gets complicated by the minute. ;) )

Definitely harder than a hello world, but it sounds manageable.  Have fun
with it!

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] cron or something similar ?

2001-11-03 Thread Steve Werby

Srinivasan Ranganathan [EMAIL PROTECTED] wrote:
 Im working on a newsletter using php. Is there any
 way, other than using a cron job?

Of course.  Run the script manually via the commandline version of PHP or
require a password and form submission on a web-based version of the script
and run it manually or schedule a program on another server with cron (or pc
with scheduling program) to visit the page automatically.  wget can be used
to do this.

 Cuz, when i approach
 a my web host provider, how can i add a cron job to
 his system?

If you have shell access and your user has privileges to add a cron entry
then the program crontab can be used.  man crontab for more info.  If
not, your hosting provider will have to do it for you, that is if the
provider allows users to run cron jobs.

 how do other newsletter programs do this
 even when they are hosted at remote sites?

Some people just use mailing list programs like majordomo, mailman,
smarlist, etc. and send the newsletter out to the recipients manually...

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passing variables between pages without using url??

2001-11-03 Thread Steve Werby

sunny AT wde [EMAIL PROTECTED] wrote:
 i've written a form, which passes value to a ph script to insert them
 into mysql. from there on, i forward onto another page, but using :
 header(Location: http://www.foo.com/foo2.php?id=4user=foo;);

 now i really don't want to have the url on the next page looking like
 that because people might change the values, refresh the page and
 mess up my database.

 so is there any other ways i can pass values on??

Perhaps you should consider using the POST method instead of the GET method.
Then the variables are not displayed in the query string.  If you are
passing across a series of pages, after the first page you'll want to add
the variables you're going to pass to hidden input fields or use session
variables which will make the variables available throughout the user's
session or until you destroy the session.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] bcc

2001-11-03 Thread Steve Werby

"Nikola Karovi" [EMAIL PROTECTED] wrote:
 how can i send bcc from my php @mail script.

mail( $to, $subject, $message_body, "From: $from_name
$from_address\nbcc:[EMAIL PROTECTED]" );

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Questions per installing on linux (Php 4)

2001-11-03 Thread Steve Werby

[EMAIL PROTECTED] wrote:
 when I do am done downloading, it says to use:
 ./configure --with-apxs=/usr/sbin/apxs --with-mysql=/usr/local/mysql
 --enable-track-vars --enable-trans-sid --enable-ftp

 Ok, but I have mysql. Should I remove the --with mysql ...

If you want MySQL support in PHP you *must* include the --with-mysql option.
If you don't specify the location of the MySQL library files (the part after
the =) then PHP will use its built-in libraries which is fine on the RaQ3.

 and to have GD support, do I need a 'with gd ...'
 if so, what would that be? (I thought it was included)

Yes, include --with-gd.  --with-gd=/usr should do it.  I don't recall what
version of GD is on the RaQ3 by default so you may want to check and if it's
old you may want to consider upgrading before installing PHP.

 Or if I install postgres. Should I do that first?
 Do I need *Specific* syntax for postgres, such as --with-mysql=/usr/...

Yes, you should install PostgreSQL before installing PHP.  I recommend
searching the list archives for cobalt-users.  You can find them at the AIMS
Group archive site, same site you referenced in your post.  It might be a
better idea to ask about the PHP install on cobalt-users (go to
www.cobalt.com to subscribe, after searching the archives of course) since
everyone on that list is running RaQ systems, while my guess is that only a
fraction of the people on this list are.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Number_Format Question

2001-11-03 Thread Steve Werby

Jeff Oien [EMAIL PROTECTED] wrote:
 I have a number like this 0.51 and I would like it to display without
 the leading 0. How can I do this? Thanks.

There are lots of solutions.

$num = 0.51;

$num_parts = explode( '.', $num );
$num_new = '.' . $num_parts[1];

Or if it's always going to be a number b/w 0 and 1 then you could use
substr() to get the part you want.  You could also use something like
ereg_replace().  Someone else may have a solution that's better.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] site last updated

2001-11-03 Thread Steve Werby

Ryan Christensen [EMAIL PROTECTED] wrote:
 You can do this in a per-page basis w/:
 
 $modified = stat(yourfile.html); 
 echo date(l, F dS,$modified[9]);

Also see getlastmod() and filemtime().

-- 
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Q:Syntax for a space? ...like \n is for new line???

2001-10-25 Thread Steve Werby

Marcus James Christian [EMAIL PROTECTED] wrote:
 How do you call for a space in an email put out by mail();  ?  Similar
 to the way we call \n newlines with backslash n??

Within an email create a space by typing   or ' '.  If you want 10 spaces
do str_repeat( ' ', 10 ).  If you wanted to create a space within HTML I'd
suggest using #160; (some people prefer nbsp;), but if you do that
within the body of a text email it should display the actual characters, not
the text, so that won't get you the desired behavior.

HTH,

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Q:Syntax for a space? ...like \n is for new line???

2001-10-25 Thread Steve Werby

Jim Lucas [EMAIL PROTECTED] wrote:
 the bad thing about using the #160, mac user won't be able to view
this.
 mac uses a different ASCII set  160 isn't a space  :)

Jim,

Thanks for the info.  I didn't realize that.  I actually recently started
using that instead of nbsp; a few months ago b/c I thought it was *more*
universal.  frown

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Q:Syntax for a space? ...like \n is for new line???

2001-10-25 Thread Steve Werby

Jim Lucas [EMAIL PROTECTED] wrote:
 the bad thing about using the #160, mac user won't be able to view
this.
 mac uses a different ASCII set  160 isn't a space  :)

Jim,

Thanks for the info.  I'll definitely have to research this further.  I had
been using nbsp; since '96 and only started using #160; in the last 2
months because I was under the impression that it was more universally
accepted.  frown  If you happen to know of a resource describing ascii
code standards or differences b/w Mac and PC character sets please let me
know on or off-list.  Thanks!

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] array to string

2001-10-19 Thread Steve Werby

René Fournier [EMAIL PROTECTED] wrote:
 Just trying to convert an array to string before writing the whole thing
 back out to a file.  (Trying to do a simple database-less database, using
 text files).

 $fcontents = file($name..db);  // THE ENTIRE TABLE
 $fcontents[$update] = $updatedstring;  // THE ROW TO BE UPDATED
 $fp = fopen($name..db, w+);

 But before the next line, I need to convert $fcontents to a string, else
 just Array gets written to the text file.  I just can't seem to find the
 sure-to-be simple command to do this on php.net or phpbuilder.com, etc.
Any
 ideas?

See implode().

$fcontents_string = implode( '', $fcontents );

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ODBC version of PHPMyAdmin?

2001-10-05 Thread Steve Werby

Jaxon [EMAIL PROTECTED] wrote:
 Has anyone seen an ODBC version of PHPMyAdmin, or something similar; I
want
 to use it with more than just MySQL (e.g. Postgres and SQLServer)

Not ODBC, but phpMyAdmin has a PostgreSQL cousin, phpPgAdmin.  You used to
be able to find it at www.greatbridge.org, but Great Bridge has closed its
operation so you'll probably have to look elsewhere.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Submitting variables via /'s

2001-10-05 Thread Steve Werby

Matthew Walker [EMAIL PROTECTED] wrote:
 So, can someone give me the spot to look in the documentation to find
 out how to make this switch?

There are multiple solutions.  In a nutshell here's what I do.  I add
directives to the VirtualHost block for the site which point web requests
for certain pages to a master script that generates a number of pages with
similar database-driven content.  Here's one such line.  Any file beginning
with photo_gallery_, followed by 1 or more digits and ending in .html is
handled by template_1.php.

AliasMatch ^/photo_gallery_[[:digit:]]{1,}.html$ template_1.php

For this particular site, template_1.php actually handles nearly all of the
web requests for the site.  It consists of HTML code generating the basic
physical appearance of the site, then calls other scripts to generate the
HTML head section, breadcrumb trail, etc. and uses an include() statement
to load the appropriate PHP script that generates the bulk of the page's
content.  In this case that script is inc_page_news.php.

In inc_page_news.php the following code extracts the page number:

ereg( '/news_([[:digit:]]{1,}).html', $SCRIPT_NAME, $regs );

if ( ! empty( $regs[1] ) )
{
// Set page number.
$page = $regs[1];
}

Then a database query is performed to extract and build the page content.  I
wrote about the topic a while back on this list.  If you're interested see:

http://marc.theaimsgroup.com/?l=php-generalm=98618455619989w=2

A few months ago I wrote a script that controls ~40 product pages on each of
about 35 sites using PHP/MySQL and Apache mod_rewrite.  Prior to that the
pages were static and changes were done manually which was an extremely long
process for those involved (imagine changing layouts and fonts on 1,000+
static pages with no CSS).  Now changes can be made across all sites,
products or combinations thereof in seconds.  Sites, products, images, meta
tags, image tags, etc. are now entirely administered through a web interface
I built.  Using AliasMatch in Apache as I described above all product pages
are handled by a single PHP script which parses the URL for the site name
and product name and pulls data from a number of tables and handles a few
special cases programmatically, then generates the page.  Here are a couple
of the URLs.  You'll notice they aren't the prettiest of pages, but the goal
was to drive traffic to the sites from search engines, convert a high % of
visitors to sales and allow the site to be administered by a non-programmer
and implement changes rapidly.

http://www.3rackbids.com/products/pallet_rack.html
http://www.3-materialhandlingequipment-bids.com/products/pallet_rack.html

If you want to browse a couple of my side projects you'll see I implement
the same practices there too.

http://www.sexcriminals.com/ (not an adult content site)
http://www.tysonchandler.com/

HTH,

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Should I convert special characters before writing them to a table?

2001-10-04 Thread Steve Werby

René Fournier [EMAIL PROTECTED] wrote:
 The reason I ask is, I'm having a problem processing rows in a table that
 contain single quotes (specifically, the PHP code I wrote that allows the
 user to duplicate a row doesn't work if the a field in the row has a
single
 quote in it).

Try addslashes() before executing the query and stripslashes() when
retrieving data from the db.  See the online manual for more details.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stripslashes

2001-10-04 Thread Steve Werby

Caleb Carvalho [EMAIL PROTECTED] wrote:
 if i have an array that is fetching the result to be display
 example,
 for ($i =1; $i=sybase_num_rows($result); $i++){
 $row =sybase_fetch_array($result);

   $row[product]
   a href=solution.php?id=$row[prob_title]$row[prob_title]/a
   $row[description]$row[solution]

 where would i put the stripslashes function to get the description?

$var = $row[product] . 'a href=solution.php?id=' . $row[prob_title] . '' .
$row[prob_title] .
'/a' . stripslashes( $row[description] ) . $row[solution];

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] need phpmyAdmin but no so good

2001-10-04 Thread Steve Werby

[EMAIL PROTECTED] wrote:
 Webmin is a web-based administration interface for
 Unix systems but I need something like phpmyAdmin
 just for managing the info in databasesj ust listing dbs,
 tables, insert, delete, edit options; no create or alter
 tables and dbs.

You could pretty easily remove the form elements from phpMyAdmin that allow
the functions you don't want.  Quick and painless.  You may want to remove
PHP code from phpMyAdmin itself in case phpMyAdmin doesn't check to ensure
form data was posted (vs from a get method) and that data came from a page
in the phpMyAdmin session.  Or you could reinvent the wheel.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Should I convert special characters before writing them to a table?

2001-10-04 Thread Steve Werby

Arpad Tamas [EMAIL PROTECTED] wrote:
 I think stripslashes() isn't needed when retrieving data from the db,
 it is needed only in the query string to protect special chars from
 interpretting them as sql.

I want to say this isn't true, but maybe that depends on the configuration
of PHP (I'm thinking magic quotes settings off-hand).  From experience I
know that stripslashes() can be needed when retrieving data from a db.  Just
today I've had to do so for clients separately using PostgreSQL and MySQL.
YMMV.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] display query results at random

2001-09-26 Thread Steve Werby

Matthew Delmarter [EMAIL PROTECTED] wrote:
 How do I return a specific record from a db outside of the query?

 Let's say I select * from table (using mysql_fetch_object) and get 5
 results. I want to display the 5 results in different / random places
 on the page.

 Place 1 - show details for record 3
 Place 2 - show details for record 1
 Place 5 - show details for record 5

 How do I do this?

Someone mentioned saving to an array.  That's the way to go, but I'm not
sure if the reply was clear.

$i = 1;
while ( $qd= mysql_fetch_object( $rs ) )
{
if ( $i == 1 ) { $var1 = $qd-my_field; }
else if ( $i == 2 ) { $var2 = $qd-my_field; }
...
else if ( $i == 5 ) { $var5 = $qd-my_field; }
}

Then use $var1, $var2, ..., $var5 where needed after the loop finishes.  I
may be misunderstanding, so if you really want your query to return 5
records, but want to randomly pick a record for each of 5 random spots on
your page then do this:

$i = 1;
while ( $qd= mysql_fetch_object( $rs ) )
{
$var[] = $qd-my_field;
$i++;
}

Then use array_rand() inside a loop to pull from $var[], removing each
element after it's selected (more efficient) or adding code to ensure the
same element isn't picked twice (less efficient).

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] php script ownership

2001-09-25 Thread Steve Werby

Adam Plocher [EMAIL PROTECTED] wrote:
 Is there anyway I could make a PHP script run as the user that owns the
 script?

Yes.  Run it in CGI standalone mode.  That's the default method for
installing PHP, though it's probably not how yours is intalled.  There was a
thread a few hours ago which described how to install and run in this mode.
Just set the script's owner to the desired user and that's who it will run
as.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] help with Mysql Query...

2001-09-24 Thread Steve Werby

Christian Dechery [EMAIL PROTECTED] wrote:
 I have a table A and a table B... I want all occurences from A there are
 not in B...

 in ANSI SQL... it's nothing more than:

 select a.id, a.name from table_a a, table_b b where a.id NOT IN (select id
 from table_b)

 and that's it... but in Mysql, since there are no sub-selects, I'm burning
 my brains out and not getting it... I don't wanna create a temp table like
 the manual suggests... this is way NOT efficient... I'd rather do it in
PHP
 code than having a query that creates a temporary table, then drop it...

No temp table necessary.  Use a LEFT JOIN.

SELECT * FROM table_a
LEFT JOIN table_b
ON table_a.id = table_b.id
WHERE table_b.id IS NULL

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Disk Usage

2001-09-22 Thread Steve Werby

Scott Poarch [EMAIL PROTECTED] wrote:
 I'm trying to find a script that will return the same kind of data I get
 with du. I want a page to list current disk usage by virtual domain on our
 servers. I see the diskfreespace and disk_total_space commands, but they
 doesn't seem to work at all for me.

If you're on Linux or another un*x, try calling 'du' using system() or a
similar command.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] UPDATE syntax

2001-08-13 Thread Steve Werby

Gerard Samuel [EMAIL PROTECTED] wrote:
 OK it worked, but now I have to figure out why its only updating the
 first row.

snip
 Tyler Longren wrote:
  yeah...jibberish.  Should be this:
  UPDATE mpn_asklee SET reply='$Reply[$i]', Post='$post[$i]' WHERE
  ID='$counts'
/snip

If each row has a unique value for ID then it will only update a single row.
When in doubt what is happening store the SQL statement in a var like $sql
and then echo $sql to the screen to check it over, pasting into database
commandline to test results if necessary.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] subroutines?

2001-08-09 Thread Steve Werby

[EMAIL PROTECTED] wrote:
 As a new PHP convert, I ran into this same problem (below) yesterday while
 designing a form.  ASP programmers (if they're THINKING) will use subs to
 keep if blocks tidy.  In ASP, I'd use something like:

 If Request.ServerVariables( REQUEST_METHOD ) = GET Then
 DisplayForm
 Else
 SendFormData
 End If

 which at first I replaced with:
 if ( getenv( REQUEST_METHOD ) == GET ) {
 display_form();
 } else {
 send_email();
 }
 ...making functions out of what used to be subroutines.  All
well-and-good,
 except my global variables disappeared and nothing I could do (even
 declaring the few important ones explicitly global) seemed to allow me to
 get at the variable contents.

Bill,

You need to declare the variables global within each function that access
them or access the variable via the $GLOBALS array.

$var = 'something';

function go()
{
return $GLOBALS[var];
}

or

function go()
{
global $var;

return $var;
}

echo go();

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] sample or tutorial for conditional pulldown menus

2001-08-07 Thread Steve Werby

Tom Beidler [EMAIL PROTECTED] wrote:
 I have a client that would like to duplicate something they've seen on one
 of their competitor's web sites. It's for an automotive parts supplier and
 they would like to build a search engine for different make, model, and
year
 applications. Since a picture is worth a thousand words here's a url to
see
 the site they would like to knock off;


http://www.performanceproducts.com/shopper_profile.asp?mscssid=2K5UHTRR3UV28
 MLG468UVDQR3F4T73P3

 They like that you could choose a year and a make, which jumps to a new
page
 with an additional pulldown menu for models associated with the selected
 year and make. Some models even ask for a submodel. It's pretty cool but
 it's in ASP and lllwww.

Others on the list made good suggestions about the database structure.  The
URL you referenced reloads the whole page.  I've seen other sites achieve
the same functionality by loading the elements of the second, third and
fourth select boxes into javascript arrays which and regenerate the contents
of the dropdown boxes and make them visible based on the element selected in
the parent select box.  This avoids a page reload, but forces the page to
load all of the possible select box elements when it's first loaded - and it
obviously requires javascript.  It might be a good alternative depending on
your needs.  I've found that it only makes sense when very few target users
will have javascript disabled and the potential contents of the select boxes
are less extensive than make and model detail.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP MySQL

2001-07-20 Thread Steve Werby

[EMAIL PROTECTED] wrote:
 on 7/20/01 12:32 PM, Erich Kolb at [EMAIL PROTECTED] wrote:

  When you query a MySQL Database, how do you set the order
alphabetically?


 If it's a text field just say DESC

Anyone that tries would figure out, but I just wanted to clarify that what
Susan suggested will reverse the sort direction which is not what the poster
asked for.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Unlink Woes

2001-07-20 Thread Steve Werby

[EMAIL PROTECTED] wrote:
 on 7/20/01 11:48 AM, Sheridan Saint-Michel at [EMAIL PROTECTED] wrote:

  Warning: Unlink failed (Permission denied) in
  /home/www/foxjet/employees/admin.php on line 108

snip
 I had this error to from unlink, it may be because your server is in safe
 mode
/snip

If you're running PHP as an Apache module it runs as the owner that Apache
runs as and can only unlink files owned by that user unless the file you are
trying to unlink is world-writable.  This is a good thing.  Otherwise you
could delete any file on the server.  If you're running PHP as a CGI then it
runs with the privileges of the user who owns the CGI file.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Displaying tables

2001-07-20 Thread Steve Werby

Seb Frost [EMAIL PROTECTED] wrote:
 OK I'm playing around with MySQL on my ISP's server.  Created myself some
 forms that create/delete tables and enter/display data in a table.

 Is there a simple way to generate a list of all my tables, or even better
to
 display all of the tables with all of their information?

Get phpMyAdmin from http://www.phpwizards.net/.  Or see mysql_list_tables(),
mysql_list_fields(), etc.  See http://www.php.net/manual/en/ref.mysql.php.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP]need an opinion on this idea of mine...!!

2001-07-09 Thread Steve Werby

Chris Cocuzzo [EMAIL PROTECTED] wrote:
 I wanted to have all these functions on one master page called index.php,
 and then have one of the functions within my switch statement be used for
 display each individual page. So this function would include each separate
 php file, and then basically the master file has all of the functions that
 each page needs to function correctly. Is this a good idea?

Sure.  If the code is going to get long or complex and a lot of the code
won't be used on an individual page you may consider splitting up the
functions in separate files in some logical fashion and include()'ing those
that are needed for each specific page.

 also. related question. if I have a file called index.php, and I include
the
 file bio.php on that page, will the $PHP_SELF variable be set to bio.php,
or
 to index.php?

index.php if you're simply include()'ing the content from bio.php.  If
you're using Apache AliasRewrite magic and the URLs for each file are
pointing to the script index.php then it will be set to bio.php.  A good way
to learn is to write short test scripts, add phpinfo() to the code and see
what the variables are set to.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Running PHP as a cron job....

2001-07-08 Thread Steve Werby

Michael Hall [EMAIL PROTECTED] wrote:
 With all the advice that has been offered so far, has it been assumed that
 php is installed in the CGI rather than DSO manner?

I haven't found this to be clear from the thread.

 Can PHP as a DSO
 interpret shell script-like files with a shebang at the top?

No.  This only works if PHP is compiled in stand-alone (CGI) mode.

 Alternatively, I've read somewhere about using lynx to run a .php cron
 job. Does this apply to DSO setups? For example, would James put something
 like this in his crontab:

 *   *   *   *  lynx mail.php

Almost.  Instead of the filename, the *full* URL is needed.  If PHP is
compiled as an Apache DSO the only way Apache can parse the PHP script is if
the file is accessed via the webserver, not directly off of the filesystem.
If anyone goes this route I strongly suggest adding authentication via an
.htaccess file and passing the user/pwd to lynx (see man lynx) so that
your script which is probably only intended to be run via cron isn't
available for anyone on the web to access.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Running PHP as a cron job....

2001-07-08 Thread Steve Werby

Ben Bleything [EMAIL PROTECTED] wrote:
 Interesting method, with the lynx... I imagine that if you've only built
 the DSO, then that would be the way to do it.. if it worked.

It works.

-- 
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Running PHP as a cron job....

2001-07-08 Thread Steve Werby

Michael Hall [EMAIL PROTECTED] wrote:
 I've just recently got a bit more serious with learning bash scripting and
 am surprised at how powerful it really is, in conjunction with the usual
 UNIX commands and other tools. PHP is the only choice for most things web
 related, but I'm finding that bash is making my server admin tasks easier
 and quicker. In fact, I'm currently working on a PHP code snippet manager
 written in bash! If the idea has any legs, I might convert it over to
 Python or something later ...

Hmm.  A PHP code snippet manager written in bash, possibly to be converted
to Python...but no mention of converting to PHP.  Are you planning a Java
code snippet manager written in Fortran?  Just kidding.  Definitely reminds
you that there are a lot of tools that can be used for any given job and
lots of solutions for every problem.  BTW, I split my shell scripting
between bash and PHP, used to do shell scripting in Perl, but I rarely use
it anymore so I'm much faster scripting in PHP.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Question about how to do this...

2001-07-08 Thread Steve Werby

Ben Bleything [EMAIL PROTECTED] wrote:
 I believe (and I'm sure someone will correct me if I'm wrong) that
 whenever you 'include' or 'require' a file, it drops to regular HTML
 mode... so, yes, you will need to use ?php tags at the beginning and ?
 tags at the ends =

Think of the behavior of include() as copying the exact text from your code
in the include'd file and pasting it as is into the calling code...a la
paper and scissors.  There is no special transformation.  So if the code in
the include'd file would have needed PHP codes if it was directly within the
calling code then it needs it in the include'd file too and if it wouldn't
have in the calling code then it won't in the include'd file.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] is_alpha_numeric ?

2001-07-06 Thread Steve Werby

John Monfort [EMAIL PROTECTED] wrote:
  I'm trying to determine if an argument is alphanumeric. Is there a
 function to do this?

There may be in the CVS version (would have to check), but there's not in
4.0.6.  eregi( [[:alnum:]]{1,}, $string ) may do the trick.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP/mySQL Query

2001-07-05 Thread Steve Werby

Jeff Lewis [EMAIL PROTECTED] wrote:
 I fought the urge to post this here but have to :(

 owners
 -ownerID
 -teamname
 -more fields

 teampages
 -ownerID
 -bio

 Anyway, I'm doing a select on the database like this: select ownerID,
 last_update FROM teampages ORDER BY last_update DESC LIMIT 10

 The thing is, I want to get the team name from the other table as well.
Can
 anyone help me out?

I've read the other solutions, they all used STRAIGHT JOINs.  You may want
to consider a LEFT JOIN (form of an OUTER JOIN).  A LEFT JOIN will return
all the records from table A and those from table B that match the records
from table A.  The implication is that with a straight join if there is no
record for an ownerID corresponding to the record from the table teampages
then the record from teampages won't be returned.  So if a teamname never
got entered in owners or the ID was mis-entered your query would not return
all of the records from teampages and you probably want it to.  Using a LEFT
JOIN the record from teampages will be returned, but since there's no
corresponding record in table owners the field teamname will be blank.
Assuming all of the data is in both tables it's not a problem, but believe
me at some point when doing database programming this issue will arise.

SELECT teampages.ownerID, teampages.last_update, owners.teamname
FROM teampages
LEFT JOIN owners
ON teampages.ownerID = owners.ownerID
ORDER BY last_update
DESC LIMIT 10

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Security of PHP code

2001-07-04 Thread Steve Werby

Jon Haworth [EMAIL PROTECTED] wrote:
 Yes, I would have thought this would do it:

 if (strstr($file, /usr/local/apache/htdocs/) {
 show_source($file);
 } else {
 echo File must be in /usr/local/apache/htdocs!;
 }

 Modify as appropriate.

 Have I missed anything, or will this do the trick?

Something along those lines will work.  Without some kind of limitations
built in, the page will be able to load any file that's world-readable so
it's a good idea to limit access to certain directories or hardcode the
directory you want to give access to.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Removing Invalid Users

2001-07-04 Thread Steve Werby

Clayton Dukes [EMAIL PROTECTED] wrote:
 How can I write code that will search the database and check the validity
of
 an email address, and if it's bad, to remove that entry from the database?

Like Tom said, use regex to check the email is of a valid format.  A small
percentage of servers can be contacted to find whether an email address is
valid, but fewer and fewer are allowing this so it's completely unreliable.
You can use getmxrr() to see if a DNS MX record exists corresponding to the
domain.  You'll need explode() to pull out the domain itself from the email
address.  Unfortunately an email address can be valid without having a valid
MX record and also DNS could be unreachable at the exact moment your
requesting it.  It might be better to bypass getmxrr() and use checkdnsrr()
instead to find whether the host exists.  Of course this too could be
unreachable.  If you really want to determine if an email address is valid,
a better strategy may be to send an email to the address with a unique
string in it that must be mailed back or a unique URL that must be visited.
You'd then need a script that's triggered upon receipt of matching emails
and changes a flag in your DB record to designate the email address as valid
or a script in the webpage that does the same.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Security of PHP code

2001-07-04 Thread Steve Werby

Sascha Schumann [EMAIL PROTECTED] wrote:
 On Wed, 4 Jul 2001, Steve Werby wrote:

  Jon Haworth [EMAIL PROTECTED] wrote:
   Yes, I would have thought this would do it:
  
   if (strstr($file, /usr/local/apache/htdocs/) {
   show_source($file);
 [..]
  Something along those lines will work.  Without some kind of limitations
  built in, the page will be able to load any file that's world-readable
so
  it's a good idea to limit access to certain directories or hardcode the
  directory you want to give access to.

 Imagine someone passing in
 /usr/local/apache/htdocs/../../../../etc/passwd as path..

Excellent point.  In addition to hardcoding the path I would do something to
ensure that the file requested does not attempt to bypass that directory.
I'd probably use a regex to make sure it doesn't include a / or if I want
to serve files from a deeper directory I'd do a regex or use something like
strstr() to see if .. is within the filename.  Personally, I wouldn't make
a script that outputed a file on the server or a script's code *and* allowed
the user to dictate what file was accessed.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] checking if checkbox is checked

2001-07-04 Thread Steve Werby

Richard Kurth [EMAIL PROTECTED] wrote:
 I have 5 checkbox's in a form that I what to make sure at least one of
  the checkbox is checked.

 input type='checkbox' name='interest' value='basic'
 input type='checkbox' name='interest3' value='Internet access '
 input type='checkbox' name='interest1' value='pro'
 input type='checkbox' name='interest4' value='domain name'
 input type='checkbox' name='interest2' value='platinum'

if ( $interest == 'basic' || $interest3 == 'Internet access' || ...
$interest2 == 'platinum' )
{
echo At least one was checked.;
}

Ignoring the first input box you could also use a loop since the field names
are sequential.  You could also handle the first field, by starting $i at 0
and only appending $i if it's greater than 0, but I don't want to clutter
the code.  The code below assumes the fields aren't preset to values other
than those listed above.

for ( $i = 1; $i  4; $i++ )
{
$field = 'interest' . $i;
if ( ! empty( $$field ) )
{
$flag = TRUE;
}
}

if ( $flag == TRUE )
{
echo At least one was checked.;
}

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Email verification (was: [PHP] Removing Invalid Users)

2001-07-04 Thread Steve Werby

Arcady Genkin [EMAIL PROTECTED] wrote:
 If I understand correctly, vrfy does not wholy depend on that
 functionality to be supported by the server.  I think that it simply
 connects to the smtp port of the mail exchanger and emulates an email
 delivery, aborting halfway.

I hadn't used the tool until after this thread started, but it appears it
uses the vrfy command when checking an email address, other flags let you
check a domain's mx record or attempt to use the etrn command.

 Basically it wants to determine whether
 the mail exchanger would accept email for a given domain.  In most
 cases it won't give you 100% certainty that the email addy is legit,
 but at least you know that the domain part is not faked, and there is
 a mail exchanger willing to serve it.

I'll give you that b/c it does have a way to do it.  IMO, it makes more
sense to use PHP's built in functions that can do the same, but YMMV.  vrfy
does appear to be a decent tool, my point was that when checking email
addresses (not domains) most servers will deny the vrfy command and so it
won't be very useful.  In fact, I tried a number of different email
addresses on different hosts and all reported Command Unimplemented.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Email verification (was: [PHP] Removing Invalid Users)

2001-07-04 Thread Steve Werby

Matthew Loff [EMAIL PROTECTED] wrote:
 There really isn't any surefire way to verify whether an e-mail exists
 or not, except to try to send to it, correct?

Bingo.  And with catchall accounts and unexpected mail server behavior you
may get no response even if an email address is not valid.  IMO, the only
way to verify that an email address exists *and* is being used by the person
who supplied it (I assume in most cases this is the whole point) is to send
a unique string or URL and check that the recipient responds with the string
in an email or visits the URL.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Email verification (was: [PHP] Removing Invalid Users)

2001-07-04 Thread Steve Werby

 Steve Werby [EMAIL PROTECTED] writes:
  Like Tom said, use regex to check the email is of a valid format.  A
small
  percentage of servers can be contacted to find whether an email address
is
  valid, but fewer and fewer are allowing this so it's completely
unreliable.

Arcady Genkin [EMAIL PROTECTED] wrote:
 There's a nifty little open source program called `vrfy' which does
 nice things about email veryfication.  Finding it is left as an

It is a cool tool, but like I said in my email most servers won't allow you
to test email address validity.  It's possible using the command VRFY or the
even more dangerous EXPN to determine whether an email address is valid or
in the case of EXPN to expand an alias to return a list of all recipients.
It's a good idea to disable these commands on the server so spammers can't
easily determine valid email addresses, malicious folks can't get a list of
all of your employee email addresses and hackers can't determine valid
usernames to attack the server with.  FYI, in sendmail both commands can be
disabled by making sure PrivacyOptions is set as follows:

PrivacyOptions=noexpn novrfy

Or you can set them to the following which goes a little further:

PrivacyOptions=goaway

So unfortunately vrfy will only be useful when checking servers that haven't
disabled that command.  :-(

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] search

2001-07-03 Thread Steve Werby

AJDIN BRANDIC [EMAIL PROTECTED] wrote:
 I've got search facility (php-mysql) which is very simple. If i search
 for 'dog' it will find any records containing words 'dog' or 'dogs' or
 'dogowner' etc.  But if I search for 'dogs', words 'dog' and 'dogowner'
 will not be found.  This is a classic case so there must be a solution to
 it but I cannot find one.  I tried to do something like
 if word is 'dogs' then I do the search,
 then break word 'dogs' into an array and check if the last element is an
 's'. If it is remove it, reconstrust the string,which will give 'dog',
 and do search for that too.
 Then display results.  Well I connot find a way of breaking a string into
 an array. How do I break 'mynameis' into an array of 8 elements?
 This has got loopholes but still it is better than what I have now.

Ajdin, you may want to take a look at mnoGoSearch, which is search engine
software with a C indexer, PHP front-end and ability to work with numerous
databases, including MySQL.  It's a great program, but even if it's not
suitable for what you're doing I suggest looking at the PHP code and
database structure.  mnoGoSearch has incorporated the ability to search for
related words by incorporating a dictionary file and a database table of
grammar rules so a search for one word can be made to find other forms of
that word.

FYI, to break a string into an array like you describe use strlen() to get
the length of the string, substr() to pull out the first N characters from
the string, then loop through and add each element to an array by adding as
follows (pseudocode):

for ( $i = strlen( $string ); $i = 0; $i-- )
$array[] = substr( $string, 0, $i );

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] recommend a good PHP site specific search engine

2001-07-03 Thread Steve Werby

Tom Beidler [EMAIL PROTECTED] wrote:
 Can anyone suggest a good PHP/MySQL search engine to be used to search a
 site (not the entire Internet). I have a site with an extensive amount of
 manual pages that we would like to provide a search engine for.

mnoGoSearch http://www.mnogosearch.org/

-- 
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Filtering out \ when a ' is user entered?

2001-06-27 Thread Steve Werby

Marcus James Christian [EMAIL PROTECTED] wrote:
 \'  How can I filter out these backslashes so they don't appear on the
 final public viewable page?

Use stripslashes().

-- 
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] validate phone numbers

2001-06-20 Thread Steve Werby

Richard Kurth [EMAIL PROTECTED] wrote:
 I am using this script to validate for phone numbers and it work just
 perfect for US phone numbers. But it rejects some European and
 Australian numbers what do I need to do to make it validate all phone
 numbers

 if (($WPHONE_NO) || ($wphone_no)) {
$wphone_no = trim($wphone_no);
if ($WPHONE_NO)
   $phone_no = trim($WPHONE_NO);
if (!ereg((^(.*)[0-9]{3})(.*)([0-9]{3})(.*)([0-9]{4}$), $wphone_no))
{
   print_error(your bphone number/b is invalid);
}
 }

It would be helpful if you post a list of the range of phone numbers you are
encountering that you are having a problem with.  Or I can get you started
by saying that I think you're regular expression is saying beginning with
anything, then exactly 3 numbers, then anything, then exactly 3 numbers,
then anything, then ending in exactly 4 numbers.  Changing a {3} to {3,4}
would mean match 3-4 occurences of what's to the left.  Hopefully that
will get you started, if you post some other numbers you want to pass
validation we can be of more assistance.  regex are very powerful and I
recommend you add them to your training.  That said, people enter #s in many
different formats and sometimes it's necessary to enter a # like
011-817-972-1086 x103 or 817-972-1086, 1, 3, 12 if you're dealing with
business numbers with extensions or automated systems that have to be
traversed.  So you may be better off not validating the phone #.  YMMV.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/




Re: [PHP] logout

2001-06-20 Thread Steve Werby

Jacky [EMAIL PROTECTED] wrote:
 Is there anyway I can do the logout that will completely
 get rid of all login detail without having user to close browser?

If you're using sessions session_destroy() will do it.  Create a link or
form button that calls that function.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] variables in a e-mail

2001-06-18 Thread Steve Werby

Richard Kurth [EMAIL PROTECTED] wrote:
 How can I add a variable to an e-mail on the fly. Say I have a form on
 my page that the user fells in with data. but when he fills in the
 message things like Hello,$Variable are added before it is sent. Does
 this make sence

If you're using the mail() function set the message string to $msg_body.
Then build $msg_body from the form data.  If you're posting the form the
variables will be accessible within $HTTP_POST_VARS[], if you're within a
function you'll have to declare that array global first or access like
$GLOBALS[HTTP_POST_VARS][my_form_field].  So, in your example you'd do:

$msg_body = Hello,  . $GLOBALS[HTTP_POST_VARS][variable];

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/




Re: [PHP] IF statements

2001-05-22 Thread Steve Werby

chris herring [EMAIL PROTECTED] wrote:
 if ($date == 24  $hour == 3) {  }

 But that doesn't work... Any help is appreciated

Your logic is correct.  If the code within the braces isn't working it's
likely there's either an error in the code within the braces or $date and
$hour aren't returning the values you expect.  Try echoing them before the
if statement to verify they contain the values you expect.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] webmaster volunteer

2001-05-17 Thread Steve Werby

Alex Tretjakov [EMAIL PROTECTED] wrote:
 Hello all. Forgive for offtopic, but somebody can knows where it is
 possible to find work for volunteer. I well know and I have experience of
work
 with PHP, SQL, but I have not the projects except for amateur and
 consequently it would be desirable to work free-of-charge. Beforehand
 thank.

Give http://www.sourceforge.com/ a try.  There are thousands of projects
listed there and I bet a few could use some help.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] while loops [ newbie ]

2001-05-17 Thread Steve Werby

[EMAIL PROTECTED] wrote:
 i have a file $file that is full of usernames and descriptions, one per
 line. i have another variable $username that i would like to compare
against
 each line in the file and remove the line that matches the
 username field identically.

 $filename

 charles routers
 craig systems
 tony portmasters

 i would think that a while loop could do this and possibly write the
 output, minus the line i want to take away to a temp file and then copy it
 over. in bash i would use a statement like:

 while read i; do
blah 
 done  $filename  $filename.tmp

 however i am not certain how to read in the contents of a file for
 comparison within a while loop. this is just going to be an uphill thread
 since my next question will be for the  blah  portion :)

Use fopen() to open the file, while ( ! feof( $fp ) ) to loop through the
file until the end of it is reached and fgets() to read one line at a time.
Use explode() to grab the first word on each line, compare it to your other
variable and write each line to a new variable if it doesn't match.  Then
use fwrite to write to a temporary file and copy that file over the
original.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Uptime script?

2001-05-16 Thread Steve Werby

Christopher Heschong [EMAIL PROTECTED] wrote:
 If you want to get the current uptime in Linux without a system() call,
 you should be able to fopen() the /proc/uptime file.  The first number
 is the number of seconds the machine has been up, the second is the
 number of seconds the machine's processes have been idle.

I have a function I wrote that displays uptime and takes arguments of time
units and decimal places.  Have fun.

http://www.befriend.com/code_gallery/php/get_uptime/

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Shopping cart search

2001-05-10 Thread Steve Werby

Todd Cary [EMAIL PROTECTED] wrote:
 Can someone pass on the URL for searching for PHP shopping cart programs
 and shopping cart related questions.

google.com?  Or search the php list archives at
http://marc.theaimsgroup.com/.

 Many thanks...

Here are some shopping carts written in PHP.  I don't know of a message
board or mailing list dedicated to shopping carts.

http://www.theexchangeproject.org/
http://www.fishcart.org/

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] i need some help with extracting data from mysql

2001-05-10 Thread Steve Werby

Sandeep Hundal [EMAIL PROTECTED] wrote:
 i've got a simple problem, yet it doesn't work, so i hope someone can
 help me out here.

 i've got a table with id, group, and name. each group has many names
 ofcourse.

Are these *all* of the field names?

 now i need to output the data like :
  group1
name1
name2
name3

 group2
name4
name5

 group3
name6
 etc

 my query is SELECT group, name FROM $tablename WHERE approved='yes'
 GROUP BY folder ORDER BY folder;

You lost me.  Where is the field folder?  Can you output the results of
DESCRIBE tablename for the table and a few records?

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] i need some help with extracting data from mysql

2001-05-10 Thread Steve Werby

Sandeep Hundal [EMAIL PROTECTED] wrote:
  my query is SELECT group, name FROM $tablename WHERE approved='yes'
  GROUP BY folder ORDER BY folder;

 Sorry, substitute folder for Group. I just wrote that by mistake.

 Data is such:
 1 | friends | name1 | yes
 2 | misc| name2 | yes
 3 | friends | name3 | yes
 4 | work| name4 | no

 I want to extract the ones approves, but list them by Group first, and all
 the relevant names after. But I dont want to run a query for each GROUP to
 output the data underneath it.

You don't need to GROUP the records b/c you're not performing any kind of
aggregate operation on them.  Use the following query:

SELECT group, name
FROM tablename
WHERE approved = 'yes'
ORDER BY group

Use PHP to loop through each record like you normally would.  Since you want
the group on a line by itself and then all of the names that are members of
the group one per line below it you should do something like the following
(I assume you're outputting in HTML, if not replace all 'br' tags with
\n):

while ( $row = mysql_fetch_array( $sql ) )
{
$group = $row['group'];
$name = $row['name'];

if ( $group != $group_previous )
{
echo $group . 'br';
}

echo $name . 'br';
$group_previous = $group;
}

By setting $group_previous equal to $group *after* looping through each row
it can be compared to $group so that you only display the group name when it
doesn't match the $group of the previous row.  I think this is what you
wanted.  If I misinterpreted what you were trying to do let me know.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] cobalt raq4

2001-05-09 Thread Steve Werby

Herman Tolentino [EMAIL PROTECTED] wrote:
 anybody out there who has successfully compiled php (apache module) with
 PDFLib 4? Much help would be appreciated. Been trying for 1 week.

I haven't tried PDF 4, but I installed PDF 3.03 and compiled PHP with PDF
support on a RaQ2 recently.  I noticed you're installing on a RaQ4 and since
I did so on a RaQ2 with PHP4.0.5 compiled into Apache 1.3.19 binary that
version of PDF should work on the RaQ4 (x86 is much easier to install on
than mips platform).  I believe the configuration command I used for pdflib
was ./configure  --enable-shared --enable-shared-pdflib
and --with-pdflib=/usr/local in PHP.  I couldn't tell you whether a newer
version of PDF will work.  Perhaps if you post your installation steps and
what errors were encountered someone can help.  BTW, there's a test
directory in the PDF source and a test script ./pdftest that creates a test
PDF file.  Can you get the test file to work?

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Even more dynamic page

2001-05-04 Thread Steve Werby

Martin Skjöldebrand [EMAIL PROTECTED] wrote:
 Is there some way of making PHP even more dynamic?
 What I would like is that selecting a value from a SELECT box would
 change some info on the page - without having to click a refresh button
 or something like that.

 Or do I have to resort to javascript for such things?

Yes, use JS.  PHP is server-side.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re[2]: [PHP] Protecting programs

2001-05-03 Thread Steve Werby

Richard Kurth [EMAIL PROTECTED] wrote:
 what is obfuscation

Essentially, it means making the code hard to read, follow and locate.

 encryption

It's the coding or scrambling of data that requires decoding to be read.
MaD dUCK's other suggestions are better since he is correct in saying these
methods aren't the best.  An analogy is like leaving a bike unattended on a
crowded city street, but typing it up in string.  Anyone with time and half
a clue can ride the bike away.  The Zend compiler is worth looking at.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL fulltext indices and phrase search

2001-05-02 Thread Steve Werby

Jens Kisters [EMAIL PROTECTED] wrote:
 Hi there, is there a possibility to use MySQL's MATCH ... AGAINST to
 look for a string like foo bar ?
 
 if i MATCH keyname AGAINST ('foo bar') i get resuts that match foo or
 bar, but not both of them separated by a space.
 
 My guess is that the organization of the index doesn't allow this kind
 of search as it's based on single words , but maybe one of you has a
 better idea than
 to select the rows that contain both and hit those with LIKE '%foo bar%'

Perhaps you should ask on the mysql list.
List-Subscribe: mailto:[EMAIL PROTECTED]

-- 
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Command Line

2001-04-30 Thread Steve Werby

Randy Johnson [EMAIL PROTECTED] wrote:
 how do access arguments if I run a script from the command line

 example
 php myscript.php  arg1, arg2

They'll be located in the global array $argv[].  Include ?php phpinfo(); ?
in your script to see how to access them.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] php 4.04pl1 ldap

2001-04-30 Thread Steve Werby

Walgamotte, David [EMAIL PROTECTED] wrote:
 Is LDAP support default or are there any ./configure options I need to
know

Take a look at './configure --help'.  You need to configure --with-ldap.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Update statement?

2001-04-30 Thread Steve Werby

Kurth Bemis [EMAIL PROTECTED] wrote:
 function modify_quantity($table, $session, $itemid, $quantity)
 {
 $sql = UPDATE $table SET quantity='$quantity' WHERE session='$session'
 AND itemid='$itemid';
 mysql_query($sql);

Add 'echo $sql;' here (no quotes) and look at the output.  If the RHS of
quantity= is zero, then $quantity passed to modify_quantity is zero and
that's the problem.

 if there is a value in the db field quantity then after the statement is
 executed it is set to 0

I think that $quantity is the problem.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Help: Logging Into Sites (webgames)

2001-04-30 Thread Steve Werby

Fred [EMAIL PROTECTED] wrote:
 I want to log into a game and access a page and parse it.
 To Log into the game, youd have to use a form, so how do I do this in PHP?

Using CURL functions you can post to a URL and grab the output.  You have to
compile PHP --with-curl after installing CURL first.  You can also use
fsockopen().

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Writing a file with break lines

2001-04-30 Thread Steve Werby

Augusto Cesar Castoldi [EMAIL PROTECTED] wrote:
 How can I write a file like list.txt, I get a lot of information from
 mysql, and I have to put with line of mysql in this txt file. (rewrite).

 How can I do that?

 I tried to put \n but it didn't worked.

\n works for me.  Perhaps you should post some of your code.  Be sure \n
is within double quotes; if it's in single quotes it won't work.  Here's a
line of code from a script I wrote that works.

fwrite( $fout, Date: $h_date\n );

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Transfering an image

2001-04-26 Thread Steve Werby

Ben Quinn [EMAIL PROTECTED] wrote:
 I am trying to copy an image from an external server and save it to my
own.
 I have the following script to do this for a txt file and it works great!

 ?

 $page  = ../temp/yep.txt;

 $date = date(http:/www.example.com/yep.txt);

 $cartFile = fopen($page,a);
 fwrite($cartFile,$date,strlen($date));
 fclose($cartFile);

 ?

 But i can't get it to work for image files - the images are saved and
 displayed on screen as a whole bunch of rubbish.

That's because your browser doesn't know the data is an image.  Before you
send the image to the browser you have to use the header() function to send
the browser the proper mime type for the image.  I don't know the mime type
off-hand, but there's probably a tutorial on zend.com or phpbuilder.com that
discusses saving images in a MySQL DB and pulling them out to display on a
webpage using PHP so find one of those articles and look near the end.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] *.php and the search engienes on the web

2001-04-26 Thread Steve Werby

SED [EMAIL PROTECTED] wrote:
 If I make a whole website based on one PHP-navigation file with links like
 index.php?id=123, will all the search engines who crawl the websites be
 able to follow it and index?

A lot of them won't index pages with query strings (the part after the ?).
I posted a message in a similar thread earlier this month with more details
and some strategies to generate URLs that make search engines happy.  The
post is at the first URL below.

http://marc.theaimsgroup.com/?l=php-generalm=98618455619989w=2

Here are links to other similar threads I've replied to - read all of each
thread for the full picture.

http://marc.theaimsgroup.com/?l=php-generalm=98754380108909w=2
http://marc.theaimsgroup.com/?l=php-generalm=96578812203470w=2

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] math calculations query

2001-04-26 Thread Steve Werby

Maxim Maletsky [EMAIL PROTECTED] wrote:
 SELECT
 SUM(quantity)*SUM(total) As mySUM
 FROM
 table
 WHERE

Technically, this is correct based on what the original poster (below)
stated he wanted, but that's not really what he wanted since there's no real
world reason to calculate what he stated he wanted.  He must really want the
total monetary value of the items returned by the query.  That's calculated
by multiplying the quantity of each record by the price of each item and
summing that for each record.  So the correct SQL statement is:

SELECT SUM(price*quantity)
FROM table_name
WHERE ...

If he doesn't want to run the query above in addition to his existing query
to return individual records, he can calculate this total programatically.
Sean, in this case, as you're looping through the records do:

$amount_record = $price * $quantity;
$amount_total += $amount_record;

After the loop is complete, $amount_total will contain the value you want.
Alternately, the first line can be eliminated by calculating the amount for
each record within the query.

[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] wrote:
 i have a script which selects description, price and quantity from a mysql
 table.

 i have displayed the results on a page in the form of description, price,
 quantity but I was wondering how best to go about calculating a total
total,
 ie. sum of quantitys multiplied by sum of prices.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Site Structure

2001-04-23 Thread Steve Werby

Toby Miller [EMAIL PROTECTED] wrote:
 While it is true that you don't have to put your files in the web
directory
 at all and it is a more secure option there is still one very large
 inconvenience that prevents me from going with that option. You lose the
 usefulness of just including $DOCUMENT_ROOT/yourfolder/yourfilename.
This
 is the main reason that I do put my files in the root web directory. So
how
 do you tell all of your files where your included content is? Do you hard
 code the path in every page? If so, do you also have development, stage,
and
 live environments that mimic the exact same directory structures? If not,
do
 you always change the include strings by hand every time you move from one
 environment to another? Do you run into these problems? What kind of
 solutions/workarounds have you implemented?

Here's a solution I've used with a lot of success.  I concocted it myself a
year or so ago after trying a number of other alternatives.

// Set INC_PATH.
ereg( '(.*)htdocs.*', $SCRIPT_FILENAME, $regs );
define( 'INC_PATH', $regs[1] . 'inc/' );

// Include files.
include( INC_PATH . inc_common.php );
...
include( INC_PATH . inc_db.php );

Nearly all of the sites I design are controlled from a single PHP file using
some Apache AliasMatch magic so I usually only have to set the INC_PATH
constant
in one file and include the main include files in the same place. So the
include directory (inc) is parallel to my web docs directory.  The parent of
both is a directory called 'production', which has directories parallel to
it called 'development' and 'staging' which allows me to run 3 versions of
the site, each on 3 separate ports and copy code from one version to the
other and run them with no modifications.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP and useradd

2001-04-23 Thread Steve Werby

Nashirak Bosk [EMAIL PROTECTED] wrote:
 Ok.  I have looked at all my options for creating account dynamically
 from a webpage, and have not come up with much.  I want to create an
 user account that only creates a mail account.  I think I can do this
 with the useradd command (I am running Linux).   Like this:

useradd accountname -s /bin/false   then I could su into the
 accountname and run the passwd command.

 Now I could do this, with PHP using the popen() function.  There is only
 1 problem.  I would have to run all this as root since only root is able
 to run this command.   And even if I could it would be a big no no to
 somehow make PHP become root and then run this command.  Any other
 suggestions on how to create an account dynamically with PHP or how to
 modify what I about the useradd command to get this to work?  Thanks

I would recommend installing PHP as a CGI and making the script that calls
useradd owned by root and implementing some sort of authentication scheme to
prevent unauthorized use or I would write the useradd command to a database
(or text file) and have a bash script owned by root check it for entries
from a cron job and run the commands if entries are found.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Linux, Apache, PHP and Sendmail

2001-04-20 Thread Steve Werby

"Ben Cairns" [EMAIL PROTECTED] wrote:
 I am having a problem getting Sendmail to work on RH Linux 6.0

 I am trying to get it to relay messages through our mail server. But it is
not
 even attempting to connect to the mail server.

Is the relaying being done via a PHP script?  If not, I'm confused why you
put PHP and Apache in your subject and why you posted this to a PHP list.
There are Redhat and mail server mailing lists that would be more
appropriate in that case.  In any case, you'll get better help if you check
your log files and post relevant messages found there, post lines from
config files, etc.  If Sendmail previously worked on the box, let us know
what has changed recently about the setup.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Many email... and just one mail function

2001-04-20 Thread Steve Werby

"Marian Vasile" [EMAIL PROTECTED] wrote:
 Guyz I have a huge database wih emails.
 Now I want to send them news weekly and I can't how I can send many
 emails using mail() function ???
 but in a faster manner that ussualy ?... is that possible ?

 I'm not talking about SPAM here... I have registered users... :)

 How I can send all these 30.000 email addresses ?

With 30,000 users I recommend using a mailing list so your mail server can
do the heavy crunching.  Since you probably run PHP as an Apache module and
I suspect your user database changes here are a couple of options to
consider.

1. Create a cron job to periodically pull the email addresses from the DB
and dump them into a text file that the MLM (mailing list manager) expects
(may require an additional step depending on your MLM).

2. Install PHP as a CGI and have it do the same as in option 1, but do
directly from your PHP script that sends the email.  I say CGI so you can
make the script owned by any user you prefer and don't have to make the
directory containing the file world writable/readable.

If you choose not to go one of these routes you can try grouping email
addresses together (perhaps 50 at a time) and batch listing them in the bcc
header.  You'll likely have to increase PHP's timeout setting in php.ini or
within the script itself.  I don't recommend this method b/c it will be
*much* slower and you will not be able to take advantage of some of the nice
features of your MLM that you should really use for a list this large.  FYI,
there are also methods for accessing SMTP directly (which avoids the mail()
function completely).  I know there's a class at
http://phpclasses.upperdesign.com/ and there are others elsewhere.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Add data to three tables at once from one form

2001-04-20 Thread Steve Werby

"Julian Wood" [EMAIL PROTECTED] wrote:
  That's it.  There's nothing special to do.

 Except if one insert fails and the others succeed, you run into a bit of
 sync trouble. This is what transactions are for. You might want to
consider
 a BDB table type, which supports transactions, then you have the option to
 rollback the other inserts if one of them fails.

Good point.  I assumed that if the original poster didn't know how to
accomplish 3 DB inserts within a PHP script then transactions and rollbacks
were a little too advanced to get into (and the DB being used was never
stated).

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] how to scale down image using ImageMagick?

2001-04-19 Thread Steve Werby

"Noah Spitzer-Williams" [EMAIL PROTECTED] wrote:
 I have a bunch of pictures all in ranging filesizes and dimensions. I want
 to resize the ones that over 175 pixels wide to a 175 pixel wide picture
 however i want the height to scale down (ie. i dont want a really thin
 picture, i just want it to be what it would be if it were resized). i have
 this but i cant figure out how to just scale down the width:

 c:\progra~1\imagem~1\mogrify.exe -geometry 175x30! picture.jpeg

 the '!' forces those sizes to be used but obvoiusly i dont want the height
 to be 30. i want it to be whatever it should be so the picture doesnt look
 flattened.

I believe imagemagick has an option where you can specify a single dimension
(x or y) and it will set that dimension accordingly and automatically scale
the other dimension.  This should be covered in the manual pages or --help
output of the program.


--
--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] replace function in a file.

2001-04-19 Thread Steve Werby

"Mark Lo" [EMAIL PROTECTED] wrote:
 Is there any function exists which to open a specific file, then find
a
 specific word, if found, then replace that word with something else.

In addition to the solution mentioned using PHP filesystem functions, you
could use Unix command like grep, sed, etc. called from within your PHP
script to accomplish this.  Or you could use a search and replace program
like rpl (happens to be free) which you can download from
http://www.laffeycomputer.com/rpl.html.  rpl's syntax is very simple - "rpl
'old_string' 'new_string' filename" and you can call it using one of the
program execution functions or by enclosing it within backticks.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




  1   2   3   >