Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Borokov Smith
if (isset($_GET['order']  in_array($_GET['order'], array('Last', 
'First', ...))) { $requestedOrder = $_GET['order']; } else { 
$requestedOrder = your default; }


Mind the in_array() call. Always sanitize user input.

greetz,

boro


Jason Pruim schreef:

Hi All :)

Hope you're not getting sick of my questions as of late, but I keep 
getting closer and closer and thank you all who have helped me in the 
past! The only reason I can see this far is I am standing on the 
shoulders of giants don't know who said that but I like it :)


Anyway... Onto the question...

I think I'm just going crazy as it's been a busy week for me, but I 
can't figure out how to do this. What I am attempting to do is, I have 
a webpage(Don't we all?) that calls info to be displayed from a database,


I want to be able to sort that info so my sql query looks like: 
Select * from current order by '$order'; and $order is populated by 
a GET when they click on a link: A href=index.php?order='Last'Sort 
by last name/A  Now... the whole PHP page is being included in a 
.shtml page to actually display it and make it look purrdee :)


How do I get it to resort the info and include the new sort on the page?

I'm not sure if this has anything to do with it but:

$order = $_GET['order']; --Line 6

[Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:  
order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php on 
line 6


Any help will be greatly appreciated.. And if it solves the problem 
I'll name some of my kids* after you!




*Subject to approval of the Wife :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] string as file

2007-08-10 Thread Stut

Robert Cummings wrote:

On Fri, 2007-08-10 at 16:28 +0100, Stut wrote:

Rick Pasotto wrote:

On Fri, Aug 10, 2007 at 02:19:29PM +0100, Stut wrote:

Rick Pasotto wrote:

On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote:

On 8/9/07, Rick Pasotto [EMAIL PROTECTED] wrote:

Does php have a facility similar to python's stringIO?

What I'm wanting to do is similar to a mail merge. IOW, I know I can
create an include file like:

$out = EOT
This is an example of $var1 and $var2.
EOT;

and then after assigning values to $var1 and $var2 include that
file. I can later use different values for $var1 and $var2 and get a
different $out with a second include.

eval()

Explain.
One word responses really don't do any good.
Exactly *what* would be the argument to eval()?

RTFM, that's what it's there for.

I did. That's why I rejected the use of eval() before I posted the
message. eval() is totally unsuitable for what I want. Unless, that is,
you or Greg can explain how using eval() will get me what I want.

I think that neither you nor Greg understands what I'm looking for.

Instead of simply stating 'RTFM' perhaps *you* should RTFQuestion.

Your original post asked...

Can I someout include a string instead of a file?

That's exactly what eval does. As for what you would pass to it... PHP 
code maybe? Have you even tried it? The manual page for eval has several 
examples of how to use it, and the comments have even more.



Incidentally, eval is evil and potentially a giant security hole.
You'd be better off doing replacements with preg_match rather than
executing a string.

Agreed. That's another reason I had already rejected it. Although in
this case, since I would have full control of all the variables, it
would probably be ok.
Use regular expressions or straight string replacements - that's the 
best way to implement mail-merge type behaviour. Personally I used 
preg_replace with the 'e' modifier. For an example see, shockingly, the 
manual page for preg_replace.


Now go stick your head in a pig.


Spider-Pig, Spider-Pig, does whatever a Spider-Pig does...

:) I love Fridays!!


It's Friday? Gawdammit!

-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
 On 8/10/07, Stut [EMAIL PROTECTED] wrote:
   I get an email from each
  server containing the contents of the error log from the previous day
  and my first task each day is to go through that and track down any
  issues that usage has highlighted.
 
 That's actually a good point there that I can take away from this.
  I actually don't have anything set to send me a log of code issues,
 only when an error is caused (and, of course, anything server-related,
 but that's a different point entirely).

Simple enough... put the following in a file, and add a cron job.

#!/usr/bin/php -qC
?php

if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
{
echo Usage: {$argv[0]} subject email path\n;
exit( 1 );
}

$subject = $argv[1];
$email   = $argv[2];
$path= $argv[3];

$content = implode( '', file( $path ) );

if( trim( $content ) === '' )
{
$content = 'NO ERRORS TODAY!!!';
}

mail( $email, $subject, $content );

?

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



[PHP] Recursion and threaded message boards...

2007-08-10 Thread Tony Di Croce
I have to write some PHP backend code for a threaded message board. The db
has a message table, and each message has a parent id.

Does anyone have any advice for someone whos never done this in PHP?

I'm currently thinking that I write function that takes a db row as an
argument, and initially, it is passed the root node of the whole tree. It is
also probably passed a string variable.

The first thing it will do is append the code for itself to the string.

Then it will query the DB for all its children (with an order by post
timestamp), and for every child, it will call itself on that child row.

Am I on the right track? (I've done simmilar things in C++, just not in
PHP)...

td

-- 
Publish technical articles @ skilledwords.com and get 100% of the
ad-revenue!
http://www.skilledwords.com


Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
 On Fri, 2007-08-10 at 11:40 -0400, Daniel Brown wrote:
  On 8/10/07, Stut [EMAIL PROTECTED] wrote:
   If PHP thinks something might be wrong it will tell you. Why on earth
   would you want to ignore it? You think you're smarter than PHP? Really?
 
  Okay, Stut, let's not make Friday the official Flame Dan Brown
  holiday this week.  I vote that it should be later in the year.
 
  However, it should also be noted that my development is never done
  on a production server attached to the Internet, for one; and on my
  development machine, E_NOTICE is always enabled.  I just fail to see
  the benefit in alerting visitors to the site that there may have been
  something overlooked at some point.

 Why would it alert visitors? You don't have display errors set to on for
 a production server do you? *EK*. Send it to a log file. The
 reason it's good to enable notices on a production server is because
 your visitors are like a horde of testers, they'll probably hit every
 nook and cranny of your code that you might have missed during testing.

 Cheers,
 Rob.
 --
 ...
 SwarmBuy.com - http://www.swarmbuy.com

 Leveraging the buying power of the masses!
 ...


Ha!  No, I don't have it set to display anything to the user
except for a custom error-handling message.  The generic, there
appears to be a problem, we've been notified, blah, blah, blah

The way I read your point was to say that it should be on display.
 That misunderstanding is my fault.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Daniel Brown wrote:

On 8/10/07, Stut [EMAIL PROTECTED] wrote:

If PHP thinks something might be wrong it will tell you. Why on earth
would you want to ignore it? You think you're smarter than PHP? Really?


Okay, Stut, let's not make Friday the official Flame Dan Brown
holiday this week.  I vote that it should be later in the year.

However, it should also be noted that my development is never done
on a production server attached to the Internet, for one; and on my
development machine, E_NOTICE is always enabled.  I just fail to see
the benefit in alerting visitors to the site that there may have been
something overlooked at some point.


Whoa there nelly, that's a whole other thing.

I've never said users get to see notices. They never see warnings or 
errors. That's what the display_errors and log_errors options in php.ini 
are for. On my production servers error_reporting is set to E_ALL, 
display_errors is off and log_errors is on. I get an email from each 
server containing the contents of the error log from the previous day 
and my first task each day is to go through that and track down any 
issues that usage has highlighted.


-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:40 -0400, Daniel Brown wrote:
 On 8/10/07, Stut [EMAIL PROTECTED] wrote:
  If PHP thinks something might be wrong it will tell you. Why on earth
  would you want to ignore it? You think you're smarter than PHP? Really?
 
 Okay, Stut, let's not make Friday the official Flame Dan Brown
 holiday this week.  I vote that it should be later in the year.
 
 However, it should also be noted that my development is never done
 on a production server attached to the Internet, for one; and on my
 development machine, E_NOTICE is always enabled.  I just fail to see
 the benefit in alerting visitors to the site that there may have been
 something overlooked at some point.

Why would it alert visitors? You don't have display errors set to on for
a production server do you? *EK*. Send it to a log file. The
reason it's good to enable notices on a production server is because
your visitors are like a horde of testers, they'll probably hit every
nook and cranny of your code that you might have missed during testing.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] string as file

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 16:28 +0100, Stut wrote:
 Rick Pasotto wrote:
  On Fri, Aug 10, 2007 at 02:19:29PM +0100, Stut wrote:
  Rick Pasotto wrote:
  On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote:
  On 8/9/07, Rick Pasotto [EMAIL PROTECTED] wrote:
  Does php have a facility similar to python's stringIO?
 
  What I'm wanting to do is similar to a mail merge. IOW, I know I can
  create an include file like:
 
  $out = EOT
  This is an example of $var1 and $var2.
  EOT;
 
  and then after assigning values to $var1 and $var2 include that
  file. I can later use different values for $var1 and $var2 and get a
  different $out with a second include.
  eval()
  Explain.
  One word responses really don't do any good.
  Exactly *what* would be the argument to eval()?
  RTFM, that's what it's there for.
  
  I did. That's why I rejected the use of eval() before I posted the
  message. eval() is totally unsuitable for what I want. Unless, that is,
  you or Greg can explain how using eval() will get me what I want.
  
  I think that neither you nor Greg understands what I'm looking for.
  
  Instead of simply stating 'RTFM' perhaps *you* should RTFQuestion.
 
 Your original post asked...
 
 Can I someout include a string instead of a file?
 
 That's exactly what eval does. As for what you would pass to it... PHP 
 code maybe? Have you even tried it? The manual page for eval has several 
 examples of how to use it, and the comments have even more.
 
  Incidentally, eval is evil and potentially a giant security hole.
  You'd be better off doing replacements with preg_match rather than
  executing a string.
  
  Agreed. That's another reason I had already rejected it. Although in
  this case, since I would have full control of all the variables, it
  would probably be ok.
 
 Use regular expressions or straight string replacements - that's the 
 best way to implement mail-merge type behaviour. Personally I used 
 preg_replace with the 'e' modifier. For an example see, shockingly, the 
 manual page for preg_replace.
 
 Now go stick your head in a pig.

Spider-Pig, Spider-Pig, does whatever a Spider-Pig does...

:) I love Fridays!!

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



[PHP] and newlines under windows

2007-08-10 Thread Faither

Hey there!
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a \n-ewline.


I have a text string from a form and am trying to replace the \n or 
chr(10) or however you might call the newline with a simple html break tag.


If I use the replacing functions I get the br-tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array using:
 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
br-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the \n and chr(10).
This function ignored all newlines and gave me an array with one key and 
the entire text of the textarea as value Oh... and the newlines of 
course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^

Thanks a lot in advance


Stefan

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



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Tijnema
On 8/10/07, Daniel Brown [EMAIL PROTECTED] wrote:
 On 8/10/07, Faither [EMAIL PROTECTED] wrote:
  Hey there!
  I'm kind of lost with how str_replace , preg_replace, ereg_replace or
  even explode are handling a \n-ewline.
 
  I have a text string from a form and am trying to replace the \n or
  chr(10) or however you might call the newline with a simple html break tag.
 
  If I use the replacing functions I get the br-tags where there are
  newlines from the textarea of the form. BUT I still have the newlines
  remain.
 
  So I tried a different approach breaking the text down into an array using:
explode(' ', $string)
  in conjunction with trim() and again made a string out of the array. -
  br-tags still there, newlines aswell -.-'
 
  Next thing I tried was exploding the string using the \n and chr(10).
  This function ignored all newlines and gave me an array with one key and
  the entire text of the textarea as value Oh... and the newlines of
  course were there aswell...
 
  So... How can I get rid of these?! - I just want them gone!
 
  Is it even possible under windows? ^^
 
  Thanks a lot in advance
 
 
  Stefan
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

If I'm not mistaken, Windows doesn't strictly use \n, but rather \r\n.

 --
 Daniel P. Brown
 [office] (570-) 587-7080 Ext. 272
 [mobile] (570-) 766-8107


Just to clarify, the DEFAULT line-endings for OSes:
Windows: \r\n (carriage return followed by a newline)
Unix: \n (newline)
Mac: \r (carriage return)

Of course it is possible to use other line endings on those OSes, but
these are the default.

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Tijnema
On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
 On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
  On 8/10/07, Stut [EMAIL PROTECTED] wrote:
    I get an email from each
   server containing the contents of the error log from the previous day
   and my first task each day is to go through that and track down any
   issues that usage has highlighted.
 
  That's actually a good point there that I can take away from this.
   I actually don't have anything set to send me a log of code issues,
  only when an error is caused (and, of course, anything server-related,
  but that's a different point entirely).

 Simple enough... put the following in a file, and add a cron job.

 #!/usr/bin/php -qC
 ?php

 if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )

if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)

 {
echo Usage: {$argv[0]} subject email path\n;
exit( 1 );
 }

 $subject = $argv[1];
 $email   = $argv[2];
 $path= $argv[3];

 $content = implode( '', file( $path ) );

$content = file_get_contents($path); // Safe to require PHP 4 = 4.3.0 right?


 if( trim( $content ) === '' )
 {
$content = 'NO ERRORS TODAY!!!';
 }

 mail( $email, $subject, $content );

 ?

 Cheers,
 Rob.
 --

And have a nice day!

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 17:53 +0100, Richard Davey wrote:
 Hi Faither,
 
 Friday, August 10, 2007, 5:16:09 PM, you wrote:
 
  I'm kind of lost with how str_replace , preg_replace, ereg_replace or
  even explode are handling a \n-ewline.
 
  I have a text string from a form and am trying to replace the \n or 
  chr(10) or however you might call the newline with a simple html break tag.
 
 Why not just use nl2br() in this case?

It doesn't remove the \n character (or the \r character as is his
problem).

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



[PHP] Re: PHP on .NET DLR

2007-08-10 Thread Sancar Saran
Hello there,

Once upon a time I try to ignite PHP community to develop some kind of client 
side php, which failed, because lack of interest (or because of javascript). 
In open source world everthing boosted from personal interest.

  Hi,

  Thanks for chipping in. Silverlight is not a fad, because it is simply an
 outgrowth of a platform that is 10 year old--the .NET. Technology wise, it
 is merely java applets in XAML format. But it provides people already
 working on .NET an easy way to create the gui. Silverlight's most important
 feature is that it is based on MS's greatest strength--the Desktop.

You mean enterprise mumbo jumbo (read as over engineered perfect world 
(theorically))

My point of wiev Php can deal on enterprise sector with proper handling. (read 
as we had tons of big bad busy websites based on php)

And it doesn't mean PHP have to respond windows desktop development language 
requests.


  Recapitulating:

  a) We have a 10 year old platform the .NET, which while not optimal
 presently, is still being used by a large number of developers.

Hmmm I believe LAMP much older than this, so what is the point ? and you thing 
after inroducing php for windows desktop all of those developers penitent to 
their c# or vb sins ?

  b) Now, MS has finally given them something that can leverage MS's 25 year
 Desktop experience.

Hell who cares Ms Desktop Monopoly ?. Because of MS Desktop Monopoly we had 
that IE thing. Probably because of IE thing coming of Ajax maybe late 5 
years. Entire Web Thingy wants to broke MS Desktop Monoply.

Of course if MS supports PHP in .NET enviroment for Desktop applications  
would be nice and ask yourself is Why MS had to do this... ?

PHP was one of the strudiest Open Source project which MS cannot deal.

  c) PHP can _trivially_ take advantage of both of them--all that's needed
 is to have the community show interest in phalanger, and not let it die.
 Also, the DLR makes porting Dynamic languages very trivial. IT only took MS
 a couple of months to get Ruby on DLR.

If I want to develop big bad nasty desktop thing why should I use PHP and or 
what is PHP GTK populartiy... I did not remember anthing big written in php 
for Desktop.

  d) Ruby--now with silverlight--has everything that PHP has--cross
 platform, dynamic, web ready, and now it has become even more compelling,
 because of PHP community's hostility towards the DLR.

Ruby has Rails, ruby has iron oh no ruby has now silver light. It seems Ruby 
does not mean anything by himself.

We just had PHP and it seems more than enough to developing dynamic web sites 
under LAMP enviroment.

  e) There are a 1000 other benefits to getting PHP on dotnet. One is that
 many VB folks who are used to the procedural style of the old VB6, would
 start loving PHP and will move to it, considering how complex and different
 VB.net is from VB6.

  PHP on .NET has a 1000 reasons. Phalanger is already there. Why are you
 letting it die?

  Thanks again for your input.

Basically.
Most of us want to generate bad websites to generate some revnue, Some of us 
want develop very nasty web applications to replace desktop applications. 

Or

Developing desktop application was not fun only for bread. Deskop development 
area infested by M$ tools and M$ tranied developers. We cannot compete 
against MS with MS rules.

Regards

Sancar

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



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Tijnema
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
 Faither wrote:
  I'm kind of lost with how str_replace , preg_replace, ereg_replace or
  even explode are handling a \n-ewline.
 
  I have a text string from a form and am trying to replace the \n or
  chr(10) or however you might call the newline with a simple html break tag.
 
  If I use the replacing functions I get the br-tags where there are
  newlines from the textarea of the form. BUT I still have the newlines
  remain.
 
  So I tried a different approach breaking the text down into an array using:
   explode(' ', $string)
  in conjunction with trim() and again made a string out of the array. -
  br-tags still there, newlines aswell -.-'
 
  Next thing I tried was exploding the string using the \n and chr(10).
  This function ignored all newlines and gave me an array with one key and
  the entire text of the textarea as value Oh... and the newlines of
  course were there aswell...
 
  So... How can I get rid of these?! - I just want them gone!
 
  Is it even possible under windows? ^^

 First of all look at http://php.net/nl2br which does exactly what you're
 trying to do.

 Second try this...

 $string = str_replace(\r\n, 'br /', $string);
 $string = str_replace(\n, 'br /', $string);

 -Stut


You forgot the Macintosh newlines, which is a single carriage return.

Try this code instead:
$string = str_replace(\r\n, 'br /', $string);
$string = str_replace(\n, 'br /', $string);
$string = str_replace(\r, 'br /', $string);

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Faither

Stut wrote:

Faither wrote:
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a \n-ewline.


I have a text string from a form and am trying to replace the \n or 
chr(10) or however you might call the newline with a simple html break 
tag.


If I use the replacing functions I get the br-tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array 
using:

 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
br-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the \n and chr(10).
This function ignored all newlines and gave me an array with one key 
and the entire text of the textarea as value Oh... and the 
newlines of course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^


First of all look at http://php.net/nl2br which does exactly what you're 
trying to do.


Second try this...

$string = str_replace(\r\n, 'br /', $string);
$string = str_replace(\n, 'br /', $string);

-Stut


Wee that helped a lot thanks for the fast reply!
And sorry for the spam... got time outs from my mail client so i send 
the e-mail again -.-'


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



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Daniel Brown
On 8/10/07, Faither [EMAIL PROTECTED] wrote:
 Hey there!
 I'm kind of lost with how str_replace , preg_replace, ereg_replace or
 even explode are handling a \n-ewline.

 I have a text string from a form and am trying to replace the \n or
 chr(10) or however you might call the newline with a simple html break tag.

 If I use the replacing functions I get the br-tags where there are
 newlines from the textarea of the form. BUT I still have the newlines
 remain.

 So I tried a different approach breaking the text down into an array using:
   explode(' ', $string)
 in conjunction with trim() and again made a string out of the array. -
 br-tags still there, newlines aswell -.-'

 Next thing I tried was exploding the string using the \n and chr(10).
 This function ignored all newlines and gave me an array with one key and
 the entire text of the textarea as value Oh... and the newlines of
 course were there aswell...

 So... How can I get rid of these?! - I just want them gone!

 Is it even possible under windows? ^^

 Thanks a lot in advance


 Stefan

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



If I'm not mistaken, Windows doesn't strictly use \n, but rather \r\n.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 18:14 +0200, Faither wrote:
 Hey there!
 I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
 even explode are handling a \n-ewline.
 
 I have a text string from a form and am trying to replace the \n or 
 chr(10) or however you might call the newline with a simple html break tag.
 
 If I use the replacing functions I get the br-tags where there are 
 newlines from the textarea of the form. BUT I still have the newlines 
 remain.

That extra newline is probably caused by a \r character as promoted by
the Windows operating system.

You could try the following:

?php

$string = str_replace( \n, 'br /', $string );
$string = str_replace( \r, '', $string );

?

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
 On Fri, 2007-08-10 at 17:39 +0100, Stut wrote:
  Robert Cummings wrote:
   On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
   On 8/10/07, Stut [EMAIL PROTECTED] wrote:
    I get an email from each
   server containing the contents of the error log from the previous day
   and my first task each day is to go through that and track down any
   issues that usage has highlighted.
   That's actually a good point there that I can take away from this.
I actually don't have anything set to send me a log of code issues,
   only when an error is caused (and, of course, anything server-related,
   but that's a different point entirely).
  
   Simple enough... put the following in a file, and add a cron job.
  
   #!/usr/bin/php -qC
   ?php
  
   if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
   {
   echo Usage: {$argv[0]} subject email path\n;
   exit( 1 );
   }
  
   $subject = $argv[1];
   $email   = $argv[2];
   $path= $argv[3];
  
   $content = implode( '', file( $path ) );
  
   if( trim( $content ) === '' )
   {
   $content = 'NO ERRORS TODAY!!!';
   }
  
   mail( $email, $subject, $content );
  
   ?
 
  I used to have something similar to this until someone uploaded a script
  that started writing to the error log like mad. Overnight my poor little
  script tried to load a 240meg log file into memory and email it to me. I
  now use a simple bash script that pipes the log to the mail command -
  much safer.
 
  Should probably say that it also renames the log file, graceful's
  Apache, zips the old log and moves it to an archive file server. Rob's
  script above, used without something that starts a new log will result
  in ever-increasing emails.

 Oh yeah, that's true-- totally forgot to wipe the error log. I just
 whipped the above up :) I have something else on the server without
 command line params that I wrote ages ago :) As for a huge file, unless
 you set PHPs memory high it should just bail with a fatal memory
 exhaustion error. A better script would gzip the log file and attach it
 to an email.

 Cheers,
 Rob.
 --
 ...
 SwarmBuy.com - http://www.swarmbuy.com

 Leveraging the buying power of the masses!
 ...


Wouldn't it even be a worthwhile idea to simply include the first
$n lines of the daily log in an email?  That's how I have my logs
emailed to me for the server things.  I receive the first 300 lines of
the file, and if there's more than that (which, for server logs, there
always are, because I monitor everything), then I know to either hop
on the server and `vim` the log or download it and read it.

In any case, rotating and archiving would be a requirement.
Depending on the log, mine generally rotate daily or once every three
days, with backups being maintained for at least 30 days.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Stut

Faither wrote:
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a \n-ewline.


I have a text string from a form and am trying to replace the \n or 
chr(10) or however you might call the newline with a simple html break tag.


If I use the replacing functions I get the br-tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array using:
 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
br-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the \n and chr(10).
This function ignored all newlines and gave me an array with one key and 
the entire text of the textarea as value Oh... and the newlines of 
course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^


First of all look at http://php.net/nl2br which does exactly what you're 
trying to do.


Second try this...

$string = str_replace(\r\n, 'br /', $string);
$string = str_replace(\n, 'br /', $string);

-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 17:39 +0100, Stut wrote:
 Robert Cummings wrote:
  On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
  On 8/10/07, Stut [EMAIL PROTECTED] wrote:
   I get an email from each
  server containing the contents of the error log from the previous day
  and my first task each day is to go through that and track down any
  issues that usage has highlighted.
  That's actually a good point there that I can take away from this.
   I actually don't have anything set to send me a log of code issues,
  only when an error is caused (and, of course, anything server-related,
  but that's a different point entirely).
  
  Simple enough... put the following in a file, and add a cron job.
  
  #!/usr/bin/php -qC
  ?php
  
  if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
  {
  echo Usage: {$argv[0]} subject email path\n;
  exit( 1 );
  }
  
  $subject = $argv[1];
  $email   = $argv[2];
  $path= $argv[3];
  
  $content = implode( '', file( $path ) );
  
  if( trim( $content ) === '' )
  {
  $content = 'NO ERRORS TODAY!!!';
  }
  
  mail( $email, $subject, $content );
  
  ?
 
 I used to have something similar to this until someone uploaded a script 
 that started writing to the error log like mad. Overnight my poor little 
 script tried to load a 240meg log file into memory and email it to me. I 
 now use a simple bash script that pipes the log to the mail command - 
 much safer.
 
 Should probably say that it also renames the log file, graceful's 
 Apache, zips the old log and moves it to an archive file server. Rob's 
 script above, used without something that starts a new log will result 
 in ever-increasing emails.

Oh yeah, that's true-- totally forgot to wipe the error log. I just
whipped the above up :) I have something else on the server without
command line params that I wrote ages ago :) As for a huge file, unless
you set PHPs memory high it should just bail with a fatal memory
exhaustion error. A better script would gzip the log file and attach it
to an email.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



[PHP] Getting a 'newline' out of a string

2007-08-10 Thread Faither

Hey there!
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a \n-ewline.


I have a text string from a form and am trying to replace the \n or 
chr(10) or however you might call the newline with a simple html break tag.


If I use the replacing functions I get the br-tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array using:
 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
br-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the \n and chr(10).
This function ignored all newlines and gave me an array with one key and 
the entire text of the textarea as value Oh... and the newlines of 
course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^

Thanks a lot in advance


Stefan

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



Re: [PHP] Running a server process

2007-08-10 Thread Stut

Tijnema wrote:

On 8/10/07, Stut [EMAIL PROTECTED] wrote:

Tijnema wrote:

On 8/10/07, Stut [EMAIL PROTECTED] wrote:

Tijnema wrote:

On 8/10/07, Richard Heyes [EMAIL PROTECTED] wrote:

That is it works with just me using the site.  I am wondering how this would
effect performance if say 500 people were executing this php function around
the same time and the processing overlapped.  Is there anyway to make an
executable run as a service, I am guessing at the terminology that I should
use here, but I feel there would be a much more efficient way of performing
this task.

Well, ideally you don't run an executable. But if you must, there's some
Windows program that turns an executable into a service. But then
there's the consideration of communicating with it, which you could do
with sockets. Or you could use a file.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

I don't know if there a program exists that can convert the program
to a service, I think you need to compile it as a service from source
code, but as I mentioned in my first post, and you mentioned here too,
you also need to add support for a socket server in your program.
Sockets in PHP are easy ;)

http://www.firedaemon.com/

But you're right, you'd need a way to communicate with the service.

-Stut

Well stut, this doesn't really run your program as a service.
The program itself is a server, and simply starts every program when
that service starts. That's not the same as running the program as a
service.

That's extremely pedantic. As a service simply means it responds to
messages from the OS such as start, pause and stop. Firedaemon wraps
your executable in a process that does just that. So technically you're
correct, it doesn't turn your executable into a service, it wraps it in
one, but the effect is essentially the same.

If you need the extra control you'll get over it by rewriting your
executable to actually be a service then you should do that. But if
you're working with something you don't have the source for, or don't
have the time to implement such a modification then Firedaemon is the
best option I've come across.

-Stut


Yes, but if you don't have the source, you can't add socket support,
and then you can do quite less with a program... Unless you already
have socket support in the program, but that seems quite odd to me ;)


 Sockets aren't the only IPC mechanism available. And besides, I was 
countering your general statement regarding Firedaemon, not the 
applicability of Firedaemon to the OP's problem, which we can't comment 
on without knowing a lot more information about it.


-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Tijnema
On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
 On Fri, 2007-08-10 at 19:21 +0200, Tijnema wrote:
  On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
   On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
  I get an email from each
 server containing the contents of the error log from the previous day
 and my first task each day is to go through that and track down any
 issues that usage has highlighted.
   
That's actually a good point there that I can take away from this.
 I actually don't have anything set to send me a log of code issues,
only when an error is caused (and, of course, anything server-related,
but that's a different point entirely).
  
   Simple enough... put the following in a file, and add a cron job.
  
   #!/usr/bin/php -qC
   ?php
  
   if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
 
  if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)

 Quite true.

   {
  echo Usage: {$argv[0]} subject email path\n;
  exit( 1 );
   }
  
   $subject = $argv[1];
   $email   = $argv[2];
   $path= $argv[3];
  
   $content = implode( '', file( $path ) );
 
  $content = file_get_contents($path); // Safe to require PHP 4 = 4.3.0 
  right?

 I always forget about file_get_contents() because its counterpart
 file_put_contents() for some ungodly reason didn't appear until PHP 5.

Forget PHP4 and life becomes a lot easier :)

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] Running a server process

2007-08-10 Thread Stut

Tijnema wrote:

On 8/10/07, Stut [EMAIL PROTECTED] wrote:

Tijnema wrote:

On 8/10/07, Richard Heyes [EMAIL PROTECTED] wrote:

That is it works with just me using the site.  I am wondering how this would
effect performance if say 500 people were executing this php function around
the same time and the processing overlapped.  Is there anyway to make an
executable run as a service, I am guessing at the terminology that I should
use here, but I feel there would be a much more efficient way of performing
this task.

Well, ideally you don't run an executable. But if you must, there's some
Windows program that turns an executable into a service. But then
there's the consideration of communicating with it, which you could do
with sockets. Or you could use a file.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

I don't know if there a program exists that can convert the program
to a service, I think you need to compile it as a service from source
code, but as I mentioned in my first post, and you mentioned here too,
you also need to add support for a socket server in your program.
Sockets in PHP are easy ;)

http://www.firedaemon.com/

But you're right, you'd need a way to communicate with the service.

-Stut


Well stut, this doesn't really run your program as a service.
The program itself is a server, and simply starts every program when
that service starts. That's not the same as running the program as a
service.


That's extremely pedantic. As a service simply means it responds to 
messages from the OS such as start, pause and stop. Firedaemon wraps 
your executable in a process that does just that. So technically you're 
correct, it doesn't turn your executable into a service, it wraps it in 
one, but the effect is essentially the same.


If you need the extra control you'll get over it by rewriting your 
executable to actually be a service then you should do that. But if 
you're working with something you don't have the source for, or don't 
have the time to implement such a modification then Firedaemon is the 
best option I've come across.


-Stut

--
http://stut.net/

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



Re: [PHP] Getting a 'newline' out of a string

2007-08-10 Thread Richard Davey
Hi Faither,

Friday, August 10, 2007, 5:16:09 PM, you wrote:

 I'm kind of lost with how str_replace , preg_replace, ereg_replace or
 even explode are handling a \n-ewline.

 I have a text string from a form and am trying to replace the \n or 
 chr(10) or however you might call the newline with a simple html break tag.

Why not just use nl2br() in this case?

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



[PHP] Getting a 'newline' out of a string

2007-08-10 Thread Faither

Hey there!
I'm kind of lost with how str_replace , preg_replace, ereg_replace or 
even explode are handling a \n-ewline.


I have a text string from a form and am trying to replace the \n or 
chr(10) or however you might call the newline with a simple html break tag.


If I use the replacing functions I get the br-tags where there are 
newlines from the textarea of the form. BUT I still have the newlines 
remain.


So I tried a different approach breaking the text down into an array using:
 explode(' ', $string)
in conjunction with trim() and again made a string out of the array. - 
br-tags still there, newlines aswell -.-'


Next thing I tried was exploding the string using the \n and chr(10).
This function ignored all newlines and gave me an array with one key and 
the entire text of the textarea as value Oh... and the newlines of 
course were there aswell...


So... How can I get rid of these?! - I just want them gone!

Is it even possible under windows? ^^

Thanks a lot in advance


Stefan

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



Re: [PHP] Recursion and threaded message boards...

2007-08-10 Thread Richard Davey
Hi Tony,

Friday, August 10, 2007, 5:23:28 PM, you wrote:

 I have to write some PHP backend code for a threaded message board.
 The db has a message table, and each message has a parent id.

 Does anyone have any advice for someone whos never done this in PHP?

 I'm currently thinking that I write function that takes a db row as
 an argument, and initially, it is passed the root node of the whole
 tree. It is also probably passed a string variable.

 The first thing it will do is append the code for itself to the string.

 Then it will query the DB for all its children (with an order by post
 timestamp), and for every child, it will call itself on that child row.

 Am I on the right track? (I've done simmilar things in C++, just not in
 PHP)...

To be honest this is less of a PHP issue (at this stage) and more of a
SQL one. What SQL package are you using? (MySQL? if so v4 or v5?). I
would strongly consider looking at using a nested set system for the
structure (or at least a derivative of it, there are many good ones
out there) in combination with a standard parent/child hierarchy.

You can wrap up nearly all of the complexity of this requirement (i.e.
the tree walking / retrieval) on a stored procedure level with some
decent table design.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
  I get an email from each
 server containing the contents of the error log from the previous day
 and my first task each day is to go through that and track down any
 issues that usage has highlighted.

That's actually a good point there that I can take away from this.
 I actually don't have anything set to send me a log of code issues,
only when an error is caused (and, of course, anything server-related,
but that's a different point entirely).

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re[2]: [PHP] Friday morning brain farts....

2007-08-10 Thread Richard Davey
Hi Stut,

Friday, August 10, 2007, 4:44:14 PM, you wrote:

 On my production servers error_reporting is set to E_ALL,
 display_errors is off and log_errors is on. I get an email from each
 server containing the contents of the error log from the previous
 day and my first task each day is to go through that and track down
 any issues that usage has highlighted.

Snap :)

We do exactly the same here. The PHP log is checked first thing every
morning for notices, fatal errors, etc. The notices are especially
useful to finding out where other devs have forgotten (or incorrectly
named) variables, etc - as a number of people work on the sites each
day.

I wrote a very simple script that parses the log file into a web page
and colour codes each element (red = fatal, green = notice, yellow =
warning). We can also inject developer notes into it (using
error_log() with some set keywords at the start) which appear in blue.

Here's a small grab from an internal development server log:

http://www.corephp.co.uk/images/php_error_log.jpg

Simple, but effective.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] string as file

2007-08-10 Thread Jim Lucas

Rick Pasotto wrote:

On Thu, Aug 09, 2007 at 02:39:51PM -0700, Jim Lucas wrote:

Rick Pasotto wrote:

Does php have a facility similar to python's stringIO?
What I'm wanting to do is similar to a mail merge. IOW, I know I can
create an include file like:
$out = EOT
This is an example of $var1 and $var2.
EOT;
and then after assigning values to $var1 and $var2 include that file. I
can later use different values for $var1 and $var2 and get a different
$out with a second include.
Can I someout include a string instead of a file? Or maybe there is
some completely different way to do what I want.

template.php
?php

ob_start();
echo Hi, my name is {$first_name} {$last_name}.;
return ob_get_clean();

?


This is two different ways you can do it, bases on your input data array 
structure


test.php


?php

$string = 'Hi, my name is |FIRST_NAME| |LAST_NAME|.';

$values = array();
$values[] = array('FIRST_NAME' = 'Jim', 'LAST_NAME' = 'Lucas');
$values[] = array('FIRST_NAME' = 'James',   'LAST_NAME' = 'Lucas');
$values[] = array('FIRST_NAME' = 'Jimmy',   'LAST_NAME' = 'Lucas');

foreach ( $values AS $row ) {

$in = array_keys($row);

foreach ( $in AS $k = $v )
$in[$k] = '|'.$v.'|';

echo str_replace($in, $row, $string);

}

?



You have misunderstood. You are still putting the template in an
external file. I want it in the main file. I don't want to maintain
two different files.






--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
 If PHP thinks something might be wrong it will tell you. Why on earth
 would you want to ignore it? You think you're smarter than PHP? Really?

Okay, Stut, let's not make Friday the official Flame Dan Brown
holiday this week.  I vote that it should be later in the year.

However, it should also be noted that my development is never done
on a production server attached to the Internet, for one; and on my
development machine, E_NOTICE is always enabled.  I just fail to see
the benefit in alerting visitors to the site that there may have been
something overlooked at some point.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:28 -0400, Daniel Brown wrote:
 On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
  I never disable E_NOTICE or even E_STRICT.
 
 I'm humbled in the presence of greatness.

Nothing great about it. It's work as usual. When you're developing the
code you see any notices immediately. It takes 10 seconds to fix them
since you're usually working at that specific location in the code
anyways.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
 I never disable E_NOTICE or even E_STRICT.

I'm humbled in the presence of greatness.

I do my best to ensure that there are no notices or warnings, but
I still disable E_NOTICE in general, because I know that it's not
going to end the world.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] string as file

2007-08-10 Thread Stut

Rick Pasotto wrote:

On Fri, Aug 10, 2007 at 02:19:29PM +0100, Stut wrote:

Rick Pasotto wrote:

On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote:

On 8/9/07, Rick Pasotto [EMAIL PROTECTED] wrote:

Does php have a facility similar to python's stringIO?

What I'm wanting to do is similar to a mail merge. IOW, I know I can
create an include file like:

$out = EOT
This is an example of $var1 and $var2.
EOT;

and then after assigning values to $var1 and $var2 include that
file. I can later use different values for $var1 and $var2 and get a
different $out with a second include.

eval()

Explain.
One word responses really don't do any good.
Exactly *what* would be the argument to eval()?

RTFM, that's what it's there for.


I did. That's why I rejected the use of eval() before I posted the
message. eval() is totally unsuitable for what I want. Unless, that is,
you or Greg can explain how using eval() will get me what I want.

I think that neither you nor Greg understands what I'm looking for.

Instead of simply stating 'RTFM' perhaps *you* should RTFQuestion.


Your original post asked...

Can I someout include a string instead of a file?

That's exactly what eval does. As for what you would pass to it... PHP 
code maybe? Have you even tried it? The manual page for eval has several 
examples of how to use it, and the comments have even more.



Incidentally, eval is evil and potentially a giant security hole.
You'd be better off doing replacements with preg_match rather than
executing a string.


Agreed. That's another reason I had already rejected it. Although in
this case, since I would have full control of all the variables, it
would probably be ok.


Use regular expressions or straight string replacements - that's the 
best way to implement mail-merge type behaviour. Personally I used 
preg_replace with the 'e' modifier. For an example see, shockingly, the 
manual page for preg_replace.


Now go stick your head in a pig.

-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 10:43 -0400, Jason Pruim wrote:
 Hi All :)
 
 Hope you're not getting sick of my questions as of late, but I keep  
 getting closer and closer and thank you all who have helped me in the  
 past! The only reason I can see this far is I am standing on the  
 shoulders of giants don't know who said that but I like it :)

http://en.wikipedia.org/wiki/Stand_on_the_shoulders_of_giants

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re[2]: [PHP] Friday morning brain farts....

2007-08-10 Thread Richard Davey
Hi Robert,

Friday, August 10, 2007, 4:13:02 PM, you wrote:

 On Fri, 2007-08-10 at 11:00 -0400, Daniel Brown wrote:

 Remember to clean that input before you sit down at the table, there, 
 boy!
 
 It's safe to ignore the `Undefined index` notices.  That will just
 appear if a variable is referenced without first being instantiated or
 defined.  No biggie, just put this at the head of your code:
 
 ini_set(error_reporting,E_ALL  ~E_NOTICE);

 I'm in the that's sloppy and poor style camp for the above setting.

I've got to agree. A clean E_ALL error log is a good error log.

It's not like it's hard to fix.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
 Bad Dan *slap*. Ignoring notices may be detrimental to your health
 and/or well-being. Better to initialise it with a default if it has not
 been set in the request.

 if (!isset($_GET['order'])) $_GET['order'] = 'Last';

Ouch!

So you're all going to tell me that you have E_NOTICE set to
report on your sites?  Look, I didn't say it was the Right Way[tm],
but it is safe to ignore.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
 On Fri, 2007-08-10 at 11:00 -0400, Daniel Brown wrote:
 
  Remember to clean that input before you sit down at the table, there, 
  boy!
 
  It's safe to ignore the `Undefined index` notices.  That will just
  appear if a variable is referenced without first being instantiated or
  defined.  No biggie, just put this at the head of your code:
 
  ini_set(error_reporting,E_ALL  ~E_NOTICE);

 I'm in the that's sloppy and poor style camp for the above setting.

 Cheers,
 Rob.
 --
 ...
 SwarmBuy.com - http://www.swarmbuy.com

 Leveraging the buying power of the masses!
 ...


You belong in a camp, alright ;-P

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] string as file

2007-08-10 Thread Rick Pasotto
On Fri, Aug 10, 2007 at 02:19:29PM +0100, Stut wrote:
 Rick Pasotto wrote:
 On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote:
 On 8/9/07, Rick Pasotto [EMAIL PROTECTED] wrote:
 Does php have a facility similar to python's stringIO?

 What I'm wanting to do is similar to a mail merge. IOW, I know I can
 create an include file like:

 $out = EOT
 This is an example of $var1 and $var2.
 EOT;

 and then after assigning values to $var1 and $var2 include that
 file. I can later use different values for $var1 and $var2 and get a
 different $out with a second include.
 eval()
 Explain.
 One word responses really don't do any good.
 Exactly *what* would be the argument to eval()?

 RTFM, that's what it's there for.

I did. That's why I rejected the use of eval() before I posted the
message. eval() is totally unsuitable for what I want. Unless, that is,
you or Greg can explain how using eval() will get me what I want.

I think that neither you nor Greg understands what I'm looking for.

Instead of simply stating 'RTFM' perhaps *you* should RTFQuestion.

 Incidentally, eval is evil and potentially a giant security hole.
 You'd be better off doing replacements with preg_match rather than
 executing a string.

Agreed. That's another reason I had already rejected it. Although in
this case, since I would have full control of all the variables, it
would probably be ok.

-- 
Whatever crushes individuality is despotism, by whatever name it may be
 called. -- John Stuart Mill, 1859
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:00 -0400, Daniel Brown wrote:

 Remember to clean that input before you sit down at the table, there, boy!
 
 It's safe to ignore the `Undefined index` notices.  That will just
 appear if a variable is referenced without first being instantiated or
 defined.  No biggie, just put this at the head of your code:
 
 ini_set(error_reporting,E_ALL  ~E_NOTICE);

I'm in the that's sloppy and poor style camp for the above setting.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Jason Pruim [EMAIL PROTECTED] wrote:
 Hi All :)

 Hope you're not getting sick of my questions as of late, but I keep
 getting closer and closer and thank you all who have helped me in the
 past! The only reason I can see this far is I am standing on the
 shoulders of giants don't know who said that but I like it :)

 Anyway... Onto the question...

 I think I'm just going crazy as it's been a busy week for me, but I
 can't figure out how to do this. What I am attempting to do is, I
 have a webpage(Don't we all?) that calls info to be displayed from a
 database,

 I want to be able to sort that info so my sql query looks like:
 Select * from current order by '$order'; and $order is populated by
 a GET when they click on a link: A href=index.php?order='Last'Sort
 by last name/A  Now... the whole PHP page is being included in
 a .shtml page to actually display it and make it look purrdee :)

 How do I get it to resort the info and include the new sort on the page?

 I'm not sure if this has anything to do with it but:

 $order = $_GET['order']; --Line 6

 [Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:
 order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php
 on line 6

 Any help will be greatly appreciated.. And if it solves the problem
 I'll name some of my kids* after you!



 *Subject to approval of the Wife :)

 --

 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 3251 132nd ave
 Holland, MI, 49424
 www.raoset.com
 [EMAIL PROTECTED]




Remember to clean that input before you sit down at the table, there, boy!

It's safe to ignore the `Undefined index` notices.  That will just
appear if a variable is referenced without first being instantiated or
defined.  No biggie, just put this at the head of your code:

ini_set(error_reporting,E_ALL  ~E_NOTICE);

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Paul Novitski

At 8/10/2007 07:43 AM, Jason Pruim wrote:

I want to be able to sort that info so my sql query looks like:
Select * from current order by '$order'; and $order is populated by
a GET when they click on a link: A href=index.php?order='Last'Sort
by last name/A  Now... the whole PHP page is being included in
a .shtml page to actually display it and make it look purrdee :)

...

$order = $_GET['order']; --Line 6



Your HTML should read:

a href=index.php?order=LastSort by last name/a

Note double-quotes around the href expression and no quotes around 
the querystring parameter value.


Also, you'll want to check the incoming values to prevent SQL 
injection (q.v.).  If you insert unevaluated input into an SQL query 
you're leaving yourself vulnerable to everything from data exposure 
to data manipulation from outside sources.


Regards,

Paul
__

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com 



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



[PHP] Friday morning brain farts....

2007-08-10 Thread Jason Pruim

Hi All :)

Hope you're not getting sick of my questions as of late, but I keep  
getting closer and closer and thank you all who have helped me in the  
past! The only reason I can see this far is I am standing on the  
shoulders of giants don't know who said that but I like it :)


Anyway... Onto the question...

I think I'm just going crazy as it's been a busy week for me, but I  
can't figure out how to do this. What I am attempting to do is, I  
have a webpage(Don't we all?) that calls info to be displayed from a  
database,


I want to be able to sort that info so my sql query looks like:  
Select * from current order by '$order'; and $order is populated by  
a GET when they click on a link: A href=index.php?order='Last'Sort  
by last name/A  Now... the whole PHP page is being included in  
a .shtml page to actually display it and make it look purrdee :)


How do I get it to resort the info and include the new sort on the page?

I'm not sure if this has anything to do with it but:

$order = $_GET['order']; --Line 6

[Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:   
order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php  
on line 6


Any help will be greatly appreciated.. And if it solves the problem  
I'll name some of my kids* after you!




*Subject to approval of the Wife :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP] function - action

2007-08-10 Thread Martin Alterisio
2007/8/7, Richard Lynch [EMAIL PROTECTED]:

 On Fri, August 3, 2007 1:38 am, Ralph Kutschera wrote:
I'm working on a project, where we distinguish between functions
  and
  actions in design, although in PHP both are implemented as
  functions.
  Is there a chance that PHP can use the word action as function?
 
  E.g.:
  public function doSomething() {  }
  public action doSomethingElse() { ... }
 
  ... is actually the same but would help to see the design also in the
  code.

 You might be able to do this with the Run-Kit extension...


I was unaware that run-kit was able to do this kind of things, could you
explain a little more about how would this extension could handle code with
alien keywords.

It might be easier, however, to hack some kind of pre-processor that
 would search for PCRE '\\s*action\\s*' and replace it with ' function
 '

 You'd have to pre-process generate your actual PHP files that get
 executed, but the source you use would just have the 'action' in it.


Actually is not that simple. There are some considerations that should be
taken into account, such as the loss of error information (file and line
number where the error occurs) and exception information (stack trace does
not point to the right place), and parsing correctly the code as to replace
the action keyword where it actually applies. I made some experimentation
with preprocessing php code with added keywords, that might help you if you
wish to use such a solution:
http://www.phpclasses.org/browse/package/4001.html


Re: [PHP] Running a server process

2007-08-10 Thread Tijnema
On 8/10/07, Richard Heyes [EMAIL PROTECTED] wrote:
  That is it works with just me using the site.  I am wondering how this would
  effect performance if say 500 people were executing this php function around
  the same time and the processing overlapped.  Is there anyway to make an
  executable run as a service, I am guessing at the terminology that I should
  use here, but I feel there would be a much more efficient way of performing
  this task.

 Well, ideally you don't run an executable. But if you must, there's some
 Windows program that turns an executable into a service. But then
 there's the consideration of communicating with it, which you could do
 with sockets. Or you could use a file.

 --
 Richard Heyes
 +44 (0)844 801 1072
 http://www.websupportsolutions.co.uk

I don't know if there a program exists that can convert the program
to a service, I think you need to compile it as a service from source
code, but as I mentioned in my first post, and you mentioned here too,
you also need to add support for a socket server in your program.
Sockets in PHP are easy ;)

Tijnema


-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] Running a server process

2007-08-10 Thread Tijnema
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
 Tijnema wrote:
  On 8/10/07, Richard Heyes [EMAIL PROTECTED] wrote:
  That is it works with just me using the site.  I am wondering how this 
  would
  effect performance if say 500 people were executing this php function 
  around
  the same time and the processing overlapped.  Is there anyway to make an
  executable run as a service, I am guessing at the terminology that I 
  should
  use here, but I feel there would be a much more efficient way of 
  performing
  this task.
  Well, ideally you don't run an executable. But if you must, there's some
  Windows program that turns an executable into a service. But then
  there's the consideration of communicating with it, which you could do
  with sockets. Or you could use a file.
 
  --
  Richard Heyes
  +44 (0)844 801 1072
  http://www.websupportsolutions.co.uk
 
  I don't know if there a program exists that can convert the program
  to a service, I think you need to compile it as a service from source
  code, but as I mentioned in my first post, and you mentioned here too,
  you also need to add support for a socket server in your program.
  Sockets in PHP are easy ;)

 http://www.firedaemon.com/

 But you're right, you'd need a way to communicate with the service.

 -Stut

Well stut, this doesn't really run your program as a service.
The program itself is a server, and simply starts every program when
that service starts. That's not the same as running the program as a
service.

Tijnema

-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] manual vs. meta refresh

2007-08-10 Thread Tijnema
On 8/10/07, Kevin Murphy [EMAIL PROTECTED] wrote:
 I doubt this, but is there any way to determine via PHP if a browser
 was refreshed automatically via a META tag vs the person clicking the
 refresh button?

 --
 Kevin Murphy

Normally not, unless you add an extra GET item to the META tag, for example:
meta http-equiv=refresh
content=1;http://www.domain.com/dir/site.php?foo=barmeta_refresh=yes;

But this would only work once, as you get redirected to there.
You can add a counter if you want, and keep track of the number of
times it has been redirected to META, in comparison to the one before.

meta http-equiv=refresh
content=1;http://www.domain.com/dir/site.php?foo=barmeta_refresh=1;
and when the new page load, check whether the value is the same as the
previous page load (user has uses refresh), or it is +1 (redirected
through META)

Tijnema

-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] manual vs. meta refresh

2007-08-10 Thread Richard Davey
Hi Kevin,

Friday, August 10, 2007, 7:26:30 PM, you wrote:

 I doubt this, but is there any way to determine via PHP if a browser  
 was refreshed automatically via a META tag vs the person clicking the
 refresh button?

You could dynamically generate the meta tag, so it refreshes to your
page with some extra parameter that wouldn't exist if someone just hit
F5. It's not foolproof (as the meta tag can of course be seen in plain
text), but it should give you a high success rate.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] php 4.4.7 make install with pear causes zend freeing errors

2007-08-10 Thread Tijnema
On 8/10/07, John Mendenhall [EMAIL PROTECTED] wrote:
 I sent this to the php-install list.  However, with
 no response, I knew there would be more eyes looking
 at it here.  Hopefully, someone can send me a pointer
 on how to resolve this issue.  It might be the root of
 other problems I am having.

 Per my previous message, I have recently upgraded from
 php 4.4.0, to php 4.4.7.  My configure options are as
 follows:

snip

 I would like to know what I am doing wrong here.
 When I turn off pear, this does not happen.
 When I try to upgrade or install pear packages,
 I get the same types of errors.

 Thanks in advance for any pointers you can
 provide.

 Thanks!

 JohnM

 --

What are you doing with PHP4???

Go PHP5!!

http://www.gophp5.org

Tijnema


-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] Running a server process

2007-08-10 Thread Tijnema
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
 Tijnema wrote:
  On 8/10/07, Stut [EMAIL PROTECTED] wrote:
  Tijnema wrote:
  On 8/10/07, Richard Heyes [EMAIL PROTECTED] wrote:
  That is it works with just me using the site.  I am wondering how this 
  would
  effect performance if say 500 people were executing this php function 
  around
  the same time and the processing overlapped.  Is there anyway to make an
  executable run as a service, I am guessing at the terminology that I 
  should
  use here, but I feel there would be a much more efficient way of 
  performing
  this task.
  Well, ideally you don't run an executable. But if you must, there's some
  Windows program that turns an executable into a service. But then
  there's the consideration of communicating with it, which you could do
  with sockets. Or you could use a file.
 
  --
  Richard Heyes
  +44 (0)844 801 1072
  http://www.websupportsolutions.co.uk
  I don't know if there a program exists that can convert the program
  to a service, I think you need to compile it as a service from source
  code, but as I mentioned in my first post, and you mentioned here too,
  you also need to add support for a socket server in your program.
  Sockets in PHP are easy ;)
  http://www.firedaemon.com/
 
  But you're right, you'd need a way to communicate with the service.
 
  -Stut
 
  Well stut, this doesn't really run your program as a service.
  The program itself is a server, and simply starts every program when
  that service starts. That's not the same as running the program as a
  service.

 That's extremely pedantic. As a service simply means it responds to
 messages from the OS such as start, pause and stop. Firedaemon wraps
 your executable in a process that does just that. So technically you're
 correct, it doesn't turn your executable into a service, it wraps it in
 one, but the effect is essentially the same.

 If you need the extra control you'll get over it by rewriting your
 executable to actually be a service then you should do that. But if
 you're working with something you don't have the source for, or don't
 have the time to implement such a modification then Firedaemon is the
 best option I've come across.

 -Stut

Yes, but if you don't have the source, you can't add socket support,
and then you can do quite less with a program... Unless you already
have socket support in the program, but that seems quite odd to me ;)

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Michael Preslar
Here's what I use to watch my apache logs.. Looks for php errors,
notices, and warnings, seg faults, etc.. Grabs the stats for the prior
hour and spits them to stdout.. Pipe that to mutt or sendmail and
youve got an hourly cron.. Check the command line options for other
good stuff.. Only catch: This is written in perl..

http://www.michaelpreslar.com/hour_errorlog.pl.txt

 Should probably say that it also renames the log file, graceful's
 Apache, zips the old log and moves it to an archive file server. Rob's
 script above, used without something that starts a new log will result
 in ever-increasing emails.

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



Re: [PHP] Recursion and threaded message boards...

2007-08-10 Thread Stephen
--- Tony Di Croce [EMAIL PROTECTED] wrote:

 I have to write some PHP backend code for a threaded
 message board. The db
 has a message table, and each message has a parent
 id.
 
 Does anyone have any advice for someone whos never
 done this in PHP?

You are reinventing the wheel here. Why?

There are a number of open source PHP message board
scripts. Check those out, even if just to learn as
examples.

Stephen

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:18 -0400, Daniel Brown wrote:
 On 8/10/07, Stut [EMAIL PROTECTED] wrote:
  Bad Dan *slap*. Ignoring notices may be detrimental to your health
  and/or well-being. Better to initialise it with a default if it has not
  been set in the request.
 
  if (!isset($_GET['order'])) $_GET['order'] = 'Last';
 
 Ouch!
 
 So you're all going to tell me that you have E_NOTICE set to
 report on your sites?  Look, I didn't say it was the Right Way[tm],
 but it is safe to ignore.

I never disable E_NOTICE or even E_STRICT.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] manual vs. meta refresh

2007-08-10 Thread Tijnema
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
 Kevin Murphy wrote:
  I doubt this, but is there any way to determine via PHP if a browser was
  refreshed automatically via a META tag vs the person clicking the
  refresh button?

 Add a GET variable to the URL you put in the meta tag to tell you it
 came from the meta tag.


 -Stut

 You could dynamically generate the meta tag, so it refreshes to your
 page with some extra parameter that wouldn't exist if someone just hit
 F5. It's not foolproof (as the meta tag can of course be seen in plain
 text), but it should give you a high success rate.

 Cheers,

 Rich

Hello stut and rich again,

I see you provided both the same solution as me, but did you guys
think of the fact that it only works once?

One they guy is redirected once through the meta tag, it is on the page with url
?from_meta=yes, or something smiliar, now when the user presses F5, it
will stil think the user is redirected through the META tag...

Tijnema


-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 19:49 +0200, Tijnema wrote:
 On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
 
  I always forget about file_get_contents() because its counterpart
  file_put_contents() for some ungodly reason didn't appear until PHP 5.
 
 Forget PHP4 and life becomes a lot easier :)

Tell that to some of my clients that have large codebases in PHP4 and
don't want to spend to have it updated to PHP5 when it works perfectly
fine as it is. I don't blame them either.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



[PHP] multiple data to insert to database

2007-08-10 Thread Alain Roger
Hi,

I would like to know what is the best way and fastest to insert into
PostgreSQL around 25.000 records (extracted from CSV file).
Should i use the standard pg_exec($dbconn, insert into...); for each
record ?

thanks a lot,

-- 
Alain

Windows XP SP2
PostgreSQL 8.1.4
Apache 2.2.4
PHP 5.2.1


[PHP] manual vs. meta refresh

2007-08-10 Thread Kevin Murphy
I doubt this, but is there any way to determine via PHP if a browser  
was refreshed automatically via a META tag vs the person clicking the  
refresh button?


--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada College
www.wnc.edu
775-445-3326

P.S. Please note that my e-mail and website address have changed from  
wncc.edu to wnc.edu.





Re: [PHP] function - action

2007-08-10 Thread Martin Alterisio
2007/8/3, Ken Tozier [EMAIL PROTECTED]:


 On Aug 3, 2007, at 9:39 AM, Ken Tozier wrote:

 
  On Aug 3, 2007, at 2:38 AM, Ralph Kutschera wrote:
 
  Hallo!
 
I'm working on a project, where we distinguish between
  functions and
  actions in design, although in PHP both are implemented as
  functions.
  Is there a chance that PHP can use the word action as function?
 
  E.g.:
  public function doSomething() {  }
  public action doSomethingElse() { ... }
 
  ... is actually the same but would help to see the design also in
  the code.
 
  You could define a generic action function
 
  function action($funcName, $funcArgs)
  {
return $funcName($funcArgs);
  }

 Actually, this might be better as it makes no assumptions about the
 function's argument list.

 function action()
 {
 $func   = func_get_arg(0);
 $expr   = func_get_args();
 $expr   = array_slice($expr, 1);
 $expr   = implode(', ', $expr);
 $expr   = $func.'('.$expr.');';

 return eval($expr);
 }


Actually this function won't work as expected. The arguments are improperly
passed, they are not escaped and would only work with variables that hold
numeric values, one word strings that do no match to existing constants
(which will still trigger a notice in the error log). Also return values
will not be passed through, because a return statement was not included in
the eval'ed code.

eval is not the best solution for this:

function action() {
$func = func_get_arg(0);
$args = func_get_args();
$args = array_slice($args, 1);
return call_user_func_array($func, $args);
}


You lose the ability to pass by reference but that might not be
 important for your script.


That's not entirely true, objects are always references. You lose the
ability to pass any other type of value by reference.


Re: [PHP] Running a server process

2007-08-10 Thread Tijnema
On 8/10/07, Stut [EMAIL PROTECTED] wrote:
 Tijnema wrote:
  On 8/10/07, Stut [EMAIL PROTECTED] wrote:
  Tijnema wrote:
  On 8/10/07, Stut [EMAIL PROTECTED] wrote:
  Tijnema wrote:
  On 8/10/07, Richard Heyes [EMAIL PROTECTED] wrote:
  That is it works with just me using the site.  I am wondering how 
  this would
  effect performance if say 500 people were executing this php function 
  around
  the same time and the processing overlapped.  Is there anyway to make 
  an
  executable run as a service, I am guessing at the terminology that I 
  should
  use here, but I feel there would be a much more efficient way of 
  performing
  this task.
  Well, ideally you don't run an executable. But if you must, there's 
  some
  Windows program that turns an executable into a service. But then
  there's the consideration of communicating with it, which you could do
  with sockets. Or you could use a file.
 
  --
  Richard Heyes
  +44 (0)844 801 1072
  http://www.websupportsolutions.co.uk
  I don't know if there a program exists that can convert the program
  to a service, I think you need to compile it as a service from source
  code, but as I mentioned in my first post, and you mentioned here too,
  you also need to add support for a socket server in your program.
  Sockets in PHP are easy ;)
  http://www.firedaemon.com/
 
  But you're right, you'd need a way to communicate with the service.
 
  -Stut
  Well stut, this doesn't really run your program as a service.
  The program itself is a server, and simply starts every program when
  that service starts. That's not the same as running the program as a
  service.
  That's extremely pedantic. As a service simply means it responds to
  messages from the OS such as start, pause and stop. Firedaemon wraps
  your executable in a process that does just that. So technically you're
  correct, it doesn't turn your executable into a service, it wraps it in
  one, but the effect is essentially the same.
 
  If you need the extra control you'll get over it by rewriting your
  executable to actually be a service then you should do that. But if
  you're working with something you don't have the source for, or don't
  have the time to implement such a modification then Firedaemon is the
  best option I've come across.
 
  -Stut
 
  Yes, but if you don't have the source, you can't add socket support,
  and then you can do quite less with a program... Unless you already
  have socket support in the program, but that seems quite odd to me ;)

  Sockets aren't the only IPC mechanism available. And besides, I was
 countering your general statement regarding Firedaemon, not the
 applicability of Firedaemon to the OP's problem, which we can't comment
 on without knowing a lot more information about it.

 -Stut

Sockets is the best IPC available for all platforms, Pipes etc. only
work on POSIX systems, not on default windows installation, as you
would need the Microsoft Windows Services For Unix package installed.

You could use things like files or databases too, but sockets would
mostly be easier as you can simple send a START command to emulate the
start of a program, and have a stream open for returning data.

I see I misreaded a little bit of your reply.

Tijnema

-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



[PHP] php 4.4.7 make install with pear causes zend freeing errors

2007-08-10 Thread John Mendenhall
I sent this to the php-install list.  However, with
no response, I knew there would be more eyes looking
at it here.  Hopefully, someone can send me a pointer
on how to resolve this issue.  It might be the root of
other problems I am having.

Per my previous message, I have recently upgraded from
php 4.4.0, to php 4.4.7.  My configure options are as
follows:

-
./configure \
 --prefix=/usr/local/php4 \
 --with-apxs=/usr/sbin/apxs \
 --enable-debug \
 --disable-cgi \
 --enable-force-cgi-redirect \
 --enable-discard-path \
 --enable-safe-mode \
 --disable-short-tags \
 --disable-ipv6 \
 --enable-magic-quotes \
 --with-openssl \
 --with-pcre-regex \
 --with-curl \
 --with-curlwrappers \
 --with-mcrypt \
 --enable-session \
 --with-mysql=/usr/local \
 --with-mysql-sock=/var/www/var/run/mysql/mysql.sock
-

After running configure and make, I run make install.
This is the output of the make install:

-
calvin:php-4.4.7 {156} sudo make install
Installing PHP SAPI module:   apache
[activating module `php4' in /var/www/conf/httpd.conf]
cp libs/libphp4.so /usr/lib/apache/modules/libphp4.so
chmod 755 /usr/lib/apache/modules/libphp4.so
cp /var/www/conf/httpd.conf /var/www/conf/httpd.conf.bak
cp /var/www/conf/httpd.conf.new /var/www/conf/httpd.conf
rm /var/www/conf/httpd.conf.new
Installing PHP CLI binary:/usr/local/php4/bin/
Installing PHP CLI man page:  /usr/local/php4/man/man1/
Installing PEAR environment:  /usr/local/php4/lib/php/
[PEAR] Archive_Tar- already installed: 1.3.2
[PEAR] Console_Getopt - already installed: 1.2.3
[PEAR] HTML_Template_IT- already installed: 1.2.1
[PEAR] Net_UserAgent_Detect- already installed: 2.3.0
[PEAR] PEAR   - already installed: 1.6.1
Wrote PEAR system config file at: /usr/local/php4/etc/pear.conf
You may want to add: /usr/local/php4/lib/php to your php.ini include_path
[PEAR] Structures_Graph- already installed: 1.0.2
/usr/local/src/php.net/php-4.4.7/Zend/zend_hash.c(458) :  Freeing 0x3CB27624 
(128 bytes), script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 89 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(795) :  Freeing 0x3CBB9EA4 
(44 bytes), script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
/usr/local/src/php.net/php-4.4.7/Zend/zend_variables.c(123) : Actual location 
(location was relayed)
Last leak repeated 30 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_hash.c(280) :  Freeing 0x3CBB9724 
(43 bytes), script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 4173 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_hash.c(204) :  Freeing 0x3CBB96A4 
(32 bytes), script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 1504 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(2392) :  Freeing 
0x3CBB94A4 (44 bytes), 
script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
/usr/local/src/php.net/php-4.4.7/Zend/zend_variables.c(123) : Actual location 
(location was relayed)
Last leak repeated 27 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(1818) :  Freeing 
0x3CB26D24 (12 bytes), 
script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 18 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(2126) :  Freeing 
0x3CB26CE4 (12 bytes), 
script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 568 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(2129) :  Freeing 
0x3CBB9124 (45 bytes), 
script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
/usr/local/src/php.net/php-4.4.7/Zend/zend_variables.c(111) : Actual location 
(location was relayed)
Last leak repeated 568 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(512) :  Freeing 0x3CB266A4 
(12 bytes), script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 525 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(2106) :  Freeing 
0x3CBB8A24 (44 bytes), 
script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
/usr/local/src/php.net/php-4.4.7/Zend/zend_API.c(563) : Actual location 
(location was relayed)
Last leak repeated 512 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_API.c(595) :  Freeing 0x3CBB8424 (44 
bytes), script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
/usr/local/src/php.net/php-4.4.7/Zend/zend_API.c(583) : Actual location 
(location was relayed)
Last leak repeated 35 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_hash.c(424) :  Freeing 0x3CBB51A4 
(35 bytes), script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 1202 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(1950) :  Freeing 
0x3CB262E4 (12 bytes), 
script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 29 times
/usr/local/src/php.net/php-4.4.7/Zend/zend_execute.c(1676) :  Freeing 
0x3CB02DE4 (12 bytes), 
script=/usr/local/src/php.net/php-4.4.7/pear/install-pear.php
Last leak repeated 42 times

Re: [PHP] Running a server process

2007-08-10 Thread Daniel Brown
On 8/10/07, Richard Heyes [EMAIL PROTECTED] wrote:
  That is it works with just me using the site.  I am wondering how this would
  effect performance if say 500 people were executing this php function around
  the same time and the processing overlapped.  Is there anyway to make an
  executable run as a service, I am guessing at the terminology that I should
  use here, but I feel there would be a much more efficient way of performing
  this task.

 Well, ideally you don't run an executable. But if you must, there's some
 Windows program that turns an executable into a service. But then
 there's the consideration of communicating with it, which you could do
 with sockets. Or you could use a file.

 --
 Richard Heyes
 +44 (0)844 801 1072
 http://www.websupportsolutions.co.uk

 Knowledge Base and HelpDesk software
 that can cut the cost of online support

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



Nathan,

It should also be noted that, if your question was also whether or
not two perfectly-simultaneous executions by two separate clients is
an issue, the answer is no.  Even if you had all 500 clients hitting
the exec() point at the exact same moment, PID tracking wouldn't be an
issue for even a semi-modern machine.  Resource usage probably would
be, and there would be the issue of PID limitation if you're hitting
the magic number (65535), but for the system to accurately track which
data goes to which client and who owns what process.

I'm not sure if that's even part of the point you were
questioning, but I read it as such.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] multiple data to insert to database

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 15:36 +0200, Alain Roger wrote:
 Hi,
 
 I would like to know what is the best way and fastest to insert into
 PostgreSQL around 25.000 records (extracted from CSV file).
 Should i use the standard pg_exec($dbconn, insert into...); for each
 record ?
 
 thanks a lot,

Let's say you have a table with an id and a value field. Where id is the
key. You should be able to stack inserts like follows:

INSERT INTO foo ( id, value ) VALUES ( 1, 'One' ), ( 2, 'Two' ), ( 3,
'threee' );

So with that in mind, you should cluster your inserts into groups of X
inserts. I few hundred should make things a little quicker for you.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Hosting cost

2007-08-10 Thread Daniel Brown
On 8/10/07, Richard Davey [EMAIL PROTECTED] wrote:
 Hi Richard,

 Friday, August 10, 2007, 11:10:21 AM, you wrote:

  This is off topic so feel free to reply off list.

  My question is how much is it reasonable to charge for the following:

  1. Building a very small website (you can see it here:
  http://www.cleardebtadvice.co.uk)
  2. Hosting it for two years
  3. Providing email accounts as need be
  4. Probably a days worth of update work

 Would you be re-designing the site? (God I hope so)

 It's not exactly complex, but I don't know how quickly you can design,
 even so I'd be looking at £200 - £250 per day spent on that.

 Hosting would be barely anything for such a small site, do you already
 have a host you use? If so take their prices, add your mark-up (x2)
 and voila.

 I'd hope the hosting would include email by default. I'd never charge
 extra for this (unless the email requirements were well out of the
 ordinary)

 A days worth of update work.. see above.

 Cheers,

 Rich
 --
 Zend Certified Engineer
 http://www.corephp.co.uk

 Never trust a computer you can't throw out of a window

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



Rich (Davey) is probably about right.  At most, the site you
linked to is probably four pages --- index, service information, form
thanks, and the optional form error.  Figure approximately two hours
for each simple page to account for adjustments to font and such, two
hours for designing the header and footer, and another two hours for
adjusting the finished product as directed by your client.  If you
already have a form-to-mail script ready, you may not even want to add
the development cost for that into the final product, but that's
completely up to you.  Multiply the final number by your standard
hourly rate and shave or inflate the number as you see fit and fair.

With hosting, if the client wants to be completely hands-off,
remember to include about an hour to set up the site, transfer the
domain, and set up the email accounts.  And as far as pricing the
two-year hosting option, I agree with Davey again: by charging double
for what it would cost you to host the site, and for such a small
site, you're making extra money off the deal, while still being fair
to your client.  However, I'd be sure to get the money paid up-front
for the hosting, rather than try to set up automatic billing from your
account with the expectation of being paid by the client each month.

And another point on hosting --- that signature line in my email
isn't just to fill space and piss off people who may be receiving the
list on their Blackberry.  If you don't have a host and you host with
me, you'll get 50% off using the coupon in my signature.  So doubling
it will actually be the advertised price on the site.

How's that for a shameless plug?  ;-P

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] string as file

2007-08-10 Thread Rick Pasotto
On Thu, Aug 09, 2007 at 02:39:51PM -0700, Jim Lucas wrote:
 Rick Pasotto wrote:
 Does php have a facility similar to python's stringIO?
 What I'm wanting to do is similar to a mail merge. IOW, I know I can
 create an include file like:
 $out = EOT
 This is an example of $var1 and $var2.
 EOT;
 and then after assigning values to $var1 and $var2 include that file. I
 can later use different values for $var1 and $var2 and get a different
 $out with a second include.
 Can I someout include a string instead of a file? Or maybe there is
 some completely different way to do what I want.
 template.php
 ?php

 ob_start();
 echo Hi, my name is {$first_name} {$last_name}.;
 return ob_get_clean();

 ?


 This is two different ways you can do it, bases on your input data array 
 structure

 test.php
 ?php

 $values = array();

 $values[] = array('first_name' = 'Jim','last_name' = 'Lucas');
 $values[] = array('first_name' = 'James','last_name' = 'Lucas');
 $values[] = array('first_name' = 'Jimmy','last_name' = 'Lucas');

 foreach ($values AS $row) {
   extract($row);
   echo include 'template.php';
 }

 $values = array();

 $values[] = array('Jim','Lucas');
 $values[] = array('James','Lucas');
 $values[] = array('Jimmy','Lucas');

 list($first_name, $last_name) = current($values);
 do {
   echo include 'template.php';
 } while (list($first_name, $last_name) = next($values));
 ?

You have misunderstood. You are still putting the template in an
external file. I want it in the main file. I don't want to maintain
two different files.

-- 
It is always from a minority acting in ways different from what the
 majority would prescribe that the majority in the end learns to do
 better. -- Friedrich Hayek
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

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



Re: [PHP] string as file

2007-08-10 Thread Rick Pasotto
On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote:
 On 8/9/07, Rick Pasotto [EMAIL PROTECTED] wrote:
  Does php have a facility similar to python's stringIO?
 
  What I'm wanting to do is similar to a mail merge. IOW, I know I can
  create an include file like:
 
  $out = EOT
  This is an example of $var1 and $var2.
  EOT;
 
  and then after assigning values to $var1 and $var2 include that
  file. I can later use different values for $var1 and $var2 and get a
  different $out with a second include.
 
 eval()

Explain.

One word responses really don't do any good.

Exactly *what* would be the argument to eval()?

-- 
In vices, the very essence of crime -- that is, the design to injure the
 person or property of another -- is wanting. It is a maxim of law that
 there can be no crime without a criminal intent. -- Lysander Spooner
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net

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



Re: [PHP] Import XLS file with UTF-8

2007-08-10 Thread Zoltán Németh
2007. 08. 10, péntek keltezéssel 15.04-kor Alain Roger ezt írta:
 Hi,
 
 So now i know how to import the content of the CSV file to database,
 however, before to import to database i do a simple test.
 in fact, i display in my browser all content of my CSV file.
 
 unfortunately, not all characters are displayed correctly.
 in PHP page include meta http-equiv=Content-Type content=text/html;
 charset=UTF-8 but it does not help to display the Slovak Characters which
 are correctly display in EXCEL when i open the CSV file with it.
 i tried to display a standar slovak web page in my browser and it works
 perfectly well.
 
 So where could be the problem ?
 thanks a lot,

you should send a content-type header:

header(Content-Type: text/html; charset=utf-8);

hope that helps
Zoltán Németh

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



Re: [PHP] Import XLS file with UTF-8

2007-08-10 Thread Alain Roger
i change the UTF-8 by windows-1250 and it works well.

But what will happen if after i use UTF-8 in the rest of this PHP page ?
everytime  some characters will not be correctly displayed...

moreover my database is in UTF-8.

So i must expect some issue during copy data from CSv to database, no ?

Al.

On 8/10/07, Stut [EMAIL PROTECTED] wrote:

 Alain Roger wrote:
  Hi,
 
  So now i know how to import the content of the CSV file to database,
  however, before to import to database i do a simple test.
  in fact, i display in my browser all content of my CSV file.
 
  unfortunately, not all characters are displayed correctly.
  in PHP page include meta http-equiv=Content-Type content=text/html;
  charset=UTF-8 but it does not help to display the Slovak Characters
 which
  are correctly display in EXCEL when i open the CSV file with it.
  i tried to display a standar slovak web page in my browser and it works
  perfectly well.
 
  So where could be the problem ?

 The Content-Type needs to match the file type, so if the file is not
 UTF-8 extended characters will not be displayed correctly when it's
 displayed as UTF-8.

 Try removing that meta tag and see what the browser makes of the file by
 guessing.

 -Stut

 --
 http://stut.net/




-- 
Alain

Windows XP SP2
PostgreSQL 8.1.4
Apache 2.2.4
PHP 5.2.1


[PHP] Import XLS file with UTF-8

2007-08-10 Thread Alain Roger
Hi,

So now i know how to import the content of the CSV file to database,
however, before to import to database i do a simple test.
in fact, i display in my browser all content of my CSV file.

unfortunately, not all characters are displayed correctly.
in PHP page include meta http-equiv=Content-Type content=text/html;
charset=UTF-8 but it does not help to display the Slovak Characters which
are correctly display in EXCEL when i open the CSV file with it.
i tried to display a standar slovak web page in my browser and it works
perfectly well.

So where could be the problem ?
thanks a lot,
-- 
Alain

Windows XP SP2
PostgreSQL 8.1.4
Apache 2.2.4
PHP 5.2.1


Re: [PHP] preg_match_all to match img tags

2007-08-10 Thread Ólafur Waage
Guys i would like to thank you for the help.

Jan i used some of your code to help me get this. There was one issue
with yours, preg_match_all while in a foreach will only match the last
match and output that as the $m array.

Here is the code, i hope someone else can use it. Its a working code
in PHP4 and PHP5. I am currenly wrapping the imageManip(); around the
$_POST variable that is the blog post when im posting it to the SQL.
So the getimagesize(); only has to run once.

There is one bug, if the user resizes the image manually to something
less than 590, to say maybe 400, this program will still resize it to
590.

function imageProportions($image)
{
  $imageLoad = @getimagesize($image);

  // if the image is larger than 590 pixels, it will resize both
height and width
  // if not it will do nothing to the variables.
  if($imageLoad[0]  590)
  {
$proportion = $imageLoad[0] / $imageLoad[1];
$imageLoad[0] = 590;
$imageLoad[1] = $imageLoad[0] / $proportion;

return array($imageLoad[0], ceil($imageLoad[1]));
  }
  else
  {
return array($imageLoad[0], $imageLoad[1]);
  }
}

function imageManip($data)
{
  // match all image tags (thanks to Jan Reiter)
  @preg_match_all(/\ *[img][^\]*[.]*\/i, $data, $matches);

  if( is_array($matches[0]) )
  {
// put all those image tags in one string, since preg match all
needs the data
// to be in a string format
foreach($matches[0] as $match)
{
  $imageMatch .= $match;
}

// match all source links within the original preg match all output
@preg_match_all(/src=\(.+?)\/i, $imageMatch, $m);

// for each match that has the same key as the second match,
replace the entire
// tag with my img tag that includes width, height and border=0
foreach($matches[0] as $imageTagKey = $imageTag)
{
  foreach($m[1] as $imageSrcKey = $imageSrc)
  {
if($imageTagKey == $imageSrcKey)
{
  $imageStats = imageProportions($imageSrc);

  $data = str_replace($imageTag, img src=\.$imageSrc.\
width=\.$imageStats[0].\ height=\.$imageStats[1].\
border=\0\ /, $data);
}
  }
}
  }

  return $data;
}


2007/8/10, Jan Reiter [EMAIL PROTECTED]:
 Maybe this is what you are searching for:

 $images = array();
 $data = blah img src=img.png width=\400\ height='600' src=blah.png img
 src=gg.tiff;

 preg_match_all(/\ *[img][^\]*[.]*\/i, $data, $matches);
 foreach($matches[0] as $match)
 {
 preg_match_all(/(src|height|width)*= *[\\']{0,1}([^\\'\ \]*)/i,
 $match, $m);
 $images[] = array_combine($m[1],$m[2]);
 }

 print_r($image);

 It will produce:

 Array
 (
 [0] = Array
 (
 [src] = img.png
 [width] = 400
 [height] = 600
 )

 [1] = Array
 (
 [src] = gg.tiff
 )
 )

 I wrote it just as an example. So you may modify it for your needs!
 Does anyone know if there is a way to put this into ONE regex??

 Jan

 -Original Message-
 From: brian [mailto:[EMAIL PROTECTED]
 Sent: Friday, August 10, 2007 3:18 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] preg_match_all to match img tags

 Ólafur Waage wrote:
  I know this isn't exactly a php related question but due to the
  quality of answers ive seen lately ill give this a shot. (yes yes im
  smoothing up the crowd before the question)
 
  I have a weblog system that i am creating, the trouble is that if a
  user links to an external image larger than 500pixels in width, it
  messes with the whole layout.
 
  I had found some regex code im using atm but its not good at matching
  the entire image tag. It seems to ignore properties after the src
  declaration and not match tags that have properties before the src
  declaration .
 
  preg_match_all(/\ *[img][^\]*[src] *= *[\\']{0,1}([^\\'\ ]*)/i,
  $data, $matches);
  print_r($matches);
 
  This currently makes two arrays for me, the source location from all
  img tags and a large part of the tag itself. But not the entire tag.
 
  What i do is i match the img tag, find the src, get the image
  properties, and if the width is more than 500, i shrink it down and
  add width=X and height=Y properties to the image tag.
 
  How can i match an image tag correctly so it does not cause any issues
  with how the user adds the image.
 

 style
 #your_content_div img { max-width: 500px !important; }
 /style

 OK, so it won't work with IE6. Screw them.

 But if the height is set in the img tag it'll keep that, so the image
 could become distorted. So, you could also do something like:

 #your_content_div img { visibility: none; }

 Then run some Javascript routine onload to properly figure the
 dimensions of each image. Adjust the width down to 500px, if necessary,
 then the height by whatever percent difference between original width
 over new width:

 var new_height = (original_width / 500) * original_height;

 Then, whether you change the dimensions of the image or not, 

Re: [PHP] Running a server process

2007-08-10 Thread Richard Heyes

That is it works with just me using the site.  I am wondering how this would
effect performance if say 500 people were executing this php function around
the same time and the processing overlapped.  Is there anyway to make an
executable run as a service, I am guessing at the terminology that I should
use here, but I feel there would be a much more efficient way of performing
this task.


Well, ideally you don't run an executable. But if you must, there's some 
Windows program that turns an executable into a service. But then 
there's the consideration of communicating with it, which you could do 
with sockets. Or you could use a file.


--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



Re: [PHP] help with ming library

2007-08-10 Thread Stut

Diana wrote:

How do I install the ming library on windows??
I copied the php_ming.dll that I had on another computer and enabled 
this line in php.ini extension=php_ming.dll

but I still get that error Call to undefined function Ming_setScale()


Have you restarted your web server (Apache, IIS, whatever) since 
changing php.ini?


-Stut

--
http://stut.net/

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



Re: [PHP] Running a server process

2007-08-10 Thread Tijnema
On 8/10/07, Nathan Wallis [EMAIL PROTECTED] wrote:
 Hi there,



 I have a windows application the performs  a certain task that I need it to
 perform.  I am in the process of developing my site and am really interested
 in the functionality of the site at the moment and haven't set about putting
 the details in place, so I am using the php function



 exec (start ... );



 To run the process.



 It works.



 That is it works with just me using the site.  I am wondering how this would
 effect performance if say 500 people were executing this php function around
 the same time and the processing overlapped.  Is there anyway to make an
 executable run as a service, I am guessing at the terminology that I should
 use here, but I feel there would be a much more efficient way of performing
 this task.



 Any thoughts would be much appreciated.



 Nathan

500 people at the same time is a big problem, as it will start 500
processes at the same time. I wonder how many Windows servers can
handle that much processes at same time.

If you have written the windows application, you should rewrite some
part of it to let it work with sockets, so that you can simply connect
to the program with a socket.

Tijnema
-- 
Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info

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



[PHP] Hosting cost

2007-08-10 Thread Richard Heyes

This is off topic so feel free to reply off list.

My question is how much is it reasonable to charge for the following:

1. Building a very small website (you can see it here:
   http://www.cleardebtadvice.co.uk)
2. Hosting it for two years
3. Providing email accounts as need be
4. Probably a days worth of update work

I not interested in actual costs, but more commercial worth.

Thanks.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support


--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



RE: [PHP] I know this is not easy and I'm not stupid but...

2007-08-10 Thread Zoltán Németh
2007. 08. 10, péntek keltezéssel 02.31-kor Jan Reiter ezt írta:
 Hi! 
 Thank you for your response! 
 
 The only intention of my code was to investigate the (back then) unexpected
 behavior of the if statement. 
 
 
 With $var['test'] set to blah this expression should be false
 ($var['test'] == 0) for what I know ...
 
 $var['test'] = blah;
 var_dump($var['test'] == 0); 
 
 //returns bool(true)
 
 Now I know why this happens! According to Table 6.5 of the Operators page in
 the PHP Manual in this comparison all of the values are converted to
 integer. And  atoi(blah) for sure will fail!;-) So you have to use === to
 keep the types of the values! 

I found something interesting:

[EMAIL PROTECTED]:~ php -r '$var = 'bla'; var_dump('0' == $var);'
bool(true)
[EMAIL PROTECTED]:~ php -r '$var = 'bla'; var_dump(0 == $var);'
bool(false)

version is 5.2.1

is this expected behaviour to be a difference between the two types of
quotes in this case?

greets
Zoltán Németh

 
 Jan
 
 
 
 -Original Message-
 From: Jim Lucas [mailto:[EMAIL PROTECTED] 
 Sent: Friday, August 10, 2007 1:47 AM
 To: Jan Reiter
 Cc: [EMAIL PROTECTED]; php-general@lists.php.net
 Subject: Re: [PHP] I know this is not easy and I'm not stupid but...
 
 Jan Reiter wrote:
  Hi!
  
  Phil:
  Still I am curious what var_dump($userValues['afterDark']); at line 102.5
  would return. 
  I managed to recreate that fault with 
  
  $var['test'] = blah;
  
  echo ($var['test']);
  
  if( $var['test'] == 0)
  {
  echo ok;
  }
  
  //this returns blahok -- not expected. 
  
  In my case Var_dump() returns string(4) blah as expected.
  
  Using 
  
  if( $var['test'] === 0)
  
  behaves as expected!!
 
 Are you wanting to only test for a empty/non-empty string?
 
 if so, use this.
 
 if ( empty($var['test']) ) {
   echo var['test'] is empty;
 }
 
  
  
  Jim:
  TypeCasting would only be effective if you used the type sensitive
  comparison operator === , because with == 0 equals NULL equals false
  equals  and so on ... or do I miss something here??
  
  
  Hope that solves it for you! I'm still investigating why my first examples
  fails. I've got the strong feeling that I'm missing something there. I
 don't
  believe in a php bug or a memory leak in this case! Must be something
 pretty
  obvious! Anyone a clue??
  
  Thanks,
  Jan
  
 
 

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Robert Cummings wrote:

On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:

On 8/10/07, Stut [EMAIL PROTECTED] wrote:

 I get an email from each
server containing the contents of the error log from the previous day
and my first task each day is to go through that and track down any
issues that usage has highlighted.

That's actually a good point there that I can take away from this.
 I actually don't have anything set to send me a log of code issues,
only when an error is caused (and, of course, anything server-related,
but that's a different point entirely).


Simple enough... put the following in a file, and add a cron job.

#!/usr/bin/php -qC
?php

if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
{
echo Usage: {$argv[0]} subject email path\n;
exit( 1 );
}

$subject = $argv[1];
$email   = $argv[2];
$path= $argv[3];

$content = implode( '', file( $path ) );

if( trim( $content ) === '' )
{
$content = 'NO ERRORS TODAY!!!';
}

mail( $email, $subject, $content );

?


I used to have something similar to this until someone uploaded a script 
that started writing to the error log like mad. Overnight my poor little 
script tried to load a 240meg log file into memory and email it to me. I 
now use a simple bash script that pipes the log to the mail command - 
much safer.


Should probably say that it also renames the log file, graceful's 
Apache, zips the old log and moves it to an archive file server. Rob's 
script above, used without something that starts a new log will result 
in ever-increasing emails.


-Stut

--
http://stut.net/

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



[PHP] phpinfo does not display openssl module

2007-08-10 Thread Alain Roger
Hi

i've reinstalled the complete server and i use apache module to load
openSSL.

However, if i uncomment in PHP.INI the extension=php_openssl.dll, it still
does not appear on screen when i use phpinfo() function.
i've tried also to uncomment some other extension and they also are not
displayed during the phpinfo().

So i though that i modified the wrong php.ini file, but when i checked it
seemed ok.

here is what i get during phpinfo() screen :

Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File
D:\webserver\PHP\php.ini
i do not have any php.ini in C:\windows folder so php.ini is directly loaded
from D:\webserver\PHP\ folder.

does someone see from where could the problem come ?

thanks a lot
-- 
Alain

Windows XP SP2
PostgreSQL 8.1.4
Apache 2.2.4
PHP 5.2.1


Re: [PHP] Hosting cost

2007-08-10 Thread Richard Davey
Hi Richard,

Friday, August 10, 2007, 11:10:21 AM, you wrote:

 This is off topic so feel free to reply off list.

 My question is how much is it reasonable to charge for the following:

 1. Building a very small website (you can see it here:
 http://www.cleardebtadvice.co.uk)
 2. Hosting it for two years
 3. Providing email accounts as need be
 4. Probably a days worth of update work

Would you be re-designing the site? (God I hope so)

It's not exactly complex, but I don't know how quickly you can design,
even so I'd be looking at £200 - £250 per day spent on that.

Hosting would be barely anything for such a small site, do you already
have a host you use? If so take their prices, add your mark-up (x2)
and voila.

I'd hope the hosting would include email by default. I'd never charge
extra for this (unless the email requirements were well out of the
ordinary)

A days worth of update work.. see above.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Daniel Brown wrote:

On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:

I never disable E_NOTICE or even E_STRICT.


I'm humbled in the presence of greatness.

I do my best to ensure that there are no notices or warnings, but
I still disable E_NOTICE in general, because I know that it's not
going to end the world.


Do your best? If you set out with the goal of not allowing your sites to 
generate notices it's no harder than ignoring them. The benefits far 
outweigh the minimal cost.


I must admin that a couple of sites I've been involved with over the 
years have run with notices ignored, but that's only because they 
consisted of large amounts of code that had been written without any 
regard for them. Of all the sites I've worked on those were some of the 
worst.


If PHP thinks something might be wrong it will tell you. Why on earth 
would you want to ignore it? You think you're smarter than PHP? Really?


-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Daniel Brown wrote:

On 8/10/07, Stut [EMAIL PROTECTED] wrote:

Bad Dan *slap*. Ignoring notices may be detrimental to your health
and/or well-being. Better to initialise it with a default if it has not
been set in the request.

if (!isset($_GET['order'])) $_GET['order'] = 'Last';


Ouch!

So you're all going to tell me that you have E_NOTICE set to
report on your sites?  Look, I didn't say it was the Right Way[tm],
but it is safe to ignore.


I do indeed. E_NOTICE can help find certain bugs faster than any other 
method I've found. Turning them off is both lazy and dangerous.


-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Daniel Brown wrote:

On 8/10/07, Jason Pruim [EMAIL PROTECTED] wrote:

Hi All :)

Hope you're not getting sick of my questions as of late, but I keep
getting closer and closer and thank you all who have helped me in the
past! The only reason I can see this far is I am standing on the
shoulders of giants don't know who said that but I like it :)

Anyway... Onto the question...

I think I'm just going crazy as it's been a busy week for me, but I
can't figure out how to do this. What I am attempting to do is, I
have a webpage(Don't we all?) that calls info to be displayed from a
database,

I want to be able to sort that info so my sql query looks like:
Select * from current order by '$order'; and $order is populated by
a GET when they click on a link: A href=index.php?order='Last'Sort
by last name/A  Now... the whole PHP page is being included in
a .shtml page to actually display it and make it look purrdee :)

How do I get it to resort the info and include the new sort on the page?

I'm not sure if this has anything to do with it but:

$order = $_GET['order']; --Line 6

[Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:
order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php
on line 6

Any help will be greatly appreciated.. And if it solves the problem
I'll name some of my kids* after you!



*Subject to approval of the Wife :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





Remember to clean that input before you sit down at the table, there, boy!

It's safe to ignore the `Undefined index` notices.  That will just
appear if a variable is referenced without first being instantiated or
defined.  No biggie, just put this at the head of your code:

ini_set(error_reporting,E_ALL  ~E_NOTICE);


Bad Dan *slap*. Ignoring notices may be detrimental to your health 
and/or well-being. Better to initialise it with a default if it has not 
been set in the request.


if (!isset($_GET['order'])) $_GET['order'] = 'Last';

-Stut

--
http://stut.net/

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



[PHP] php 4.4.7 configure run causes syntax errors

2007-08-10 Thread John Mendenhall
I sent this to the php-install list.  However, with
no response, I knew there would be more eyes looking
at it here.  Hopefully, someone can send me a pointer
on how to resolve this issue, if it is one.

I recently upgraded our php from 4.4.0 to 4.4.7.
When I run configure from the command line with
several options, I get the following errors at
the beginning of the script run:

-
creating cache ./config.cache
checking for egrep... grep -E
checking for a sed that does not truncate output... /usr/bin/sed
expr: syntax error
./configure[1732]: test: 0: unexpected operator/operand
expr: syntax error
./configure[1747]: test: 0: unexpected operator/operand
expr: syntax error
./configure[1747]: test: 0: unexpected operator/operand
-

The first error is always on line 1732.  All the rest are
on 1747.  There is about one error for each option on
the command line.  It ends like this:

-
expr: syntax error
./configure[1747]: test: 0: unexpected operator/operand
expr: syntax error
./configure[1747]: test: 0: unexpected operator/operand
checking host system type... i386-unknown-openbsd3.6
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
-

It continues and completes without errors.
Is this something I need to worry about?

Here is the actual command I have been using recently:

-
./configure \
 --prefix=/usr/local/php4 \
 --with-apxs=/usr/sbin/apxs \
 --enable-debug \
 --disable-cgi \
 --enable-force-cgi-redirect \
 --enable-discard-path \
 --enable-safe-mode \
 --disable-short-tags \
 --disable-ipv6 \
 --enable-magic-quotes \
 --with-openssl \
 --with-pcre-regex \
 --with-curl \
 --with-curlwrappers \
 --with-mcrypt \
 --enable-session \
 --with-mysql=/usr/local \
 --with-mysql-sock=/var/www/var/run/mysql/mysql.sock
-

I am running on OpenBSD 3.6.  Please let me know
if you need any additional information.

Thanks in advance for any pointers you can provide.

JohnM

--
john mendenhall
[EMAIL PROTECTED]
surf utopia
internet services

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



Re: [PHP] manual vs. meta refresh

2007-08-10 Thread Stut

Kevin Murphy wrote:
I doubt this, but is there any way to determine via PHP if a browser was 
refreshed automatically via a META tag vs the person clicking the 
refresh button?


Add a GET variable to the URL you put in the meta tag to tell you it 
came from the meta tag.


P.S. Please note that my e-mail and website address have changed from 
wncc.edu to wnc.edu.


Then you might want to change the from address in your mail client!

-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 19:21 +0200, Tijnema wrote:
 On 8/10/07, Robert Cummings [EMAIL PROTECTED] wrote:
  On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
   On 8/10/07, Stut [EMAIL PROTECTED] wrote:
 I get an email from each
server containing the contents of the error log from the previous day
and my first task each day is to go through that and track down any
issues that usage has highlighted.
  
   That's actually a good point there that I can take away from this.
I actually don't have anything set to send me a log of code issues,
   only when an error is caused (and, of course, anything server-related,
   but that's a different point entirely).
 
  Simple enough... put the following in a file, and add a cron job.
 
  #!/usr/bin/php -qC
  ?php
 
  if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
 
 if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)

Quite true.

  {
 echo Usage: {$argv[0]} subject email path\n;
 exit( 1 );
  }
 
  $subject = $argv[1];
  $email   = $argv[2];
  $path= $argv[3];
 
  $content = implode( '', file( $path ) );
 
 $content = file_get_contents($path); // Safe to require PHP 4 = 4.3.0 right?

I always forget about file_get_contents() because its counterpart
file_put_contents() for some ungodly reason didn't appear until PHP 5.

  if( trim( $content ) === '' )
  {
 $content = 'NO ERRORS TODAY!!!';
  }
 
  mail( $email, $subject, $content );
 
  ?
 

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] string as file

2007-08-10 Thread Stut

Rick Pasotto wrote:

On Thu, Aug 09, 2007 at 03:25:27PM -0500, Greg Donald wrote:

On 8/9/07, Rick Pasotto [EMAIL PROTECTED] wrote:

Does php have a facility similar to python's stringIO?

What I'm wanting to do is similar to a mail merge. IOW, I know I can
create an include file like:

$out = EOT
This is an example of $var1 and $var2.
EOT;

and then after assigning values to $var1 and $var2 include that
file. I can later use different values for $var1 and $var2 and get a
different $out with a second include.

eval()


Explain.

One word responses really don't do any good.

Exactly *what* would be the argument to eval()?


RTFM, that's what it's there for.

Incidentally, eval is evil and potentially a giant security hole. You'd 
be better off doing replacements with preg_match rather than executing a 
string.


-Stut

--
http://stut.net/

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



Re: [PHP] Import XLS file with UTF-8

2007-08-10 Thread Stut

Alain Roger wrote:

Hi,

So now i know how to import the content of the CSV file to database,
however, before to import to database i do a simple test.
in fact, i display in my browser all content of my CSV file.

unfortunately, not all characters are displayed correctly.
in PHP page include meta http-equiv=Content-Type content=text/html;
charset=UTF-8 but it does not help to display the Slovak Characters which
are correctly display in EXCEL when i open the CSV file with it.
i tried to display a standar slovak web page in my browser and it works
perfectly well.

So where could be the problem ?


The Content-Type needs to match the file type, so if the file is not 
UTF-8 extended characters will not be displayed correctly when it's 
displayed as UTF-8.


Try removing that meta tag and see what the browser makes of the file by 
guessing.


-Stut

--
http://stut.net/

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



[PHP] help with ming library

2007-08-10 Thread Diana

How do I install the ming library on windows??
I copied the php_ming.dll that I had on another computer and enabled this 
line in php.ini extension=php_ming.dll
but I still get that error Call to undefined function Ming_setScale() 


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



Re: [PHP] Recursion and threaded message boards...

2007-08-10 Thread Børge Holen
On Friday 10 August 2007 18:29, Stephen wrote:
 --- Tony Di Croce [EMAIL PROTECTED] wrote:
  I have to write some PHP backend code for a threaded
  message board. The db
  has a message table, and each message has a parent
  id.
 
  Does anyone have any advice for someone whos never
  done this in PHP?

 You are reinventing the wheel here. Why?

Why bother doing with these questions when he only asks for advice... 
FOR THE SAKE OF DOING IT!!!



 There are a number of open source PHP message board
 scripts. Check those out, even if just to learn as
 examples.

Ah and here you come through =D


 Stephen

-- 
---
Børge
http://www.arivene.net
---

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



[PHP] Running a server process

2007-08-10 Thread Nathan Wallis
Hi there,

 

I have a windows application the performs  a certain task that I need it to
perform.  I am in the process of developing my site and am really interested
in the functionality of the site at the moment and haven't set about putting
the details in place, so I am using the php function 

 

exec (start ... );

 

To run the process.

 

It works.

 

That is it works with just me using the site.  I am wondering how this would
effect performance if say 500 people were executing this php function around
the same time and the processing overlapped.  Is there anyway to make an
executable run as a service, I am guessing at the terminology that I should
use here, but I feel there would be a much more efficient way of performing
this task.

 

Any thoughts would be much appreciated.

 

Nathan



Re: [PHP] Re: Thoughts about music library

2007-08-10 Thread Børge Holen
On Wednesday 08 August 2007 03:16, Richard Lynch wrote:
 On Tue, August 7, 2007 3:20 am, Colin Guthrie wrote:
  Børge Holen wrote:
  On Monday 06 August 2007 23:39, Colin Guthrie wrote:
  Børge Holen wrote:
  I'm building an web interface for my music collection.
 
  I'd have a quick look at mp3act. It does pretty much what you want
  I think.
 
  yes, but where is the fun in that? ;D
  and if something irritate me, it simple to fix it when I built it
 
  Indeed :p

 I had no problem hacking the DDJ source when I found something I
 didn't like... :-)

Yes, but then again, I get lost in someone elses code(thats beside the 
point ;)


 And, really, you still should at least survey the popular ones to
 steal their ideas :-)

Jup did that, quite a lot. They seem to ponder on the exact same question that 
I have, and I can't seem to find any techincal reasons for why and why not on 
these subjects, I can think of quite a few, but would appreciate some other 
point of view. Someone with more experience on the correct way of doing 
things, and not as a finished program witch works.


 Maybe you'll find one you like and can live with their source code.

Hardly, I like making stuff and learn as I go.


 Maybe you'll still want to roll your own.

 But at least take a look at the car-lot of pre-built wheels, eh?

See above. =D

 --
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some indie artist.
 http://cdbaby.com/browse/from/lynch
 Yeah, I get a buck. So?

-- 
---
Børge
http://www.arivene.net
---

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



Re: [PHP] Running a server process

2007-08-10 Thread Stut

Tijnema wrote:

On 8/10/07, Richard Heyes [EMAIL PROTECTED] wrote:

That is it works with just me using the site.  I am wondering how this would
effect performance if say 500 people were executing this php function around
the same time and the processing overlapped.  Is there anyway to make an
executable run as a service, I am guessing at the terminology that I should
use here, but I feel there would be a much more efficient way of performing
this task.

Well, ideally you don't run an executable. But if you must, there's some
Windows program that turns an executable into a service. But then
there's the consideration of communicating with it, which you could do
with sockets. Or you could use a file.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk


I don't know if there a program exists that can convert the program
to a service, I think you need to compile it as a service from source
code, but as I mentioned in my first post, and you mentioned here too,
you also need to add support for a socket server in your program.
Sockets in PHP are easy ;)


http://www.firedaemon.com/

But you're right, you'd need a way to communicate with the service.

-Stut

--
http://stut.net/

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



[PHP] simplexml_load_file()

2007-08-10 Thread Panquekas
Hello,

I'm doing an script which it'll read the xml values, but I have one
problem doing that.

On the xml there is a tag that has an hífen in the middle, so when I do
echo $xml-comment-id it gives me an error.

How can I make this work?

Thanks in advantage.


Re: [PHP] php 4.4.7 make install with pear causes zend freeing errors

2007-08-10 Thread John Mendenhall
 On 8/10/07, John Mendenhall [EMAIL PROTECTED] wrote:
  Per my previous message, I have recently upgraded from
  php 4.4.0, to php 4.4.7.  My configure options are as
  follows:
 
 snip
 
  I would like to know what I am doing wrong here.
  When I turn off pear, this does not happen.
  When I try to upgrade or install pear packages,
  I get the same types of errors.
 
 What are you doing with PHP4???

We have several clients with web applications and
sites that break when we attempted to upgrade to
php5.  Upgrading to php5 is a priority.  However,
we are unable to do this at this time.

JohnM

-- 
john mendenhall
[EMAIL PROTECTED]
surf utopia
internet services

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



[PHP] Re: string as file

2007-08-10 Thread Dan
Well, I have no idea what the Phython StringIO method does.  Could someone 
explain in PHP terms maybe?  Google gave me this explaining stringIO 
http://docs.python.org/lib/module-StringIO.html .  It didnt' make much sense 
still after reading it though.


- Dan

Rick Pasotto [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

Does php have a facility similar to python's stringIO?

What I'm wanting to do is similar to a mail merge. IOW, I know I can
create an include file like:

$out = EOT
This is an example of $var1 and $var2.
EOT;

and then after assigning values to $var1 and $var2 include that file. I
can later use different values for $var1 and $var2 and get a different
$out with a second include.

Can I someout include a string instead of a file? Or maybe there is
some completely different way to do what I want.

--
I have always in my own thought summed up individual liberty, and
business liberty, and every other kind of liberty, in the phrase
that is common in the sporting world, A free field and no favor.
-- Woodrow Wilson, U.S. President, 1915
   Rick Pasotto[EMAIL PROTECTED]http://www.niof.net 


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



Re: [PHP] Code Igniter for 'novices' ?

2007-08-10 Thread Dan
Um yeah.  The PHPpatterns.com site hasn't been updated for years.  Plus I'm 
unable to find any actual content on anything there.  I looked through the 
indexes but didn't find anything.



Nathan Nobbe [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

steve,

though i havent used code igniter i consider the tutorials on the site
demonstrating how to use it quite valuable.
i think they are valuable because they can show people who arent familiar 
w/

a development flow,
using an mvc framework, what its like, in general.
i have heard good things about code igniter.

if you want to learn the core values, i recommend opp and design patterns.
here is a nice free site to get you headed in the right direction for php.

http://www.phppatterns.com/docs/start

-nathan

On 8/9/07, Steve Finkelstein [EMAIL PROTECTED] wrote:


Hi all,

This isn't a 'which framework is better than the other' question. I'm a
novice developer and I'm looking to conform to an MVC model for my
applications. I was wondering if anyone would be kind enough and has used
code igniter, to respond to me and let me know their thoughts on it, and
if
it's a good framework to work with as a novice.

I eventually hope to learn the core values and build my own robust
framework.

Thanks :-)





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



RE: [PHP] Open Source Job Wanted system

2007-08-10 Thread Joey
Hey Nathan,


Actually what I was looking for was an application so that I could have a
service like craiglist.

 

Joey

 

From: Nathan Nobbe [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 09, 2007 3:46 PM
To: Joey
Cc: PHP
Subject: Re: [PHP] Open Source Job Wanted system

 

craigslist is out there, but i havent posted a resume on there..

-nathan

On 8/9/07, Joey [EMAIL PROTECTED] wrote: 

Has anybody had any experience with any open source Job posting systems out
there? 



Thanks!





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

 

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



Re: [PHP] Open Source Job Wanted system

2007-08-10 Thread Richard Lynch
On Thu, August 9, 2007 1:54 pm, Joey wrote:
 Has anybody had any experience with any open source Job posting
 systems out
 there?

Check this out:
http://jobcoin.com/

I haven't had a chance to install it and play with it yet, but it sure
seems reasonable in its approach.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] manual vs. meta refresh

2007-08-10 Thread Richard Lynch
On Fri, August 10, 2007 1:26 pm, Kevin Murphy wrote:
 I doubt this, but is there any way to determine via PHP if a browser
 was refreshed automatically via a META tag vs the person clicking the
 refresh button?

You could embed something in the META tag's URL such as:

meta http-equiv=refresh
content=5;http://example.com?from_meta_tag=1; 

You would then need to re-direct back to the URL *without* the GET
parameter from_meta_tag=1 so that their refresh button would not be
going to that URL with from_meta_tag in it.

Kind of kludgy, but should work

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] Re: Forwarding $_POST[]...

2007-08-10 Thread Dan

I have a suspicion that this is something like.

1. User enters info
2. Checks if info is indeed valid
   |_ If not then ask the user for correct info
3. Done process the info

Is this right?

You can do this buy having PHP post to itself, it checks if the info is 
valid and if it isn't it renders a page asking for correct info and 
resubmits to itself till it gets what it wants.  Then it does whatever you 
want it to.


Other than that yes, it can be somewhat annoying trying to move data between 
PHP files, especially if you want seperate scripts to be more object 
oriented in that each has a specific function.  Does anyone know of an easy 
to pass data between PHP files?


- Dan

Tony Di Croce [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

I keep wanting to do something, and either I dont know how to do it, or I'm
doing something wrong and need to rethink things.

Quite often, I have a form that submits to a php script via POST and after
doing some processing (or more frequently, asking the user a question), 
I'd

like to forward those $_POST[] vars to another script (or even the same
script).

I could do something complicated and store the $_POST vars in $_SESSION[],
but what I'd rather do is simply add a var to $_POST[] and resubmit this 
to

the same .php.

Is their any way to do this, or do I need to rethink things?

  td

--
Publish technical articles @ skilledwords.com and get 100% of the
ad-revenue!
http://www.skilledwords.com



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



Re: [PHP] Re: PHP on .NET DLR

2007-08-10 Thread Richard Lynch
On Fri, August 10, 2007 12:12 pm, Sancar Saran wrote:
 Once upon a time I try to ignite PHP community to develop some kind of
 client
 side php, which failed, because lack of interest (or because of
 javascript).
 In open source world everthing boosted from personal interest.

Wez did a PHPScript thingie that I think works as an ActiveX
controller or somesuch...

It's in PECL.

Never found time to play with it, but it sure looks interesting...

I've got ZERO interest in anything .net related, personally.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] and newlines under windows

2007-08-10 Thread Richard Lynch
On Fri, August 10, 2007 11:48 am, Faither wrote:
 I'm kind of lost with how str_replace , preg_replace, ereg_replace or
 even explode are handling a \n-ewline.
.
.
.
 Is it even possible under windows? ^^

In Linux, the newline is \n, but...

Under Windows, the newline isn't \n, it's \r\n

In the Mac world it's \r

Now the browsers are running on whatever platform, and the user is
copying/pasting in text or whatever, and the data you get PROBABLY is
using the newline encoding of the web browser client platform.

So, to normalize any input with newlines, do this:

//assuming basic ASCII text data input:
$data = str_replace(\r\n, \n, $data);
$data = str_replace(\r, \n, $data);

Store that normalized text in the database.

When you DISPLAY the text to the user, you might want to use:
echo nl2br($data);

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



  1   2   >