Re: [PHP] Programming the Hard Way?

2001-01-27 Thread Steve Werby

"[ rswfire ]" [EMAIL PROTECTED] wrote"
 Am I programming the hard way?
 mysql_query("SELECT * FROM table WHERE id='".$id."'");

 Could I just do this?
 mysql_query("SELECT * FROM table WHERE id='$id'");

Yes.  And if $id is always numeric you could simplify it even more.  Quotes
are only needed around strings.  They aren't needed around numbers.  If you
surround a number in quotes it's treated as a string which will result in
different behavior when doing sorting and  or  comparisons.

mysql_query( "SELECT * FROM table WHERE id=$id " );

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Why?? SPRINTF(SELECT sequence,prodnum,childdesc....);

2001-02-01 Thread Steve Werby

"Karl J. Stubsjoen" [EMAIL PROTECTED] wrote:
 What is the purpose of the SPRINTF in this instance?
 SPRINTF("SELECT

equence,prodnum,childdesc,onhand,openorders,avlallocate,bakorder,webpricing
 FROM prodaval");

It appears as though the sprintf() function is being misused.  There's no
advantage to using it to wrap around an SQL statement.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] contracting consulting (was [PHP] Pricing for PHP programming???)

2001-02-01 Thread Steve Werby

"Benjamin Munoz" [EMAIL PROTECTED] wrote:
 Great thread. When I was changing jobs in April of 2000, a recruiter told
me
 that PHP is "cool and all", but there is zero demand for developers of PHP
 web apps (in Los Angeles).

Interesting.  We're located in [not very large, but high tech/internet
concentration] Charlottesville, Virginia and there's a pretty significant
demand for PHP-based apps and websites.  Then again, our target market is
small/medium businesses and small internet startups and after assessing a
client's needs, working with them to define a solution and developing a
proposal that nearly always uses LAMP the clients rarely care what we use as
long as we deliver.  Sure, larger, stodgier corportate clients with IT
departments are more resistent to utilizing PHP and open source technology
for their enterprise solutions, but they aren't the only customers out
there.

 therefore command a higher wage.  Demand vs supply, right?.  A search
today
 on monster.com for ASP in LA yields 142 listings, Java yields 262, JSP
 yields 32, Perl yields 105, PHP yields 16, cold fusion yields 16.

Odd.  My search on monster.com for "php" turned up 324 listings.  I *wish*
there were less - we have listings 135 and 136 and have not found the right
candidate yet.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Pricing for PHP programming???

2001-02-01 Thread Steve Werby

"Shane McBride" [EMAIL PROTECTED] wrote:
 I was wondering what other PHP people charge to write PHP?

There's no magic answer.  And no offense, but if you categorize building
business solutions delivered via the internet as "writing PHP" then your
services probably shouldn't be priced at the higher end of the spectrum.
There are so many factors - size of project, complexity, reusability of
project components, turnaround time, your reputation, your speed, geography,
etc.  And there are many ways to price a project.  We use a combination of
flat rate pricing, estimates with a cap, hourly rates, retainer arrangements
and some more creative terms depending on another long list of factors.

As a PHP programmer and COO of a development and consulting shop, the
emphasis on hourly rate is something that really amazes me.  Not all
programmers are created equal.  A lot of clients don't recognize that.  Some
mistakenly believe that a $120/hr. programmer is 20% more productive than a
$100/hr. programmer.  Yet others think that a $200/hr. programmer must be
twice as good as a $100/hr. programmer.  I find that there is *no*
correlation between hourly rate and the quality, productivity and value of a
programmer.  Sure, in other non_knowledge_based occupations, there may be a
correlation, but in our biz I don't see one.  Some say "you get what you pay
for", but b/c this industry is new there are a lot of unscrupulous
developers out there talking with naive uneducated clients.  This is a
dangerous mix.  We've talked to a number of prospective clients who were
charged $100,000+ for projects we could have done for $5,000.  I couldn't
sleep at night if we gouged clients like that and in the long run I think
gouging clients will come back to bite you.  We try to emphasize the total
cost to the client along with the benefits of our proposed solutions.  We
try to state these benefits in terms of time savings, exposure, value-added
capabilities, revenue and process improvement.  When you can put what you
can bring to the table in these terms the hourly rate becomes less critical
and it makes it easier to compete with inferior competitors that compete on
price alone.

So, in general what should you charge based on your skills, experience and
the types of things you are building?  At a mimimum you should charge enough
to cover the cost of your operation taking into account the risk of not
staying fully utlized and adding on enough to make an acceptable amount of
profit.  If after arriving at that number it seems that your target market
can't support that rate, reassess your strategy.  As a rule of thumb, a
consulting biz needs to charge 2.5 - 3 times the hourly rate payed to its
employees.  If you're a one person operation, you might think you need to
charge less, but I wouldn't look at it that way.  Unless you have clients
breaking your door down and your clients aren't aware that there *are*
others like you, you'll probably have to spend a significant amount of
non-billable time dealing with running the business, doing marketing, sales
and other business functions.  And if you're alternative is working as an
employee of another company and earning a steady paycheck (unless you just
don't want to work for anyone else) you should plan on at least making
enough to earn more than this alternative.

If I was trying to gauge my value I would probably start low, build up word
of mouth, client referrals and long term relationships and then increase my
rates gradually over time if the market allows you to do so.  In my area a
green PHP programmer working part time might be able do contract work for
$15 an hour while a seasoned guru might be able to command $150 an hour.
Over time your programming skills, productivity and business knowledge
should continuously increase.  As a result your margins should increase,
even if your so called "hourly rate" remains flat.  Unless of course you
hire other people.  That may make your operation much more complex and
difficult to manage than you may think.  Plus, any development firm that
hires a PHP programmer is reducing the pool of PHP programmers available to
my company and I just can't have that.  grin

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Automatic incoming mail notification

2001-02-01 Thread Steve Werby

"Josh G" [EMAIL PROTECTED] wrote:
 Depends on your mailserver. Most mail servers can redirect incoming
 mail to a program, I know sendmail can. In your case just make the first
 line of your script #!/path/to/php/bin/php and that should do the trick.

To actually read from the message piped to the PHP script, you'll need to
use the following to read from STDIN:

fopen( 'php://stdin', 'r' );

The above isn't widely documented, but it works.  With all this said, if the
original poster simply wants to let a web-based user know that there is a
new message in the user's email box, a better strategy may be to store all
of the messages in a database like MySQL and compare the timestamp on the
most recent message to the timestamp in a session variable from the previous
page access.  It wasn't clear what the poster was attempting, but with some
more details someone (maybe me) could provide a good solution.  Also, PHP
has functions for accessing IMAP accounts which could prove useful.

 Sorry I don't know how to make sendmail do it, only that you can.

Using sendmail you add an alias to pipe incoming email to a program (your
PHP script).  You may also need to create a symbolic link in a directory
utilized by smrsh (sendmail restricted shell) to allow sendmail to execute
your script (this is done for security reasons).  "man smrsh" for details.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Performance question

2001-02-02 Thread Steve Werby

"Matthew Mundy" [EMAIL PROTECTED] wrote:
 I was wondering.  What kind of performance reduction is there in including
 files or using the auto prepended one for a file less than, say, 10 line?
 Specifically, I would think that the file IO would be a detriment to such
 a small file.  Without the includes, code would be repeated, but in PHP,
 IMHO, speed is a much more important factor than code size.  Anyways, what
 would be the performance factors in deciding what goes in an include vs
 inline code?

I don't think you'll find a noticable difference in speed.  To me the
benefit of a modular design outweighs the effect on speed.  As a rule of
thumb, I take any code that will be used in multiple files and store in a
separate file, but development speed is my most critical constraint.
Reduced file size is a nice side effect, but storage space is so cheap that
really doesn't matter.  And if you want to increase the speed from the user
perspective you may want to look at a combination of caching and sending
gzipped data to browsers that support it.  There was a tutorial on
phpbuilder.com recently about this strategy and with the exception of a few
obstacles it works nicely depending on what your output is like.  You might
want to benchmark including the code inline versus using include() or auto
prepending it by writing a program to simulate expected (or heavy) usage of
the script in question and using something similar to the code below to
track the time that the script took to run.  On small simple programs the
results will be skewed by the time it takes to actually run the code below,
but on longer, more complex scripts that will be neglible when comparing
your test cases.

?php
// Set start time of script.
$time_start = microtime();
$time_start = explode( " ", $time_start );
$time_start = $time_start[1] + $time_start[0];


// Set end time of script.
$time_end = microtime();
$time_end = explode( " ", $time_end );
$time_end = $time_end[1] + $time_end[0];

// Measure script run time.
$time_run = $time_end - $time_start;

// Write output to file.
// Left as user exercise.
?

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Pricing for PHP programming???

2001-02-02 Thread Steve Werby

"Siim Einfeldt aka Itpunk" [EMAIL PROTECTED] wrote:
 But here I have to disagree with you. Yes, some guys who charge only $10/h
 might sometimes be better than $200/h, but you cant say that there is
 *no* corralation between rates and quality. Sometimes there actually
 is.

$10 versus $200 is a little extreme, but I agree that there is sometimes a
correlation between rates and quality if we're talking about programmers or
firms that deal with larger, better educated (in terms of software
development) clients.  If we're talking about individual programmers that
deal with smaller clients I don't find this to be the case.  Because smaller
clients tend to understand the technology and the process less and often
can't recognize the difference between a guru and a hack.

 I usually dont charge for hour either, rather per project, but your
 example of $5000 and $100,000. Well, what is the purpose of your
 doings? Many of us like what we do, but the second reason (if not the
 first) for doing it, is money, you can say whatever you want, but this is
 true for mosy of the peops.

Obviously I want to be profitable.  But my primary motivation is to be doing
challenging work, to enjoy what I'm doing and to build software that makes
my clients happy.  Sure, we could be like this other company and charge
$100,000 for a project that's worth $5,000 but we won't do that.  Why?
Because it will inevitably come back to haunt us.  In this business you have
little more than your knowledge and your reputation and a tarnished
reputation won't get you far.  YMMV.

 And lets talk about clients just a bit more. A decent firm, before it
 starts buying something, it looks on more than one direction, they make
 their job on getting to know the prices and services that are being
 offered to decide where to order something.

Again, I think we're talking about different kinds of clients.  A large
corporate client looking for someone to fulfill a large project will spend a
lot of time doing research, soliciting quotes and in general will be well
educated in terms of what's involved and what it should cost.  A small brick
and mortar company or shoestring budget startup headed by a non-technical
person might not have that luxury and generally doesn't have the time,
energy or expertise to make a qualified decision.  My experience is that a
lot of these type of clients only speak to 1 to 3 firms.  And these other
firms are often not qualified - they don't understand the business world or
don't even do programming.  In fact, last week I spoke to the head of a
small internet startup that was soliciting bids for a search engine for his
site.  His site consisted *entirely* of hundreds of identically formatted
static pages that were created by combining text and images in Photoshop.
He got bids from 2 other firms before me about building a search engine for
the site.  We were the only firm that informed him that no search engine can
search text from within an image (meaning the other firms had no clue) and
that if we built him a database driven site with an admin interface to
upload images, create records and modify text he could save 15 minutes per
page built for the site and modify the entire look of the site in under an
hour.  Based on his projection this would save him about 300 hours a year.
These are the type of clients we typically deal with 80% of the time.  We're
comfortable doing it, but we don't rip them off just because they're
uneducated.

 $100,000 instead of $5000? You shouldnt. In some other fields you could
 say that they just didn`t have any other candidates to choose from, but
 when talking about programming and php, well, you just can`t say it, can
 you? Most of the projects can be done even over the internet, no problems.

My reality is different than your reality.  I don't know if I want to trade
places or not.  grin

 shouldn`t count on all the jobsites available in the internet, rather word
 of mouth, this is the best way.

Amen.  If you do good work for a fair price and make the experience
pleasurable for your clients the work will come.  It's like any business.
People want to work with people they like and if your customers like you
they'll mention you to others.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] getting STDIO

2001-02-02 Thread Steve Werby

"Martin A. Marques" [EMAIL PROTECTED] wrote:
 Lets say my script is named script1.php and I do:
 
 $ less file1 | script1.php

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

Then use the standard file handling functions to access the piped data.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Undefined variable

2001-02-03 Thread Steve Werby

"Dundee (Roland)" [EMAIL PROTECTED] wrote:
 When creating a page(php) on Win2000 I get alot of 'Undefined variable'
 error messages, but there are no errors at all running the same page on a
 apache server.

Is the variable a user defined variable?  If so, my guess is the error
reporting level for the two servers is different.  See the error handling
section of php.ini and see if the default settings differ b/w the two
servers.  Also see error_reporting() if you're explicitly using that
function.  If the variable is a PHP or environment variable perhaps the
variable is available on Apache, but not on Win2k.  I have very little
experience with PHP on Windows so it could be something else, but that's
where I'd start.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] CGI vs PHP

2001-02-03 Thread Steve Werby

"phpLover" [EMAIL PROTECTED] wrote:
 I am sorry if my question is confusing. What I mean is that CGI is
excellent
 in handling flat file data base, reading and writing files line by line,
 word by wor. So is PHP equally strong?

I assume you mean Perl CGI - there are many programming languages that can
run as a CGI.  PHP installed as an Apache module will in general run scripts
faster than a Perl CGI or PHP CGI.  PHP works great for file handling
scripts, though as your files grow you'll probably want to consider using
databases instead of flat files.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Replacing A Word in HTML page

2001-02-03 Thread Steve Werby

"phpLover" [EMAIL PROTECTED] wrote:
 I want to read an HTML page from another site and replace certain
characters
 with capital letters and show them in another dynamically generated web
page
 on my site. I know this is possible in Perl, but can this be done in PHP?
If
 yes, then how?

It's definitely possible in PHP.  I've done it.  You probably want to use a
combination of fopen() and other file handling functions, eregi_replace()
and str_replace().

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] % operator

2001-02-04 Thread Steve Werby

"Dhaval Desai" [EMAIL PROTECTED] wrote:
 what is the use of %

It returns a remainder.  For example 7 % 2 = 1.

 Is it called modulo..what is it's use in PHP.?

There are plenty of situations where it's useful.  For example, if you're
displaying data in rows and want to shade every other row:

if ( 1 == $row_count % 2 ) { echo "trtd$data/td/tr"; }
else { echo "trtd class='shade-1'$data/td/tr"; }

Or if you have a data set you want to display in an HTML table across
multiple rows, you'll probably find it useful for determining when to put
tr or /tr as you loop through your data set and use it to calculate
whether you will need to fill cells at the end of the table with
non-breaking spaces.  There are many other applications, but these two come
up pretty frequently in web applications.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Arrays from forms

2001-02-04 Thread Steve Werby

"Jamie" [EMAIL PROTECTED] wrote:
 $results = mysql_query("SELECT option_type, code FROM options WHERE
 code='000' ORDER BY option_type",$db);
  mysql_fetch_array($results);
 // From what  understand I should have an array some thig like this:
 // ("Size"="A4" , "Size" = "A3", "Size"="A5", "Colour"="Red", etc..);

According to your SQL statement that doesn't appear to be true.  According
to your SQL statement you'll return two fields: option_type and code.

  $types = array_values($results);
 // OK so now I think I have an array like this:
 // ("A4" , "A3", "A5", "Red", etc..);
   while ($type =array_pop($types)){
echo $type."br";
  }

I'd avoid using array_values() and array_pop().  Simply do this:

while ( $row = mysql_fetch_array( $result ) )
{
    $option_type = $row[option_type];
$code = $row[code];
echo "$option_type $codebr";
}

Hopefully that'll be enough to get you going.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] Replacing A Word in HTML page

2001-02-04 Thread Steve Werby

"phpLover" [EMAIL PROTECTED] wrote:
 Thanks for your answerm but what does eregi_replace() do?

Short answer is to see
http://www.php.net/manual/en/function.eregi-replace.php.  Usage examples can
be found right on php.net.  See longer answer below.

Previously "phpLover" [EMAIL PROTECTED] wrote:
 I want to read an HTML page from another site and replace certain
 characters
 with capital letters and show them in another dynamically generated web
 page on my site.

I should have said use ereg_replace().  It matches text using regular
expressions (regular expressions allow for complex matching) in a
case-sensitive manner.  Depending on the specifics of what you're attempting
it may be of use.  You could use it to replace certain characters within a
specific part of the HTML source page (but ignore the same characters within
other parts of the page) with capital letters (like you described).  If you
simply want to replace all matches within the page str_replace() is a better
choice.  Regular expressions are a more difficult concept to master than a
lot of other concepts within PHP so you may want to look at some tutorials
or books on the subject.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.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] split string value again

2001-03-29 Thread Steve Werby

"Jacky" [EMAIL PROTECTED] wrote:
 I have a vairable that stores email address value. I need to break it so
 that I will only get the dmain name bit to store in another variable so
 that
 I can redirect user to that domain, like if user email is [EMAIL PROTECTED]
 then I would like to break that and take only foo.com bit to use for
 navigation.

I don't think any of the responses you got took into account email addresses
like [EMAIL PROTECTED]  If you truely just want domain.tld it's a little
more complex.  I happened to have written a script a few months ago that
does what you want.  Even if you don't need something this complex in your
case, my code uses 5 or 6 string functions and arrays so it's a pretty good
example of how to manipulate strings in PHP.

?php
// Expecting a properly formatted email address.
$string_in = '[EMAIL PROTECTED]';

// strpos() finds position of '@' character.
// substr() returns portion of email address to the
// right of '@' (the host).
$string_tmp = substr( $string_in, strpos( $string, '@' ) + 1 );

// substr_count() returns the # of occurrences of '.' within the host.
$dot_count = substr_count( $string_tmp, '.' );

// If only one dot was found, we're done.
if ( $dot_count == 1 )
{
$string_out = $string_tmp;
}
// If more than one dot was found, there's more to do.
else
{
// explode() splits the host into elements of an array.
// The elements are the portions of the string between the dots.
$parts = explode( '.', $string_tmp );

// count() returns the number of elements.  We want the
// last 2 elements.  Since the array elements begin at 0, not 1,
// we need to get elements n-2 and n-1, not n-1 and n, which
// might normally be expected.
$string_out = $parts[count( $parts ) - 2] . '.' . $parts[count( $parts ) -
1];
}

// print the desired output.
echo $string_out;
?

--
Steve Werby
President
Befriend Internet Services LLC
Tel: 804-355-WEBS
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] Execute Shell command?

2001-04-01 Thread Steve Werby

[EMAIL PROTECTED] wrote:
 Does anyone know if there is a way to execute a shell command in a php
 script? I am trying to execute the following:

 /usr/sbin/cadduser -d www.domain.com -f Adrian -u testing -p testing -q
10 -w
 [EMAIL PROTECTED]

If you're running an Apache module version of PHP, the program you are
trying to execute will have to be owned by the same owner as Apache and user
executable (chmod u+x cadduser) or world executable (chmod o+x cadduser)
which is not good from a security standpoint.  I'm not certain, but cadduser
seems like the name of a script to add a user to Linux from the Cobalt
RaQ3/4 shell tool package so you're probably running PHP as an Apache
module.  The alternative is to install a second copy of PHP as a CGI, in
which case each PHP script runs as the owner of that script.  So if an
external program is owned by root, your PHP script can run it through a
shell command by making your PHP script owned by root.

Hopefully that will help you get closer to a solution.  If not, you'll
probably get better assistance if you post the answers to the following
questions:

What operating system, who owns the script and what are the permissions on
it?  Is PHP running as an Apache module or as a CGI?  If it's an Apache
module, what owner does Apache runs as?

Also, if your system is a Cobalt RaQ you may want to post to the
cobalt-users mailing list
(http://list.cobalt.com/mailman/listinfo/cobalt-users/) to signup.

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

2001-04-01 Thread Steve Werby

"Joe Montiel" [EMAIL PROTECTED] wrote:
 I am new to the list and to php...I would like to know how php does with
the
 major search engines. Do I need to do something extra to make it work?
Will
 it index if I am pulling my content from text files?

PHP produces HTML output which is sent to a browser, spider, etc.
Everything else being equal about content on a webpage, a PHP generated file
and a static HTML file are identical, with the possible exception of the
file extension.  There are a few "gotchas".  A search engine can recognize a
.php* file extension and assign it a penalty, though I'm not aware of this
happening.  If that's a fear you can always configure your webserver to
parse .html files using PHP.  Some search engines will ignore or penalize
webpages with query strings in them (query strings are variable-value pairs
following a "?" after the webpage name).  The logic for this makes sense
since a lot of pages like that are dynamically generated and a search engine
will be less effective if it indexes a page and a few days later a user does
a search, it appears in the results and the user goes there and the page no
longer exists or contains different content than was indexed.  An easy way
around this (at least in Apache) is to create dynamically generated webpages
that appear static.  This can be accomplished by using AliasMatch lines in
your Apache config. file to point a group of URLs (such as all beginning
with '/books/') to a single PHP file.  Then within the PHP file use a
combination of regular expressions and environment variables (among other
solutions) to pull the proper content from a file or database.

For example if you have a URL like '/books/516.html' you can do:
eregi( '^/books/(.*).html', $SCRIPT_URL, $regs ) )
// $regs[1] will contain '516'.
// Grab record from database with id 516.

Offhand, the only other things to watch for are don't do fast meta redirects
(or any redirects at all) and if your PHP file hasn't been updated in
months, but the database data it pulls from has updated recently, it's
likely that browsers and spiders may think their cached copies of your
webpage are current.  A solution is to use a combination of header()
functions like:

header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );

Making your webpages appear at the top of search engines for your desired
search phrases is another story.  Though I live talking about search engine
optimization strategies and steps, this isn't the right forum for giving
away all of the secrets.  smile

--
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] session in php3 and in php4

2001-04-01 Thread Steve Werby

"Jacky" [EMAIL PROTECTED] wrote:
 If there is no way to get around this, what is syntax for assign session
in php4 then?

PHP session support is possible in PHP3 using a 3rd party module from the
PHP Base Library (http://phplib.netuse.de/) which is pretty widely used.
For session handling in PHP4 see the manual
(http://www.php.net/manual/en/ref.session.php) and you may want to check
zend.com, phpbuilder.com, etc. for tutorials, code snippets and examples.

--
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] Can php read and than print file like it is

2001-04-02 Thread Steve Werby

"Jan Grafstrm" [EMAIL PROTECTED] wrote:
 I have a file with text on 17 rows and when I let php read it ,get
 filezise and than print I only get the first row.
 I want all rows exatly like it is in the file, is it possible?
 My file:
 html
 head

Yes, it's possible.  Post your code so we can see what you've tried.  I
suggest using fopen() and fgets() to accomplish what you want.  The first
example in the manual at http://www.php.net/manual/en/function.fgets.php
does exactly what you want.

--
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] Can php read and than print file like it is

2001-04-02 Thread Steve Werby

"Jan Grafstrm" [EMAIL PROTECTED] wrote:
 Thank You Steve!
 Here is my php
 
 ?
  $fillista = "fillista.xml";
  $fp = @fopen($fillista,r);
  $count = fgets($fp,filesize($fillista));
  fclose($fp);
  print "fillista=".$count;
 ?

Your call to fgets() is only returning the first line of the input file.
Add the following line after it and $count will now have the first 2 lines:

$count .= fgets($fp,filesize($fillista));

If you construct your code to *loop* through the input file using fgets()
like the first example at http://www.php.net/manual/en/function.fgets.php
that I mentioned your problem will be solved.  Good luck!

--
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] Looping through the alphabet [was: Why does it work this way?]

2001-04-02 Thread Steve Werby

"Boget, Chris" [EMAIL PROTECTED] wrote:
 for( $i = "a"; $i = "z"; $i++ ) {
 }

 Not entirely too sure why, but the above works.  And
 it's really cool that it does. :)
 However, it doesn't work as one would expect (aside

You may know this already and not have a need, but for the benefit of others
who may have read your post, you can loop through 'a' to 'z' using the chr()
function as follows:

?php
for ( $i = 97; $i = 122; $i++ )
{
echo chr( $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] duplicate a table

2001-04-02 Thread Steve Werby

"McShen" [EMAIL PROTECTED] wrote:
 how do i duplicate a table?
 i tried
 create table refer2 select * from refer;
 create table refer2 as select * from refer;

 they didn't work.
 my mysql version is  mysql 3.22.28,

This has nothing to do with PHP - you should post to the MySQL list instead.
Anyway, the first SQL statement you tried will work in MySQL 3.23x, but not
3.22x.  You'll need to upgrade to 3.23, use SELECT INTO OUTFILE then import
back into a new table after creating it, or use mysqldump or another utility
to create INSERT statements from your table, edit the table name and then
use MySQL to run the INSERTs.

--
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] SQL : multiple SELECT and missing rows.

2001-04-02 Thread Steve Werby

"Maxim Maletsky" [EMAIL PROTECTED] wrote:
 As you can see, the main data is in 'accounts', the 'addresses.ID' is
UNIQUE
 and corresponds to 'accounts.ID'. The fact is that not every account has
an
 address registered with it.
snip
 FROM
 accounts,
 addresses

You're doing a straight join.  You need to use a LEFT JOIN to return all the
records from one table and those from a second table that match based on a
common field.  Read about joins in the manual and find a resource on SQL
statements - it'll pay off.

SELECT *
FROM accounts
LEFT JOIN addresses
ON addresses.ID = accounts.ID


 Can anyone suggest me how do I SELECT ALL of the accounts having simply
NULL
 on 'addresses.*' when there's no such row, instead of 'loosing' the whole
 'account' row?

Use the query above and add:
WHERE addresses.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] Please Help!

2001-04-02 Thread Steve Werby

"E K L" [EMAIL PROTECTED] wrote:
 $tpl = new FastTemplate("../usr/local/apache/htdocs/toplevel.tpl");

According to the error, the path above is incorrect.  Looking at it, my
guess is that the path might really be:

"/usr/local/apache/htdocs/toplevel.tpl"

--
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 RaQ XTR(slightly OT)

2001-04-03 Thread Steve Werby

"Phil Driscoll" [EMAIL PROTECTED] wrote:
 I have a number of php4/mysql sites running from various NT boxes. I have
 the opportunity to move a lot of stuff across from one of the NT boxes
onto
 a new Cobalt RaQ XTR. This job will have to be done in a hurry. If anyone
 can prewarn me of any problems, or better still, tell me it will all run
 like a dream, I'd be most grateful.

I administer a few RaQs and have done a lot of work for clients with RaQs
(no XTRs yet).  You may have to go through the web files and make sure paths
are correct and you'll need to chown and chmod the files to the proper
values.  Of course you'll need to recreate entries in the MySQL 'mysql'
database.  If you're migrating any of the sites to a newer version of PHP or
from a much older version you may have some compatibility problems with some
functions and may need to go through some code.  And if the new and old
versions are configured differently (like having differences in whether
magic quotes is on/off and short PHP tags are on/off) you may have to make
some code changes.  Otherwise it should be a pretty smooth transition.

--
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] upgrade question

2001-04-03 Thread Steve Werby

"Walgamotte, David" [EMAIL PROTECTED] wrote:
 I want to upgrade to 4.04pl1 PHP, I just downloaded the source from their
 website. One problem I have had in the past, is when I recompile PHP with
 different support options the phpinfo() still displays the old
information.
 Could anyone help me to find out where phpinfo() is pulling it's
information
 or direct me to an upgrade "how to"
 for PHP ?

Perhaps you should try deleting the old install first.  locate php, then
rm -rf [DIRECTORIES_HERE] or rpm -e [PHP_PKG_HERE].

--
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] Validation Email in PHP programs

2001-04-03 Thread Steve Werby

"Renze Munnik" [EMAIL PROTECTED] wrote:
 Besides the RE you might wanna take a look at these functions:

 http://www.php.net/manual/en/function.getmxrr.php
 and
 http://www.php.net/manual/en/function.checkdnsrr.php

 Using (one of) those you can check the email-address better. I.e.
 the domain. Extract the domainname from the given email-address and
 feed it to either one of these and you'll get a result whether or
 not the domain has an MX-record.

Here's some personal insight to consider.  This will work and I toyed with
it in the past.  There are a few gotchas:

1. For a valid host, if DNS is slow it may add several seconds to the
script.
2. If it's not a valid host, the script will run until the lookup times out.
3. If the host is temporarily down or inaccessible it will falsely report
that it doesn't exist.

So it really depends what you're trying to do.

 Only thing left is whether or not
 the user exists on the given mailserver. But for as far as I know
 you can't automatically check that.

Renze is correct.  Unless you're checking local email addresses which you
control, there's no way to check down to that level.  And be happy there
isn't.  Otherwise the amount of spam you get right now will increase ten
fold.

--
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] Validation Email in PHP programs

2001-04-03 Thread Steve Werby

"Steve Werby" [EMAIL PROTECTED] wrote
 Renze is correct.  Unless you're checking local email addresses which you
 control, there's no way to check down to that level.  And be happy there
 isn't.  Otherwise the amount of spam you get right now will increase ten
 fold.

I should have said there's no *reliable* way to check whether an email
address on an external server is valid.  Mail servers that have the SMTP
VRFY command (and to a lesser extent the EXPN command) enabled may be able
to tell whether an email address is valid.  Since many (probably most) have
these turned off and many domains have catchall email accounts installed
connecting to an SMTP server to check would not reliably tell you whether
the user supplied email address is asociated with an email account used by a
human being.

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




  1   2   3   >