[PHP] Re: Remote MySQL Connecton Problems

2009-05-07 Thread Ray Hauge

Nathan Rixham wrote:

Ray Hauge wrote:

Hello everyone,

I've run into a bit of a sticky situation trying to connect to a 
remote MySQL database.  Here's the background:


Connecting from the command line on the web server works.

Connecting from a different vhost works.

There's no information in mysql_error.  In fact, mysql_select_db('db') 
or die(mysql_error()); doesn't produce any output.


The only way I know this isn't working is when I try to run a query, 
the result resource is NULL.


If I copy the contents of the query and run it on the command line, 
from the web server, I get the results I expected.


I manage both servers.  I added the new login on the MySQL server and 
also ran flush privileges.  I've gone so far as to reboot both the 
MySQL process and the apache process.


The versions of MySQL are slightly different 5.0.24a (web) vs 5.0.36(db).

It's getting late and I'm just grasping for straws.

Thanks!
Ray


and thus:
database server works - yes
user and login works locally - yes
user and login works remotely - yes
user and login works on box in question - yes

further debug:
do mysql connections work for any host at all in php? - todo
is the mysql module for php installed - todo check phpinfo() output
is error reporting enabled - todo set error_reporting to E_ALL
does a simple query such as show databases return any results
is query properly formatted and are variables properly replaced in php 
version - todo check


I'd reckon that by the time you've checked all the above - you'll have 
your own solution :)


regards!


Thanks Nathan!

I'm not sure what the problem was.  I think I was tired and trying too 
hard to solve an issue that didn't exist.  I was thinking that 
var_export($db_conn) would display MySQL Resource Id #1 or something 
similar, but it was displaying NULL.  I took out all my debugging code 
and it's working fine now.


Ray

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



[PHP] Remote MySQL Connecton Problems

2009-05-06 Thread Ray Hauge

Hello everyone,

I've run into a bit of a sticky situation trying to connect to a remote 
MySQL database.  Here's the background:


Connecting from the command line on the web server works.

Connecting from a different vhost works.

There's no information in mysql_error.  In fact, mysql_select_db('db') 
or die(mysql_error()); doesn't produce any output.


The only way I know this isn't working is when I try to run a query, the 
result resource is NULL.


If I copy the contents of the query and run it on the command line, from 
the web server, I get the results I expected.


I manage both servers.  I added the new login on the MySQL server and 
also ran flush privileges.  I've gone so far as to reboot both the MySQL 
process and the apache process.


The versions of MySQL are slightly different 5.0.24a (web) vs 5.0.36(db).

It's getting late and I'm just grasping for straws.

Thanks!
Ray

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



Re: [PHP] Robert Cummings

2008-09-30 Thread Ray Hauge

Daniel Brown wrote:

All:

What was pointed as a passing mention in one thread I thought was
worth note in a thread of its own.  As quoted by Rob:


BTW, while we're off topic... my wife delivered our third child (second
boy) 3 minutes after midnight yesterday :)


I'd say that deserves a round of congratulations.  Many - most,
probably - of you know Rob from here, and have seen his help and
dedication - as well as his annoying wit ;-P - offered to any and all
on this list.  Quite often, it's offered when you don't especially
want it.  Nonetheless, it's great news, and I think we should all take
a moment and wonder: why the hell aren't you at the hospital with your
wife and newborn son, Rob?  ;-P

Congrats to the Cummings family!



Oh wow, congrats Rob!  We just had our second (and last after my 
surgery) 5 months ago.


Enjoy the lack of sleep :)

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Zend Platform

2008-09-09 Thread Ray Hauge

Stut wrote:

On 9 Sep 2008, at 18:52, Nathan Rixham wrote:
Short and sweet; does anybody have any practical experience; thoughts 
or case studies in regards to implementing the Zend Platform.


Yeah, I used it in my previous job a coupla years ago. It looks great, 
the marketing hype is well executed but as usual the reality is far from 
the promise. There are some aspects I really like, but mainly in 
concept. What you actually get is expensive extra bloat to install on 
your servers.


* The bytecode cache can be replaced by one of several free solutions 
out there.


* The job queue is a great idea but the implementation is problematic at 
best. Avoid this if you can.


* The centralised logging and the alerting features are nice - this is 
probably the only but I really found useful.


* The clustering features I did not use so didn't look at too closely, 
but it didn't appear to offer anything that couldn't be replicated 
pretty easily with open source tools.


At the end of the day what you're buying is marketing hype, and there 
are people out there who fall for it hook line and sinker. My advice is 
that unless you have someone insisting you use ZP, don't. And even if 
you do I urge you to look at what you actually need from it and evaluate 
alternatives before making a commitment. Have you ever heard about 
Facebook, Yahoo or any other big player using it?


Don't get me wrong, I think Zend is a great company, but I just don't 
see the value in ZP. For the price of the license you could add another 
server which will give you far better ROI and higher capacity then ZP 
could ever achieve.


And don't get me started on what they've done to Zend Studio. I've 
switched to Aptana - same platform, but cheaper and a lot more stable. 
Shame!


-Stut



I agree with most of your post.  The error logging features are great. 
I haven't used ZP for a while, but when I did it was nice to get an 
alert right away of what happened, and it also captured the variables in 
use at the time so that you could see why it happened.  If the error 
reporting is what you're looking for, then the bytecode caching is a 
nice addition, but like you said there are OSS alternatives.


I also completely agree with the Zend Studio comment.  I've switched 
back to Zend Studio 5.5, because the Eclipse version was just so 
unintuitive... especially for debugging.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What font/size do you use for programming?

2008-07-08 Thread Ray Hauge

tedd wrote:

Hi gang:

I'm running a Mac (so I know mine is a bit different size wise) but I'm 
currently using Veranda at 14 point for coding.


Just out of curiosity, what font and size do you ppls use for your 
programming?


Cheers,

tedd



12pt Adobe Sans MM (Zend Studio) on a 19 LCD @ 1280x1024 running Linux.

I'm not doing PHP at my new job anymore (bummer), but the terminal I use 
to connect to the OpenVMS server uses auto font scaling to make it super 
huge (the programs only support 80 and 132 character screen widths).


BTW, MUMPS is a very interesting language.  By interesting I really mean 
crazy, but I suppose it is really old.


F I=1:1:10 W VALUE: _I,! ; Writes VALUE:  . I each on a new line

Sorry for venturing off-topic, but I told you!

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Convert PDF Files to PCL-Files

2008-07-04 Thread Ray Hauge

jogisarge wrote:

Hello @all,

i am running php5 on a IBM i5 V5R4.
now i have to print exisiting pdf-files.

the problem is, i cant use external programms like pdftops or other stuff
like this, because the php core runs in the pase environment.

is there any possibility to convert existing pdfs to pcl files ?

bye jo






I don't know if IBM has a port of the linux command pdf2ps (to post 
script).  There should be some sort of converter from post script to 
PCL, but I'm not completely sure on that.  I'm not currently aware of a 
straight converter.  Sorry if that's not much of a help.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Another canvas example

2008-06-24 Thread Ray Hauge

Richard Heyes wrote:

Pretty sweet! My only problem with it is that I had to use the keyboard
to get to the Attach button, since I couldn't click on it with it
being behind the pie chart in the page's Z-order.


Yes, no way around (I think). Even with the buttons z-index set to 99 it 
still shows up behind the beachball.


TAB and the spacebar are your friends I guess... :-)



You could make the z-index of the beachball at 1, and then put the rest 
of the page in a div with a z-index higher than 1.  The beachball should 
then still appear, but be under the div, which allows you to click the 
button.  I ran into the same issue with a game I've been making:


http://www.primateapplications.com/trackattack/

Since you're working with the Canvas, you can be reasonably sure that 
the browser would support doing this.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Another canvas example

2008-06-24 Thread Ray Hauge

Richard Heyes wrote:

Pretty sweet! My only problem with it is that I had to use the keyboard
to get to the Attach button, since I couldn't click on it with it
being behind the pie chart in the page's Z-order.


Yes, no way around (I think). Even with the buttons z-index set to 99 it 
still shows up behind the beachball.


TAB and the spacebar are your friends I guess... :-)



Oh, I forgot to mention that you'll have to make the css position 
attribute relative.  Then the z-index will work.  I think that's what I 
had to do for the same issue. *


* I had to get up in the middle of the night to check some production 
issues and checked my email while waiting.  My memory might not be fully 
functioning :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Re: Another canvas example

2008-06-24 Thread Ray Hauge

Per Jessen wrote:

Colin Guthrie wrote:


http://www.primateapplications.com/trackattack/

Since you're working with the Canvas, you can be reasonably sure that
the browser would support doing this.

Dude, that's cool it's killed my productivity, but it's cool :D


The Playmobil website has a very similar one, except it's water-pipes
and Flash. 



/Per Jessen, Zürich




My son likes trains, and I was using this as an excuse to learn 
JavaScript better.  My wife's favorite NES game (yes, I collect NES 
games) was/is Pipe Dream, so I modeled it after that game.  It uses 
Soundmanager2 to play the music and sounds through Flash.  All the code 
is inline, just to make it easier for people to view the code.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Another canvas example

2008-06-24 Thread Ray Hauge

Daniel Brown wrote:

On Tue, Jun 24, 2008 at 3:53 AM, Ray Hauge [EMAIL PROTECTED] wrote:

http://www.primateapplications.com/trackattack/


Ray,

This displays perfectly fine, but does not function beyond looking
pretty on Firefox 3 (Linux/KDE).  I am, however, probably going to
play that game for a bit on my non-Linux (I refuse to say the name!)
machine.

Maybe Rich could turn his canvas example into the first
HTML/CSS/JavaScript beach volleyball game.  It would be the closest
some of us would probably get to detaching from our desks and getting
onto a beach to play anyway.



Strange, I've tested it on Kubuntu Hardy  FF 3, SuSE SLED 10.1  FF2, 
Windows FF23 Safari Opera 9.5 IE67, Mac OSX Safari.  I'd be interested 
in what error you got, just email me off-list if you like.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Another canvas example

2008-06-21 Thread Ray Hauge

Richard Heyes wrote:

Hi,

Latest in my new series of look at me, aren't I cool canvas examples 
is here:


http://www.phpguru.org/pie/pie.html

Works in IE7 too. And Opera. Ooh.



Awesome stuff.  I think the canvas element will be my next adventure. 
I've been learning JavaScript a lot recently.  That's been an 
interesting experience that I'm glad I did.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Adding a page with FPDF

2008-06-18 Thread Ray Hauge

Brian Dunning wrote:

Anyone use FPDF?

I'm trying to create a new document in memory, starting with a template 
document - I'm going to add some stuff to it. The template document 
might be any size and dimensions. Here is the code I'm using, and my 
problem is that the resulting document is always an 8.5x11 page. How do 
I get my new document to be the same dimensions as the template doc?


$pdf= new fpdi();
$pagecount = $pdf-setSourceFile(templates/.$pdf_template_name);
$tplidx = $pdf-ImportPage(1);
$pdf-addPage('P');
$pdf-useTemplate($tplidx);



I think you have to specify the page size when you create the $pdf 
variable.  Here's how I've been using it:


$pdf = new fpdi('P','pt','letter');

You might be able to use the FPDF_TPL::getTemplateSize() method to 
figure it out dynamically somehow though:


http://www.setasign.de/support/manuals/fpdf-tpl/fpdf-tpl/fpdf-tpl-gettempaltesize/

It also looks like the useTemplate method might do some legwork for you, 
but I'd have to test...


http://www.setasign.de/support/manuals/fpdf-tpl/fpdf-tpl/fpdf-tpl-usetemplate/

HTH

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Canvas examples

2008-06-16 Thread Ray Hauge

Richard Heyes wrote:
I guess the other browser doesn't do much with canvas ? 


Nope. Eg:

canvas id=foo
This gets shown on none supporting browsers, but not on supportive
browsers.
/canvas

MSIE just shows the text and doesn't do anything with the canvas.

One thing about using a canvas is bandwidth. If it's a big concern I 
would hazard a guess that a bar chart (for example) would cost less in 
terms of code required to build the image compared to JPGraph, and also 
less in terms of output (particularly if you were to use output 
compression).




Another idea for dynamic graphing could be:

http://solutoire.com/plotr/

It also uses the canvas element, but if you use excanvas for IE it'll 
work in most newer browsers.  I've used it in a project to provide 
dynamic bar graphs from a queue so that they could see in semi-real time 
how many customer requests were in different queues.  It was an internal 
app, or else I'd link it :(


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Canvas examples

2008-06-15 Thread Ray Hauge

Richard Heyes wrote:
Does anyone have any more examples of the new canvas element they've 
written?


FF only: http://www.phpguru.org/canvas.html



This is a pretty interesting use of Canvas as well.  Thanks for sharing!

http://ejohn.org/blog/processingjs/

--
Ray Hauge
www.primateapplications.com

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



[PHP] Enterprise

2008-05-20 Thread Ray Hauge
I just read an interesting article about enterprise software.  One of 
the most common arguments against PHP tends to be It's not enterprise 
ready.  This article talks more about ruby, but it could be about any 
non-enterprise language as well.


http://lists.canonical.org/pipermail/kragen-tol/2005-April/000772.html

I recently got a new job at a hospital, and the enterprise software 
they have is no where near as high quality as it could/should be.  This 
is my first job at a somewhat large organization (500+ employees) so I 
was kind of shocked at the state of their software.  Typically 
healthcare systems are further behind in the technology adoption, but 
having to deal with workarounds all day long sure gets old.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] SCanning text of PDF documents

2008-05-15 Thread Ray Hauge

Angelo Zanetti wrote:

Hi All.

This is a quick question.

A client of ours wants a solution that when a PDF document is uploaded that
we use PHP to scan the documents contents and save it in a DB.

I know you can do this with normal text documents using the file commands
and functions.

Is it possible with PDF documents?

My feeling is NO, but perhaps someone will prove me wrong.

Thanks in advance.

Angelo

Web: http://www.elemental.co.za 






One thing you'll have to watch is that if the PDF was created by a 
scanner, then the text on the PDF is actually just an image and cannot 
be read without OCR.  I got stumped on that one for a while when I was 
doing something similar :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] creating an xls file from mysql data

2008-05-12 Thread Ray Hauge

Chris wrote:

Richard Kurth wrote:

This script will create an xls file from the data that is sent to it
When I run this it only gets one recored and it is supposet to get all
the records that are past by the  $_POST[selectedcontactlist]
I think I have a } in the wrong place but I can not figure it out
anybody have a suggestion

$_POST[selectedcontactlist]=3,45,65,23,12,4,56; //this is a sample of
what is past

$ExplodeIt = explode(,,rtrim($_POST[selectedcontactlist],,));
$Count = count($ExplodeIt);
for ($i=0; $i  $Count; $i++) {
$sql = SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]';


Instead of doing that, do this:

/**
* This section makes sure the id's you are going to use in your query
are actually integer id's.
* If they aren't, you'll get an sql error.
*
*/
$ids = array();
foreach ($_POST['selectedcontactlist'] as $id) {
  if (!is_int($id)) {
continue;
  }
  $ids[] = $id;
}

// all posted values are duds? show an error.
if (empty($ids)) {
  echo No id's are numeric, try again;
  exit;
}

$sql = select * from contacts where id in ( . implode(',', $ids) . );


That'll get everything for all of those id's and then you can loop over
it all once:

// print out the header for the csv file here.

// then loop over the results:
while ($row = mysql_fetch_assoc($sql_result)) {
  // put it into file here.
}

// close the file
// print it out.



Or you can do it straight from MySQL, which is a lot faster:

SELECT [fields] INTO OUTFILE '/path/to/file.csv' FIELDS TERMINATED BY 
',' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\n' FROM [tables] 
WHERE [conditions]


If you want a header row, then you can use a UNION statement.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] peer review (was php framework vs just php?)

2008-04-25 Thread Ray Hauge

Jay Blanchard wrote:

I did a quick and dirty of just one of those functions. This function
takes a table and creates a form based on the table. It needs quite a
bit of refining, but I am willing to share and let you guys and gals
throw suggestions;


I use a very similar style of approach, but it's more on a field by 
field basis rather than a whole form.  I also wrote mine on company 
time, so here's an example:


?php $table = 'customers'; ?
form id='search' name='search' action='' method='post'
table align='center'
tr
td align='right'?php echo UI::getFieldLabel($table, 
'first_name'); ?/td
td colspan='3'?php echo 
UI::getBlankTextField($table, 'first_name'); ?/td

/tr
tr
td align='right'?php echo UI::getFieldLabel($table, 
'city'); ?/td
td?php echo UI::getBlankTextField($table, 'city'); 
?/td

/tr
tr
td align='right'?php echo UI::getFieldLabel($table, 
'state'); ?/td
td?php echo UI::getBlankSelectField($table, 
'state'); ?/td
td align='right'?php echo UI::getFieldLabel($table, 
'zip'); ?/td
td?php echo UI::getBlankTextField($table, 'zip'); 
?/td

/tr
/table
/form

The UI class figures out the max-length of the field, and there are also 
configurations to determine what type of field it is (text, phone, date, 
textarea, etc.) and security settings based on the user logged in.  This 
has helped keep my template files very clean, and I still have full 
control over the form by not including the fields I don't want.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Should This Newbie Learn From Dreamweaver?

2008-04-22 Thread Ray Hauge

revDAVE wrote:

First of all - I know this is an entirely subjective question, and I know
there's no single approach to learning this technology. I'm just looking for
a few hints from seasoned professionals basically whether Dreamweaver
verbose code (at least it looks like that to me at this beginning point) is
all 'needed  necessary'...
 


Like you said it's all subjective, but my opinion is to learn the basics 
first, then you can rely on your tools to take the mundane work out of 
the way for you.  I'd still suggest using an editor with code completion 
though, because it will help you when you're trying to remember 
parameter orders or even function names to a point.


After you feel comfortable with that, then you'll be able to understand 
what the program is doing for you and it won't be a black box that 
really is unsupportable.  I find the best way to do that is to come up 
with some little program that you code up for fun to help get you 
through the learning stages.  You'll learn more figuring out how to get 
something to work than just copying and pasting code.


That's my 2 cents.  Hope that helps.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Evaluating math without eval()

2008-04-12 Thread Ray Hauge

Jason Norwood-Young wrote:

On Thu, 2008-04-10 at 13:15 +0100, Richard Heyes wrote:

First post to this list! I'm trying to figure out how to evaluate a
string with a mathematical expression and get a result, but without
using eval() as I'm accepting user input into the string. I don't just
want addition, subtraction, multiplication and division - I'd like to
take advantage of other functions like ceil, floor etc. 


So the string 18-10 should give me 8, ceil(1/2)*10 should be 10 (if
my maths is correct) and the string 18-10;\r\nunlink('/var/www/*');
should not execute.
If you can provide your users with distinct inputs (if it's a form) go 
that route.


Thanks Richard

Unfortunately it's not that simple. The equation sits in a DB and can be
anything - eg. ((([valuation]/[purchaseprice])/100)*100)/[numyears]
would be a typical field. [valuation], [purchaseprice] and [numyears]
gets replaced by relevant fields from user-entered data. But the system
is expandable which means I don't know what the equations, data or
fields are going to be beforehand. 


I'm working on some kinda preg_replace function to sanitize the data at
the moment and then run an eval - arg I hate regexp! Ideally eval would
have some kind of sandboxing option, or you could limit the functions
available in an eval.

J




you might be able to leverage a call to expr on a bash sell.  Just 
replace the variables you're expecting with preg_replace or some similar 
function.


http://hacktux.com/bashmath
http://sysblogd.wordpress.com/2007/08/26/let-bash-do-the-math-doing-calculations-using-that-bash/

I'm not sure if that's any more secure than eval though.

--
Ray Hauge
www.primateapplications.com

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



[PHP] April Fools Easter Egg

2008-04-01 Thread Ray Hauge

Don't forget to check your phpinfo() page for the annual easter egg.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] April Fools Easter Egg

2008-04-01 Thread Ray Hauge

tedd wrote:

At 9:23 AM -0500 4/1/08, Ray Hauge wrote:

Don't forget to check your phpinfo() page for the annual easter egg.

--
Ray Hauge
www.primateapplications.com



You got me.

Cheers,

tedd



Here's the image that I see on PHP 5.1.0. My 5.2.5 site has a distorted 
image instead of the dog.


5.1.0:
http://www.primateapplications.com/info.php.gif

5.2.5:
http://www.primateapplications.com/info.php

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Dates Again

2008-03-31 Thread Ray Hauge

Zoltán Németh wrote:

VamVan írta:

Hello All,

I have a date in 2008-03-29 12:15:00  format.

   - How can I reduce one day from it?
   - How can I reduce one hour from it?
   - How can I add 1 hour to today's date?

Thanks



just convert it to a timestamp with strtotime()
then you can manipulate it by adding/substracting
- 86400 for a day
- 3600 for an hour
then convert back with strftime()

http://hu.php.net/strtotime
http://hu.php.net/strftime

greets,
Zoltán Németh



I believe you can also use strtoime() 
http://us.php.net/manual/en/function.strtotime.php


$time = strtotime($inputTime);
$time = strtotime('-1 day', $time);
$outputTime = strftime('%Y-%m%d', $time);

I'm not sure which is more efficient, but it helps when you're looking 
for next thursday or other things like that.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] question about linux editor

2008-03-25 Thread Ray Hauge

Sudhakar wrote:

i need to connect to the linux server using an editor. can anyone suggest
which would be an ideal linux editor to connect to the server.
apart from the ip address, username and password are there any other details
i would need to connect to the server.

please advice.

thanks.



I also will typically use SSH + vi, but Zend Studio (not sure about 
Eclipse) can open an SSH connection and edit files that way.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] google books

2008-03-24 Thread Ray Hauge

John Pillion wrote:

Not a PHP question. but could someone point me in the direction of how to
download/display only a portion of a PDF, much like google books does?  For
example, if you have a 200 page pdf, but the user wishes to see the portion
that is on page 150. rather than downloading the entire PDF, only
download/display page 150?

 


I would like to avoid having to split them into 200 individual PDF's
(whether manually or automatically).

 


Any suggestions?

 


- JP




You could use FPDF and FPDI to just load up the one page:

http://www.setasign.de/support/manuals/fpdi/

Just use importPage($thePageNumberYouWanted);

code

$pdf = new fpdi('P', 'pt', 'letter');

$pdf-setSourceFile(self::PATH);
$tpl = $pdf-ImportPage(1);
$pdf-AddPage();
$pdf-useTemplate($tpl, 0, 0);

$data = $pdf-buffer;
$pdf-closeParsers();

header(Content-type: application/pdf);
header(Content-disposition: inline; filename=FileName.pdf);
header(Content-length:  . strlen($data));

echo $data;

/code

I just realized that the version of FPDI I've been using is a little 
old.  There's a new update out, so some of the above code might change a 
little.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] spider

2008-03-21 Thread Ray Hauge

tedd wrote:

Hi gang:

How do you spider a remote web site in php?

I get the general idea, which is to take the root page, strip out the 
links and repeat the process on those links. But, what's the code? Does 
anyone have an example they can share or a direction for me to take?


Also, is there a way to spider through a remote web site gathering 
directory permissions?


I know there are applications, such as Site-sucker, that will travel a 
remote web site looking for anything that it can download and if found, 
do so. But is there a way to determine what the permissions are for 
those directories?


If not, can one attempt to write a file and record the 
failures/successes (0777 directories)?


What I am trying to do is to develop a way to test if a web site is 
secure or not. I'm not trying to develop evil code, but if it can be 
done then I want to know how.


Thanks and Cheers,

tedd



Have a look at something like this:

http://simplehtmldom.sourceforge.net/

I haven't used it, but if it works you should be able to pull up a list 
of all the a tags quite easily through the DOM ala:


foreach($dom-find('a') as $node)
  echo $node-href . 'br';

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] why use {} around vraiable?

2008-03-20 Thread Ray Hauge

Lamp Lists wrote:

hi,
I saw several times that some people use this
 
$parameters = array(

  'param1' = {$_POST[param1]},
  'param2' = {$_POST[param2]}
 );

or

 $query = mysql_query(SELECT * FROM table1 WHERE id='{$session_id}');

I would use:

$parameters = array(
  'param1' = $_POST[param1],
  'param2' = $_POST[param2]
 );
 
 and


 $query = mysql_query(SELECT * FROM table1 WHERE id=' .$session_id. ' );


does it really matter? is there really difference or these are just two 
styles?

thanks.

-ll


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


The brackets are used to enforce that the entire contents between them 
is a variable.  It helps when you're using class members.


$example = this is an {$example-text};

It's also handy when you're putting variables in a heredoc.

I would suggest not using {$_POST[param1]}, like you said.  It's 
just going to make PHP figure out the string, then put the value in that 
string.  If you really wanted to make sure it's a string type then you 
can do (string)$_POST['param1'].


The short answer is you can do it the way you're doing and everything 
will work out just fine :)


--
Ray Hauge
www.primateapplications.com

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



[PHP] Closures

2008-03-18 Thread Ray Hauge
I've been reading up on some of the parts of PHP that has been suggested 
could be improved so that I could be more well informed.  One of the 
more interesting (for lack of a better word) suggestions is closures. 
 I've used closures primarily in JavaScript, and they are handy in that 
context, but JavaScript handles events and other more dynamic situations 
like that.


I can't really think of any good examples of why I'd want to use a 
closure instead of just calling functions or class methods in PHP. 
Variable functions and call_user_func*() have worked for any of the 
cases where I did need to be a bit more dynamic.


I found a great summary of some discussion on the internals mailing list 
over here: http://devzone.zend.com/node/view/id/2013#Heading1


After reading that article through, I do like Wez's idea of how to 
create anonymous functions.  The point about it causing confusion with 
people coming from other languages definitely applies though.  This 
article also gives me a second idea for this post.  How many people 
would want closures in PHP?


In summary:

Would you want closures in PHP, and why?

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Closures

2008-03-18 Thread Ray Hauge

Nathan Nobbe wrote:
if we were going to see support for anything anonymous that i would 
welcome it would be anonymous objects and the ability to create an 
object on the fly from an interface as per java 5. 


I'm not sure if this would solve your problem (my lack of java knowledge 
is showing), but you can create objects either by creating a new 
stdClass() object, or by using (object)NULL.  Example:


?php

$object = (object) NULL;

$object-test1 = 1;
$object-test2 = 2;

echo $object-test1 . \n;

echo $object-test2;

?

After trying to add a way to call a function from an object variable, I 
have come to the conclusion that it's kinda ugly.


?php

$obj = (object) NULL;

$obj-test = 2;
$obj-myTestFunc = myTestFunc;

function myTestFunc () {
   return test;
}

echo call_user_func($obj-myTestFunc) . $obj-test;

?

Does anyone have a link to some documentation about the stdClass?  All I 
could find was a bunch of bug reports and other stuff that wasn't what I 
was looking for.  I would have thought there'd be a page for it in the 
manual, but I didn't find one there either.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Objects as array key names??

2008-03-15 Thread Ray Hauge

Jim Lucas wrote:
This question should probably be directed at the PHP Internals list, but 
I thought I would start by asking here first if anybody would even use 
this feature.


It has been brought to my attention that with Perl and Ruby, you can use 
Objects as the value of the key within an array.  The examples that were 
shown to me make me think that this would be an awesome ability to have 
within PHP.


Here is an example of how I would use such a feature.

I have a table of customers.
I have a table customers contact_locations.
This table has a reference ID back to the customers table.

Now, in my array of information that I build I have this.

$res = query('Select c_id, c_first_name, c_last_name FROM customers');

$customers = array();
while ( $row = fetch_assoc($res) ) {
$customers[$row]['contact_locations'] = array();
$SQL = SELECT *
FROM contact_locations
WHERE c_id={$row['c_id']};
$loc_res = query($SQL);
while ( $loc_row = fetch_assoc($loc_res) ) {
$customers[$row]['contact_locations'][] = $loc_row;
}
}


Now, contained within one array $customers I have all the information 
that would be needed for displaying any type of information related to a 
customer or a customers location.


By doing having this feature, I could build the ability to do xPath 
searches within the base array.  That would be nice.


Anyways, what do you all think?  Worth it or not?

Jim Lucas



Maybe I don't get the new concept, but what would be wrong with:

// START CODE //
$cid = null;
$customers = array();

while ( $row = fetch_assoc($res) ) {

$cid = $row['cid'];
$customers[$cid] = $row;
$customers[$cid]['contact_locations'] = array();

$SQL = SELECT *
FROM contact_locations
WHERE c_id={$cid};

$loc_res = query($SQL);

while ( $loc_row = fetch_assoc($loc_res) ) {
$customers[$cid]['contact_locations'][] = $loc_row;
}

}
// END CODE //

Now you can easily reference all of your customers by ID and get any of 
the data you want.  I would actually just load the record I want from 
the database and not chew up all that memory, but this is just an 
example anyway.


I guess it could allow you to somewhat consolidate a two-dimensional 
array down to a single dimension.  In order to use the data, you'd have 
to use array_keys() or something similar to use it though.


It's an interesting idea, but I don't know how practical it would be.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What's wrong the __autoload()?

2008-03-13 Thread Ray Hauge

Greg Donald wrote:

On 3/12/08, Ray Hauge [EMAIL PROTECTED] wrote:

You
 come to a PHP mailing list to proclaim that RoR is better?


No dumbass, I have already been here for a long time:


This is my last post on this thread.  It's obvious nobody is going to 
convince anyone else of their being right or wrong.  The issue people 
are having is your attitude from about reply #2 from you on this thread. 
 I just wanted to make that point clear.  Trolling and being 
antagonistic doesn't get you anywhere.


The point of this reply is I didn't say anything about how long you've 
been around here.  The fact is you're still here, and we're talking PHP.


I will give you that you weren't the first to submit an opinion of Ruby 
being the best or the worst.  Your first reply was simply open minded, 
but then you got your feathers all ruffled when someone said they didn't 
like Ruby, albeit in a somewhat negative connotation.


 It's people like you that turn a lot of people off to Ruby.

I choose to use a language for a while before forming an opinion.  I
certainly wouldn't let someone's opinion sway my own inquisitive
nature to have a go at it myself.

The reason it turns people off is you have to work with the community as 
well as the language.  If you want the project to get better, you need 
to be able to work with the community.  I will admit that the PHP 
Internals list can get pretty heated as well, but those arguments are 
usually based on technical opinions and not religious fervor for the 
language*.


* Note: I haven't read a whole lot on the Internals list, but based on 
summaries by PHP|Architect and other sources I have assumed my conclusion.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Unexcepted $this

2008-03-13 Thread Ray Hauge

Eric Butera wrote:

2008/3/13 Anup Shukla [EMAIL PROTECTED]:

Murat BEŞER wrote:
  So what do you thing about on this thing ?
 

 I really would like to figure out the problem.
 However, my simple script to mimic your code did not throw any errors.

 If you could provide some more details, maybe we can figure out the problem.

 --
 Regards,
 Anup Shukla



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




It could just be a special character in the code somewhere.  Since
pushing/pulling files happens across so many servers with different
encodings it happens sometimes.  On OSX there is a text editor named
TextWrangler that has a feature called Zap Gremlins that I use to
get rid of it when it happens.


Would it be possible to post the code you have now to http://pastebin.com/ ?

That might assist in locating odd characters if that's the case, though 
I'd think that your editor would display them as well.  Usually an 
Unexpected  means that you missed a parenthesis or curly brace, etc.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] setcookie

2008-03-12 Thread Ray Hauge

Wolf wrote:



Tim Daff wrote:

Hi,

I am learning PHP, I am trying to set a simple cookie:

html
head
titleCookies/title
/head
body
   ?php setcookie('test', 45, time()+(60*60*24*7)); ?
   /body
/html

Firefox is returning this error:

Warning: Cannot modify header information - headers already sent by 
(output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in 
/Users/Daff/Sites/php_sandbox/cookies.php on line 7


I have googled this and can't find out what I am doing wrong.  Any 
help you could give me would be much appreciated.


Tim


 ?php setcookie('test', 45, time()+(60*60*24*7)); ?
 html
 head
 titleCookies/title
 /head
 body



 /body
 /html

Cookies HAVE to be at the top of the page...  You output ANYTHING else 
and you get the error you wound up getting.


Wolf




If you're not sure if data has already been sent to the client (I ran 
into an included file having a space after ?) you can use 
http://us3.php.net/manual/en/function.headers-sent.php before you call 
setcookie();


If nothing else it'll help with diagnosing this error when you run into 
it again.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] A Quick Reminder....

2008-03-12 Thread Ray Hauge

Jason Pruim wrote:


On Mar 12, 2008, at 11:06 AM, Daniel Brown wrote:

On Wed, Mar 12, 2008 at 11:01 AM, TG [EMAIL PROTECTED] 
wrote:
How about something OT that we can argue about...   driving on the 
left side

of the road versus the right side.  How does your country compare?


   Here in Pennsyltucky, a lot of people drive on the left, despite
the fact that the whole US is supposed to drive on the right.  It
usually doesn't turn out very good.  .:shakes head, solemnly:.

   Not very good at all.


Up here in the great big hand (Michigan for those who don't know) during 
the winter we have so much snow on the ground that you just kind of 
drive where ever looks like road... Even if it means you have people 
passing on your right going the opposite way.



--

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






I'm in Fargo, North Dakota (the that's a state? state).  We experience 
very much the same thing.  Especially on the side roads that don't get 
cleared as well.  You just have to make sure that you don't run into 
each other and you're good.


As far as replies, I like bottom posting because it keeps the 
conversation flow more in tact.  GMail does a good job regardless of 
bottom or top posting though.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What's wrong the __autoload()?

2008-03-12 Thread Ray Hauge

Greg Donald wrote:

On 3/12/08, Robert Cummings [EMAIL PROTECTED] wrote:

Just because someone got a flashy new toy doesn't mean I want it. I've
 got better things to do than play with flashy toys for the mere purpose
 of playing with flashy toys. I like to use tools that get jobs done.


Translation: I'm too lazy to learn anything new since I already know PHP.

Languages come and go.  There's a reason why we no longer need a
cgi-bin and Perl to make an animated gif.  Going further, who the hell
even uses animated gifs any more?


Ummm, I originally looked into Ruby and RoR because someone spouted off
 better and easier. After reviewing, looking at the language, trying
 some code, reading other peoples blogs, magazine articles, searching the
 web... I decided, using the brain I've been nurturing since I was a
 fetus, that I preferred PHP.


Great, just so long as we're clear on the point that Ruby is better
than PHP, just not for you personally.  I'm totally fine with leaving
the discussion at the differently preferred opinion level.  Sounds
like a cop-out but I'm ok with your holding that position all the
same.


But then who would confront your rhetoric and propaganda?


I do exhibit a bit of rhetoric at times, but in my defense it came
standard with my inquisitive mind.

Conversely I do not know what propaganda you speak of.  I've never
once made a specific claim in favor of Ruby that I couldn't back up
with example code.


You're assuming that we choose PHP over RoR based on having seen a 5
 minute tutorial. Wow, aren't you just full of assumptions.


Ok then, how many projects did you pursue before giving up and
concluding Rails or Ruby was too much effort to learn?  URL?

I will point out it's probably a good thing this same lack of effort
on your part did not occur when you began to learn PHP, otherwise we
wouldn't even be having this discussion.


Interestingly, laziness is one of the biggest motivators of innovation.
 Do more with less.


Well that sure as hell ain't PHP.  ROFL.  More with less, using PHP, hilarious.

/me points to SPL and laughs his ass off


That SHOULD be part of any developers mandate... but
 not blindly.


If by blindly you mean fun, fast, test-driven, productive development,
then yeah I guess so.




I didn't want to have to do this, but read some of Terry Chay's work on 
Ruby.  There are plenty of people who just prefer PHP to RoR.  Some 
people like Java, some people like .NET, etc.  Get over yourself.  You 
come to a PHP mailing list to proclaim that RoR is better?  What did you 
expect?  It's people like you that turn a lot of people off to Ruby. 
The community is insane!


This was a great read.  If nothing else he's funny.

http://terrychay.com/blog/article/php-ruby-evil-good.shtml

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What's wrong the __autoload()?

2008-03-12 Thread Ray Hauge

Ray Hauge wrote:

Greg Donald wrote:

On 3/12/08, Robert Cummings [EMAIL PROTECTED] wrote:

Just because someone got a flashy new toy doesn't mean I want it. I've
 got better things to do than play with flashy toys for the mere purpose
 of playing with flashy toys. I like to use tools that get jobs done.


Translation: I'm too lazy to learn anything new since I already know PHP.

Languages come and go.  There's a reason why we no longer need a
cgi-bin and Perl to make an animated gif.  Going further, who the hell
even uses animated gifs any more?


Ummm, I originally looked into Ruby and RoR because someone spouted off
 better and easier. After reviewing, looking at the language, trying
 some code, reading other peoples blogs, magazine articles, searching 
the

 web... I decided, using the brain I've been nurturing since I was a
 fetus, that I preferred PHP.


Great, just so long as we're clear on the point that Ruby is better
than PHP, just not for you personally.  I'm totally fine with leaving
the discussion at the differently preferred opinion level.  Sounds
like a cop-out but I'm ok with your holding that position all the
same.


But then who would confront your rhetoric and propaganda?


I do exhibit a bit of rhetoric at times, but in my defense it came
standard with my inquisitive mind.

Conversely I do not know what propaganda you speak of.  I've never
once made a specific claim in favor of Ruby that I couldn't back up
with example code.


You're assuming that we choose PHP over RoR based on having seen a 5
 minute tutorial. Wow, aren't you just full of assumptions.


Ok then, how many projects did you pursue before giving up and
concluding Rails or Ruby was too much effort to learn?  URL?

I will point out it's probably a good thing this same lack of effort
on your part did not occur when you began to learn PHP, otherwise we
wouldn't even be having this discussion.


Interestingly, laziness is one of the biggest motivators of innovation.
 Do more with less.


Well that sure as hell ain't PHP.  ROFL.  More with less, using PHP, 
hilarious.


/me points to SPL and laughs his ass off


That SHOULD be part of any developers mandate... but
 not blindly.


If by blindly you mean fun, fast, test-driven, productive development,
then yeah I guess so.




I didn't want to have to do this, but read some of Terry Chay's work on 
Ruby.  There are plenty of people who just prefer PHP to RoR.  Some 
people like Java, some people like .NET, etc.  Get over yourself.  You 
come to a PHP mailing list to proclaim that RoR is better?  What did you 
expect?  It's people like you that turn a lot of people off to Ruby. The 
community is insane!


This was a great read.  If nothing else he's funny.

http://terrychay.com/blog/article/php-ruby-evil-good.shtml



One last link, because this one is the one that has caused the most 
controversy (for lack of a better word).


http://terrychay.com/blog/article/is-ruby-the-dog-and-php-the-dogfood.shtml

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] CSV speed

2008-03-11 Thread Ray Hauge

Wolf wrote:

Danny Brow wrote:

I have about 10 csv files I need to open to access data. It takes a lot
of time to search each file for the values I need. Would it be best to
just dump all the cvs files to an SQL db and then just grab what I need
from there? I'm starting to think it would make a lot of sense. What do
you guys think?

Thanks,
Dan



Dan,

I can tell you that depending on the size of your files is going to 
dictate the route you want to go.  I have a CSV with 568,000+ lines with 
19 different pieces to each line.  The files are around 180M apiece and 
it takes my server about 2 seconds to run a system grep against the 
files.  I can run a recursive call 7 times against a MySQL database with 
the same information and it takes it about 4 seconds.


IF you have system call ability, a grep wouldn't be bad, otherwise I'd 
suggest loading the csv files into MySQL tables and checking them for 
the information, then dropping the tables when you get the next files. 
You can backup the databases such as a cron job overnight even.


HTH,
Wolf




If you do go the MySQL route, MySQL can import CSV files natively, and 
it'll be a lot faster than doing it through PHP.  Just look up the 
syntax for the LOAD DATA INFILE command... or look here.


http://dev.mysql.com/doc/refman/5.1/en/load-data.html

Here's an example:

LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(field1, filed2, field3);

I've had to do imports of a million or more records from CSV files, and 
PHP is a lot slower than MySQL at importing them :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Unexcepted $this

2008-03-10 Thread Ray Hauge

Murat BEŞER wrote:

I can't under stood but PHP gaves me an error:

UnExcepted $this for  || $this-getFileExtension($file) == 'jpg' 

When I removed jpg extension check it's okay... PHP script runs well.

What is the problem :)

public function loadImages($folder) {
$result = $this-filemanager-fecthFiles($folder);
$images = array();
if (sizeof($result)=1  $result !== false) {
foreach ($result as $file) {
if ($this-getFileExtension($file) == 'gif' || 
$this-getFileExtension($file) == 'png' || 
$this-getFileExtension($file) == 'jpg') {

$images[] = array('name'=$file);
}
}
}
return $images;
}



Try storing the value in a variable first.  It'll also have the 
side-effect of being marginally faster too.


$extension = $this-getFileExtension($file);

if ($extension == 'gif' || $extension || 'png' || $extension == 'jpg') {
// do something
}

That might help, but I would think that the way you had it would also 
work.  Let us know what happens when you use the variable like I showed 
above.


Thanks,
--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Unexcepted $this

2008-03-10 Thread Ray Hauge

Philip Thompson wrote:

On Mar 10, 2008, at 8:32 AM, Ray Hauge wrote:


Murat BEŞER wrote:

I can't under stood but PHP gaves me an error:
UnExcepted $this for  || $this-getFileExtension($file) == 'jpg' 
When I removed jpg extension check it's okay... PHP script runs well.
What is the problem :)
public function loadImages($folder) {
   $result = $this-filemanager-fecthFiles($folder);
   $images = array();
   if (sizeof($result)=1  $result !== false) {
   foreach ($result as $file) {
if ($this-getFileExtension($file) == 'gif' || 
$this-getFileExtension($file) == 'png' || 
$this-getFileExtension($file) == 'jpg') {

   $images[] = array('name'=$file);
   }
   }
   }
   return $images;
   }


Try storing the value in a variable first.  It'll also have the 
side-effect of being marginally faster too.


Good call.



$extension = $this-getFileExtension($file);

if ($extension == 'gif' || $extension || 'png' || $extension == 'jpg') {


Correction:

... $extension == 'png' ...

Personally, I like the in_array() version better - it cleaner and you 
can expand upon it more more easily.


$extensions = array('gif, 'png', 'jpg' [, 'm4a'[, 'etc']]);
if (in_array($extension, $extensions)) { ... }



// do something
}

That might help, but I would think that the way you had it would also 
work.  Let us know what happens when you use the variable like I 
showed above.


Thanks,
--
Ray Hauge



HTH,
~Philip

Personally, most of my web applications do not have to factor 13.7 
billion years of space drift in to the calculations, so PHP's rand 
function has been great for me... ~S. Johnson





Thanks for the catch.  I work from home and I hadn't had my coffee yet 
in the morning.  I usually check my news and email right after I get up 
and before I go to  work :)


I have been starting to use in_array more often as well.  Far too many 
times I'll have to go back and add more options later, then the IF 
statement gets huge.  Someday I'll kick the habit for good though.


Oh, it might also be a bit easier to store the acceptable extensions in 
an array before the IF statement


$ext = $this-getFileExtension($file);
$acceptableExtensions = array('png', 'gif', 'jpg');

if ( in_array($ext, $acceptableExtensions) ) {
// do something
}

That way the conditional doesn't grow as more and more values get added.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] SMTP

2008-03-09 Thread Ray Hauge

Alain Roger wrote:

Hi,

i know that this is not necessary the best forum for that, but i need to get
a real feedback and i guess you already faced the same issue as mine.
basically, i develop php web application on windows XP platform.
So i have apache 2.24 installed and PHP 5.2.4.

now i would like to test if my application send emails, so i've checked my
php.ini file and it seems ok.
i tried to use IIS from windows to define a default SMTP server, but as my
emails are not sent, i guess something is wrong with IIS.

so does it exist a free SMTP server (similar that linux daemon) but running
on windows XP ?
if yes, where can i find it and what steps should i perform to be sure my
emails are sent ?

i do not want to transfer all my web application each time i want to test
email sending...
i would like to test it locally.

thanks for your feedback.



I could be wrong, but I thought that you had to specify the SMTP server 
in the php.ini file.


http://us2.php.net/manual/en/ref.mail.php#ini.smtp

 now i would like to test if my application send emails, so i've 
checked my

 php.ini file and it seems ok.

Maybe that means you already did that.  The second issue might be that 
your SMTP server is MS Exchange, and it requires authentication.


If that is the case, then search for php SMTP authentication:

http://www.google.com/search?q=php+smtp+authenticationie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-a

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] CVS Scripts

2008-03-06 Thread Ray Hauge

Eric Butera wrote:

On Thu, Mar 6, 2008 at 10:58 AM, Adrian Walls [EMAIL PROTECTED] wrote:

Firstly thanks for a sensible reply.

 I am using Zend Studio Server and I haven't upgraded to Zend Studio for
 Eclipse as yet.  It also has some CVS capability not its not what I am
 after.

 Google was my first stop but it didn't turn up anything which appeared to be
 in a stable enough state.  Hence my email to the list to see if anyone else
 had come across such a solution.  My application is built from several
 modules contained with cvs.  Some of these modules are used across projects.
 I wanted to create my own web-based script to check these out of cvs and to
 build and configure the application on the fly.

 I had a look at cruisecontrol but its not really what I am looking for
 either.

 Adrian.






 -Original Message-
 From: Wolf [mailto:[EMAIL PROTECTED]


Sent: 06 March 2008 15:42
 To: Adrian Walls
 Cc: 'Eric Butera'; php-general@lists.php.net
 Subject: RE: [PHP] CVS Scripts

  Adrian Walls [EMAIL PROTECTED] wrote:
  1. It is a legal thing, whether it means anything or not or regardless of
  what anyone else's take is on it.
 
  2. It was a straight forward question I asked.  I guess it was my mistake
  for thinking this was a place to ask questions rather than somewhere to
 take
  the p*ss.  I'll not make the same mistake again.
 
 !-- SNIP --

 We're a bunch of helpful and flippant sods on this list, so take the
 criticism as constructive (trim your own sig file down and remove the white
 space and see if you can NOT send the confidentiality notices when broadcast
 mailing).

 As for automatic CVS via PHP, it depends on your take on it...

 Eclipse has a CVS piece to it which seems to work well (I've installed it,
 but most of my stuff is layered and I don't have a reason for CVS), though
 someone also posted about cruisecontrol on the sourceforge site.

 What have you found and tried via a google search?

 Wolf




Maybe look at Phing[1]?  Skimming over the docs (I know you said you
use CVS) I saw a task you can define to check files out form SVN.
There might be a cvs one somewhere or you could extend it and write
your own.

[1] http://phing.info/



Another option would be to write your own.  If your requirements are 
super specific, then that might be the best route.  I can't imagine it 
would be too difficult.


You can use shell_exec to execute the CVS checkout, and any other CVS 
command necessary.  Don't forget to use escapeshellcmd() either:


http://us3.php.net/manual/en/function.escapeshellcmd.php

After it's checked out, then you can use shell_exec() again to run the 
compile command.  If it takes a long time, you might be best just 
sending the command to the output so you can copy and paste and run it 
yourself, or just make sure you set_time_limit(0), or some amount of 
time it should finish compiling in.


I assume it's an internal app, so you wouldn't have to worry too much 
about it looking pretty or any of the other time consuming operations.


?php

//
// NOTE: Paths are for Linux. Change for Windows as necessary
//

$cmd = escapeshellcmd('/usr/bin/cvs -d :ext:[EMAIL PROTECTED]:/.../cvsroot 
checkout module');


$output = shell_exec($cmd);

// do something with output if you need

$cmd = escapeshellcmd('/path/to/module/configure');

$output = shell_exec($cmd);

echo done!;

?

Something like that anyway.  That's overly simplified of course, but it 
should get you a start if you want to write it yourself.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] CVS Scripts

2008-03-06 Thread Ray Hauge

Wolf wrote:

I am using Zend Studio Server and I haven't upgraded to Zend Studio for
Eclipse as yet.  It also has some CVS capability not its not what I am
after.  


Google was my first stop but it didn't turn up anything which appeared to be
in a stable enough state.  Hence my email to the list to see if anyone else
had come across such a solution.  My application is built from several
modules contained with cvs.  Some of these modules are used across projects.
I wanted to create my own web-based script to check these out of cvs and to
build and configure the application on the fly.

I had a look at cruisecontrol but its not really what I am looking for
either.

!-- SNIP --

You're probably going to have to code that sucker on your own and slide it in 
as a cron job on your build server to get the latest/greatest whenever needed.  
I haven't come across anything like it before, but I definitely like the 
concept.

Wolf



I had an idea to tie a ticket system with SVN.  Each ticket would be 
associated to a change in the code.  In the ticket system you put in the 
different revisions that were checked in for that ticket.  Then when you 
go to promote the ticket for testing, it'll check and make sure that 
there were no conflicting changes and merge it if possible to the next 
branch.  The details are a little fuzzy after a few months of not 
thinking about it.  The XML output from SVN would come in quite handy at 
that point though.


It would have been cool, but it would have been complicated.  We didn't 
have the time to work on it.  I think Trac is somewhat similar.


PS. sorry for the thread hijack :)

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Re: Transferring files between computers using php

2008-03-06 Thread Ray Hauge

Rahul wrote:

Zareef Ahmed wrote:

On 3/7/08, Rahul [EMAIL PROTECTED] wrote:

Thank you all so much for replying... I guess I was very vague in
describing the situation. I will write in detail:

I have three computers A, B and C. To login to B and C I should use A
because it has a SSH key. I don't have any other way of accessing these
two computers. Now, if I need to transfer a file between B and C, I am
unable to find a way that would work... because I don't know how to
authenticate without SSH keys... I was gathering some data in B and C
using PHP. Now, I need these two computers to coordinate a little and
didn't want to use a server in between and so I was thinking of
establishing a direct connection between them..



If you have ruled out web server and ssh, then you can use ftp using 
PHP or

use NFS mounting.




Zareef Ahmed wrote:

On 3/7/08, Shawn McKenzie [EMAIL PROTECTED] wrote:

Rahul wrote:

I have a small file to be transferred between two computers every few
seconds. I'm using unix with a bare bones version of php, i.e. just

the

original thing that gets installed when I run yum install php. As

there is

no webserver on any of these machines, I was wondering if there is a

way

to

transfer a small file between them and if there is, could someone be

kind

enough to provide me with an example please?

Thank You



FYI...  If you're using yum I assume it's a Linux machine (maybe

Fedora)

and not Unix.



If you want to use rsync and scp in a cronjob (for continuous transfer

at a

predefined interval), you may need to set your server (read ssh) to

accept

connection without password.
Ref : http://linuxproblem.org/art_9.html

BUT If you really want to do that from PHP, you can install a web 
server

and

enable http as your stream for opening files. (In php.ini)
 You can read the file using fopen or any other file functions, then 
can

write that file to the server on which script will be running, then you

can

set this script as your cron job.

For example :

$filecontents=file_get_contents(http://firstserver/file.txt;);

$fp=fopen(path to local file, mode);

Now use $fiiecontents to write the file using $fp resource.

BUT remember, using rsync is always a better solution, and

file_get_contents
and file functions are resource hungry, specially they will consume 
more

memory of your system.



--

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





Well I haven't ruled our webserver and ssh but I don't have much 
options. Number 1 is that I have many such computers and I don't think I 
can afford to install a webserver on all of them atleast. And coming to 
SSH, I can't use it because of the scenario that I explained. Please let 
me know if you have any other advice.


Thank You



I second the NFS mounting.  You can share a directory somewhere on 
computer A.  Then computers B and C connect to it.  That way with PHP 
you just copy the file to the shares, and computers B and C 
automatically see the file there.  Outside of that FTP might work well 
for you.  Maybe even SCP, since you already have the keys on server A 
(as long as you don't have a password when connecting to B or C).  rsync 
can work over SSH as well, and you could create a simple script to run 
rsync as often as you need.


haha, I guess that's not exactly seconding NFS, more seconding not 
transferring files over HTTP.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Preserving URL after redirect?

2008-03-05 Thread Ray Hauge

Richard Heyes wrote:
So, my question is how would I do that, and I strongly suspect if it's 
possible at all an .htaccess file with the proper entries would be the 
way to do it, not using PHP code to redirect as I am now.


Is this the case?


You would need to use mod_rewrite.



You might also be able to get this to work by changing the include_path 
and creating a special loader script in their folder.


define('INCLUDE_PATH', 'YOUR PATH HERE');

ini_set(include_path, INCLUDE_PATH);

That way the application includes would still work if you didn't specify 
 absolute paths...


I have a few scripts that use the include_path, and they look something 
like:


?php

require_once(../../set_include_path.php);

require_once(includes/utils/format.php);
require_once(includes/utils/ui.php);
//etc.

?

That way I just have the initial call to set the include path, and I 
don't have to worry about it anymore.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Anyone jump from Studio 5.5.x - Zend Eclipse?

2008-03-02 Thread Ray Hauge

Steve Finkelstein wrote:

Hi all,

I've tried googling around to find some blogs with decent information
on whether Zend Eclipse is mature enough to make the jump over from
5.5.x just yet.

Admittedly, I've dropped Zend Studio as of late and been writing all
of my code in TextMate -- but at the end of the day when a project is
complex enough, Zend Studio is much more powerful than TextMate with
all of its features and remote debugging capabilities.

Anyhow, I'm curious if it's worth it to check out Zend Eclipse yet.
We're a team of about 5-6 developers and I've been getting asked by a
few colleagues if I've tried it out yet since I'm usually the one to
try out the newer technologies.

I'd love to hear some feedback.

Thanks!

/sf



I've recently switched.  On my machine (which hasn't been updated for a 
long time...) Eclipse runs a lot slower.  I only have 1 GB of RAM.  Zend 
Studio has been running faster for me after I turned off the SVN 
integration.  I just use the CLI for SVN anyway.


Sometimes in Eclipse it'll slow down so much that I have to slow down my 
typing.  Mostly that's in CSS files.  I don't know if it's Eclipse in 
general, but Shift+Tab rarely works, and it drives me nuts.  I've tried 
to mess with the key bindings to no avail.  Debugging is a lot slower in 
Eclipse.  Some of the default key bindings in Zend Studio are different 
in Zend Eclipse as well, but that was somewhat expected and hasn't 
bothered me too much.


I've been using the official Zend Eclipse now since the day it came out. 
  Next week I'm going to switch back to regular Zend Studio.  It was 
nicer on the RAM and for the most part Just Worked(TM).


That's my experience.  I'd be interested to hear other people's experiences.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] auto-wrap on posts

2008-02-29 Thread Ray Hauge

Zoltán Németh wrote:

2008. 02. 28, csütörtök keltezéssel 10.38-kor Nathan Nobbe ezt írta:

On Thu, Feb 28, 2008 at 10:35 AM, David Giragosian [EMAIL PROTECTED]
wrote:


On 2/28/08, Nathan Nobbe [EMAIL PROTECTED] wrote:

take a look here on the marc archives.
http://marc.info/?l=php-generalm=120415418217911w=2

there are several lines that have 1 word only in them, some of the words
(for reference) are access, good, patterns, nested.
when i wrote the post (looking in my gmail client) these words are not

on

their own line..
does the post look as it does on marc in your mail clients or are the

words

in sentences where they belong ?

thanks,

-nathan


Your emails come through to my gmail account as you first described,
Nathan, ie, sometimes with just one word on a line, and just like the
marc archives.


thanks, ill just have to be careful editing from gmail then..

Ray, if I start a thread, I'm fairly sure the list sends the email back to

me.


i dont get an email back until someone replies.


that must be a gmail thing, I get everything back

greets,
Zoltán Németh


-nathan





Yeah, it is a gmail thing.  They archive the message you send, so if you 
were using the gmail client, you'd see your response.  The FAQs say that 
it'll send your message through IMAP/POP if someone replies to your 
message, but gmail doesn't do nested threads, so I think it doesn't know 
all the time when you were replied to.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Weird Results from Curl

2008-02-29 Thread Ray Hauge

Wolf wrote:
 Ray Hauge [EMAIL PROTECTED] wrote: 

Wolf wrote:

I'm curling a site to process some data, all well and good but the results are 
baffling...

$result = curl_exec($ch);
curl_close($ch);
echo HR.gettype ($result);

Of course that's not all the code, but the results contain:
-
0 11
0 1
1 1
1 11
5 An Error Has Occurred During Processing.
Error: An Error occured .
A message has been sent to the System Administrator with the details of the 
problem you have encountered. 1


What I can't seem to figure out is what the result type actually is and how to pull just 
the first piece (0,1,etc) out of the 0 11 that gets returned.

I have tried to do a strlen conversion, that failed.  I've tried bool 
converting but it doesn't come across right either.

Any ideas?

Thanks!
Wolf


It sounds like the error message is being returned from the remote server.

Is gettype() outputting the numbers, or is that part of the output from 
curl?  gettype should be returning a string, so I wouldn't think that 
gettype would be returning the numbers.


Are you using the CURLOPT_RETURNTRANSFER option?  If so, then $result 
would have the text of the site on success, and false on error.


OK, I probably wasn't clear...

The results from the server (0 11, 1 11, 0 1, 1 1, 5 Error 1, etc) are what 
I expect them to be, however I can't pull them out.

*grumble*

I forgot that I commented out the CURLOPT_RETURNTRANSFER line!  UGH!

Thanks!

Wolf


CURLOPT_RETURNTRANSFER has gotten me a few times.  The default of just 
outputting the information directly to the browser always seemed a bit 
odd to me.  Maybe that's just because I've only used it for scraping and 
reading data.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Weird Results from Curl

2008-02-29 Thread Ray Hauge

Wolf wrote:

I'm curling a site to process some data, all well and good but the results are 
baffling...

$result = curl_exec($ch);
curl_close($ch);
echo HR.gettype ($result);

Of course that's not all the code, but the results contain:
-
0 11
0 1
1 1
1 11
5 An Error Has Occurred During Processing.
Error: An Error occured .
A message has been sent to the System Administrator with the details of the 
problem you have encountered. 1


What I can't seem to figure out is what the result type actually is and how to pull just 
the first piece (0,1,etc) out of the 0 11 that gets returned.

I have tried to do a strlen conversion, that failed.  I've tried bool 
converting but it doesn't come across right either.

Any ideas?

Thanks!
Wolf



It sounds like the error message is being returned from the remote server.

Is gettype() outputting the numbers, or is that part of the output from 
curl?  gettype should be returning a string, so I wouldn't think that 
gettype would be returning the numbers.


Are you using the CURLOPT_RETURNTRANSFER option?  If so, then $result 
would have the text of the site on success, and false on error.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What design patterns do you usually use?

2008-02-29 Thread Ray Hauge

Zoltán Németh wrote:

2008. 02. 29, péntek keltezéssel 14.28-kor tedd ezt írta:

At 4:36 PM +0100 2/29/08, Zoltán Németh wrote:

sure, all information belonging to an object is usually in a record of a
db.
but, you mean include('user_functions.php') automatically loads that
data? based on what? a global $user_id variable? if so, I would consider
that poor design...
Whoa there, you don't know what it's doing -- so 
saying poor design is probably not a good call.



  And thus, two lines instead of three.

 But in fairness, the user_functions.php would
 establish a connection to the database and the
 function set_user_name($user, 'tedd') would
 simply use 'tedd' with respect to whatever
 $user is.

hmm that means you use only one user's info in the script. that's very
limiting.

Again, you don't know what's being called.

No reason to be insulting. What I am calling 
could be a pointer or an id to a record -- BOTH 
-- of which are no more limited than calling a 
class. What do you think languages are doing when 
they call segments of memory for data or function 
-- you think they pass ton's of variables or just 
a pointer? So, there's nothing limited here about 
what I'm doing. Think about it.



hey, no insult intended here... sorry if seemed so.
but, my point was exactly what you stated above. you say 'you don't know
what's being called' - that's the main problem I found with non-oop code
organization. with clearly defined classes every developer knows what he
calls without further explanation.


sure you can duplicate with procedural code anything my tons of classes
do... but above a certain project size it can easily become a
maintenance nightmare and an integration nightmare if there are more
than one developers. classes enforce some strict rules to everyone in
the team, so teamwork is much more efficient and the resulting codebase
is cleaner. I know from experience, as this project with the 400K lines
is a rewrite of the previous procedural version, which was developed and
maintained by a dozen of developers over the years, and it became such a
mess that none of us wants to touch it anymore...
Again -- the difference here is organizational 
style. Everything you can do in your classes I 
can do in my functions. Plus, you can have just 
the same amount of screw-ups as I can when you 
introduce more than one programmer and his style 
into the mix.


I don't like the tone here -- it appears that 
because I'm not agreeing with you that my code is 
limited or of poor design -- because let me 
assure you it's not!


So, let's just drop this -- you have your way and I have mine.


again, sorry for the tone if it was wrong - might be because I'm not a
native english speaker, or maybe because this is one of the craziest
fridays ever, I don't know. for sure, I didn't mean it.

and yes, let's drop this, I see I can't convince you.
anyway, I'm not an oop zealot, I just find it so useful and I tried to
explain my view of it - with absolutely no offense intended - so, happy
coding for you with your style and me with mine :)

greets,
Zoltán Németh


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com





Aww man, I was getting curious to see how nested this conversation would 
get.  Think of the children! :)


PS. Happy Friday!!!

PPS. I'm hopped up on caffeine so ignore any stupid remarks.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] ZCE guidance needed

2008-02-28 Thread Ray Hauge

Nathan Nobbe wrote:

On Wed, Feb 27, 2008 at 10:31 PM, Shelley [EMAIL PROTECTED] wrote:


Greetings all,

Im just need some guidance of how to prepare for the ZCE exam.

Is there somebody passed the exam? Any help infor is highly appreciated.



i read the php architect book and paid for 5 of their sample tests.
http://www.phparch.com/c/books/id/0973862149
some of the questions on the test are really obscure, not really like
about the language as much as the set of functions that ship w/ it.
they try and trip you up, like asking very specific questions about
some of the functions and so forth.
good news is a low score still makes the passing grade ;)

-nathan



Same here.  I read the practice book and took the Vulcan training tests.

http://www.phparch.com/c/product/vulcan/view

My work paid for an online training that got me both of them for free, 
so I used them.  The hardest part for me was just setting a date and 
stop procrastinating.  The test was easier than I was expecting, though 
there were a few things that I didn't know on there.  The tests were my 
best training though.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] ZCE guidance needed

2008-02-28 Thread Ray Hauge

Nathan Nobbe wrote:

On Wed, Feb 27, 2008 at 10:31 PM, Shelley [EMAIL PROTECTED] wrote:


Greetings all,

Im just need some guidance of how to prepare for the ZCE exam.

Is there somebody passed the exam? Any help infor is highly appreciated.



i read the php architect book and paid for 5 of their sample tests.
http://www.phparch.com/c/books/id/0973862149
some of the questions on the test are really obscure, not really like
about the language as much as the set of functions that ship w/ it.
they try and trip you up, like asking very specific questions about
some of the functions and so forth.
good news is a low score still makes the passing grade ;)

-nathan



My SMTP server didn't like my login for a few minutes, so hopefully I 
don't double-post this.


I used the book and the Vulcan Training tests as well.  I think I got 
more out of the tests than the book, but that's just me.


There were a lot of odd functions in there.  I can't even remember the 
ones that I didn't even know existed.  There were also questions about 
how to configure PHP, so look at the php.ini options as well.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] auto-wrap on posts

2008-02-28 Thread Ray Hauge

Nathan Nobbe wrote:

all,

a fellow poster has been kind enough to bring to my attention how jacked
some of my posts appear.
i was manually formatting my posts, but it appears the list server must also
be doing some formatting as many of my posts come out all jacked up looking,
some with only a single word on a line.
ive now resolved to just keep on typing all the way to the end of a line in
the gmail editor, but then they look like crap in the editor; though ill do
it to save face for the public postings if i have to ;)
any body else encounter this ?

-nathan



I haven't noticed any issues with your posts either.

Since we're talking about post issues I'll include this.  I don't seem 
to receive my own emails.  Does the list not send them back to you?  I 
haven't been able to find anything yet.  I just like to see all the 
comments.


Is it the list, or is it Thunderbird/Gmail (I use IMAP forwarding).

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] auto-wrap on posts

2008-02-28 Thread Ray Hauge

Daniel Brown wrote:

On Thu, Feb 28, 2008 at 10:25 AM, Ray Hauge [EMAIL PROTECTED] wrote:

 Since we're talking about post issues I'll include this.  I don't seem
 to receive my own emails.  Does the list not send them back to you?  I
 haven't been able to find anything yet.  I just like to see all the
 comments.


It's intelligent design on Gmail's part.  If you send an email to
a list, Gmail filters the message sent back to you so that it doesn't
appear in your inbox until someone replies to the thread.  The
exception is if a bounce is received.



That makes complete sense.  GMail stores my sent message and if I was 
reading it on GMail I'd see my sent message.  I'll have to see if 
there's any way I can change that at the GMail level.


Thanks for the help.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] echo returnArray()['a']; // workaround

2008-02-28 Thread Ray Hauge

Nathan Nobbe wrote:

all,

as we have discussed previously, php does not have support for retrieving
array values on the same line in which they are returned.  i have created a
simple workaround, and would like to share.  first there is the class (w/
other features omitted for the post)
?php
class ArrayClass {
private $theArray = null;

private function __construct($theArray) {
if(!is_array($theArray)) {
throw UnexpectedValueException('theArray must be an array!');
}
$this-theArray = $theArray;
}

public static function create($theArray) {
return new ArrayClass($theArray);
}

public function __get($name) {
if($this-isValidKey($name)) {
return $this-theArray[$name];
}
}

private function isValidKey($name) {
$isValidKey = false;
if(array_key_exists($name, $this-theArray)) {
$isValidKey = true;
}
return $isValidKey;
}
}
?

and then there is the example,

?php
include('ArrayClass.php');

function sillyFunc() {
return array('a' = 1, 'b' = 2, 'c' = 3, 'd' = 4);
}

echo ArrayClass::create(sillyFunc())-a . PHP_EOL;
?

notice what would be

echo sillyFunc()['a'] . PHP_EOL;

becomes what you see above.

-nathan

ps.  sorry for all the extra newlines; im trying to work w/ the alterations
the list server is applying to my posts so bear w/ me :D



That's pretty cool.  I wasn't sure if it would work with numerically 
indexed arrays, so I tried:


// sillyFunc returns array(0=1, 1=2);

ArrayClass::create(sillyFunc())-{0}

I just tested it, and that works.  If you leave off the curly braces and 
quotes, then you obviously get a parse error.  The curly braces are 
necessary.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Sometimes I wonder why I even started programming...

2008-02-28 Thread Ray Hauge

Nathan Rixham wrote:

[snip]
Eric Butera wrote:

I can hit tab and shift/tab too and it puts in spaces for me.

[snip]
Robert Cummings wrote:
  Uhhhm, I hit the tab button also and it does the right thing (namely
  inserts 4 spaces). Also, when I hit enter it auto tabs.
[snip]

*kicks zend studio* [and nano and textpad and dreamweaver] :(

what ide's editor's do you two use? zend's use of javaw is killing my 
win2k3 dev machine anyways.




Zend Studio can be configured to use spaces.  Nano/Eclipse can as well. 
 I've been using Nano recently, and I think I liked Zend Studio better. 
 Maybe it's just me, but Eclipse is a memory hog... even worse than 
Zend Studio.  I've also been having problems with Shift+Tab not working, 
or working only on certain types of files.  Those are the only two 
gripes I have though.


Other than that I use vim/gvim (you can get gvim for Windows) or Kate. 
I've tried Quanta as well, but I use Linux for my desktop.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Sessions

2008-02-28 Thread Ray Hauge

VamVan wrote:

Hello People,

I wanted to have your assistance in deciding few things here,
basically I want to auto populate a registration form for people
visiting second time or so on.

I have already started a session,I know that session is a cookie so is
it better to rely upon the session cookie for auto populating or
create another cookie on client side.

If i am not mistaken ini_set('session.gc_maxlifetime', 3600);
increases the time session cookie expiration time to 1 hr  right.

Please give me ur suggestions on this. if some one has a working code
can you please share?

Thanks,
V



In the example you provide it would be best to use a regular cookie. 
Sessions are destroyed and garbage collected quite regularly, so you can 
only count on the data being available while they are using your 
application (during their session).  With cookies you can specify an 
expires date so that the information will be available tomorrow, next 
week, etc.


You *could* increase the session cookie lifetime, but I wouldn't count 
on the data being available through a session, especially if they close 
their browser.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Ray Hauge

Richard Heyes wrote:

What design patterns do you usually use?


Whatever solves the problem. Factory is quite a common one. MVC is another.



I have a story to kind of touch on what Jochem said about you just don't 
know the name yet.


Just recently I was tasked with creating a new in-house CRM for an 
external partner.  I only had four days and they had particular 
requirements that ruled out Sugar or other things.  I had never really 
understood what the MVC pattern really was.  I knew the basics, but I 
just didn't get it.  After I finished the first wave of development on 
this project I finally had a chance to sit back and see the forest 
through the trees and sat back and thought damn... I just used MVC.


If you're willing to shell out a few bucks, there's a pretty good book 
on design patterns for PHP.  http://www.phparch.com/c/books/id/0973589825


You can think of design patterns more like classes you use with your 
code.  They can help you achieve a goal, but they're not going to do 
everything for you.  Maybe an even better analogy would be a really 
expensive set of knives.  They're super sharp, so make sure you know 
what you're doing with them before you use them.


There is also such a thing as too much.  I heard a talk a while ago 
about code maintainability.  The speaker mentioned a co-worker of his 
ran into his cube almost exhausted and proclaimed, I finally did it!. 
I used every one of the design patterns in my program!  Just a few 
months later the speaker ended up being in charge of maintaining that 
program, and it was a nightmare.


To make a long story short.  I generally do what's easiest.  It's 
typically faster to develop and easier to maintain.  Unnecessary 
complexity can start a snowball effect.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] What design patterns do you usually use?

2008-02-27 Thread Ray Hauge

Robert Cummings wrote:

On Wed, 2008-02-27 at 15:53 +0100, Jochem Maas wrote:

Paul Scott schreef:

On Wed, 2008-02-27 at 14:48 +0100, Jochem Maas wrote:

Paul Scott schreef:
there seems to be some misunderstanding ... a design pattern is not
a component (or anything else of substance) but merely a conceptual
strategy used to tackle a problem ... ever find yourself writing code
that's conceptually identical to previously written code (in a different
site/project/context), if so you've got yourself a pattern and as such it's
probably been documented as an 'official' design pattern with suitable fancy
name (something like 'Observer', 'Delegator', 'Factory')

chances are then that you're already using design patterns - it's just
that you don't know them by name :-)


Ja, that's what I was trying to say in a long, convoluted,
burning-the-candle-at-both-ends type of way :)

lol ... I often have the same problem ... then Richard Lynch comes along
and explains 'whatever' in a way that the rest of the world does understand :-)


Surely he didn't explain OOP to you... he's anti OOP :)

Cheers,
Rob.


You're right.  I just started reading this list again after a 1.5 year 
break, and I still remember some of the great discussions with Richard 
and others about OOP.  Great times :)


--
Ray Hauge
www.primateapplications.com

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



[PHP] Database Abstraction Idea

2008-02-27 Thread Ray Hauge
I've been working on a project that was started from scratch.  I'm a 
minimalist, so I like to keep things as simple as possible.  I've been 
using this idea for a database abstraction, and I thought I'd see if I 
could get some constructive criticism.


Here is an example of how I use this first:

$table = 'customers';

// validation is handled before this
// the class also uses PDO, so escaping isn't a problem
$id = $_CLEAN['customer_id'];

$customer = DB::loadRecord($table, $id);

echo $customer-first_name; // Bob
echo $customer-last_name; // Jones

// etc.

$customer-first_name = 'Robert';

try {
DB::updateRecord($table, $customer)
} catch (e) {
// handle error
}

# END CODE 

There are other methods as well.  I used a static class to kind of 
simulate a namespace.  The database connection is handled elsewhere.  I 
didn't want to make a singleton and have to pass it around within 
functions and stuff.


The methods are:

query_result query($sql) // for complicated reports mostly

DBRecord loadRecord($table, $id, $fields = null) // fields can be an 
array of fields you want back.  It always gives you an ID though


bool updateRecord($table, DBRecord $record)

DBRecord newRecord($table) // returns a blank record that can be 
inserted later


bool insertRecord($table, DBRecord $record)

query_result find($table, $whereField, $whereOperator, $whereValue)
// whereOperator is basically an Enum

getFieldInfo($table, $field)
// returns the fetch_object of SHOW COLUMNS FROM $table LIKE $field
// For maxlength and other things in my UI class.

The DBRecord is basically the object representation of the table and 
doesn't have to be all the fields.  Example is


tableName-columnName

I'm pretty happy with how it's working now, but I'm concerned I might 
have misses some sort of security issue.  I only had a work week to 
finish the entire project.  We only have MySQL databases, so I didn't 
need to abstract different types of databases or anything.


Thanks,
--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Database Abstraction Idea

2008-02-27 Thread Ray Hauge

Daniel Brown wrote:

Should catch(e) really be catch(Exception $e) ?


Something like that.  I was paraphrasing, which seems weird, since I was 
looking at the code for the class description anyway :)  Thanks for the 
info.


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Are these Truthful Proof about PHP ??

2008-02-27 Thread Ray Hauge

Nathan Nobbe wrote:

On Wed, Feb 27, 2008 at 2:14 PM, Robert Cummings [EMAIL PROTECTED]
wrote:


RoR is a framework, not a language. I also save crapload of typing by
using my InterJinn framework. Ruby as a language doesn't float my boat.



where were you in the big ruby stand-off a couple weeks back ? :D

-nathan



I can't help but send along some words from Terry Chay.  I don't know if 
his comments on Ruby were brought up last time (I promise I'll search 
next time), but these are great even if it's just for a good laugh and 
you don't agree with him.


http://terrychay.com/blog/article/mephisto-ruby.shtml

http://terrychay.com/blog/article/is-ruby-the-dog-and-php-the-dogfood.shtml

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Guidance

2008-02-27 Thread Ray Hauge

Matty Sarro wrote:

I understand and agree completely, and I really appreciate the help. My goal
isn't so much to keep from re-writing code, but to have a pretty firm
foundation to stand on before I really begin. I mean, with c++ or c, all I
needed was the language, and that was pretty much it. I could do everything
from there. This seems a lot more like its a marriage of a ton of different
technologies :)

On Wed, Feb 27, 2008 at 3:32 PM, Daniel Brown [EMAIL PROTECTED] wrote:


On Wed, Feb 27, 2008 at 3:01 PM, Stut [EMAIL PROTECTED] wrote:

 Maybe it's just me but I usually end up rewriting everything I write
 at least twice. That's just a fact of life and I've found that I end
 up with far better code that way than I do by trying to get it right
 first time. It also tends to be quicker.

[snip!]

 In short, learn by doing. It's served me well.

   I made it even shorter, Stut.  ;-P

   He's exactly right, Matty.  It's a form of evolution called
versioning.  No programmer gets everything perfect the first (or
usually even second, third, eighth) time.  Good, usable, lasting code
will be written and rewritten very often.  Look at almost any code
that's been around and distributed (including the PHP project itself)
and you'll notice that there are dozens of versions, because over the
years new ideas have come about to make it more productive, more
economical, and all-around better.

--
/Dan

Daniel P. Brown
Senior Unix Geek
? while(1) { $me = $mind--; sleep(86400); } ?





My suggestion is to write a throw-away app. That way you can learn 
everything you need to, but it doesn't matter if it's not perfect.  I 
did the same thing just recently while learning C#.  I made an XML 
editor just so I could learn the nuances of the language.


Also, don't forget CSS.  It comes in really handy.  I still use 
w3cschools to look up the property names I can't remember, but it's got 
a lot of great resources to point you in the right direction.


http://www.w3schools.com/

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Performance Problem

2008-02-27 Thread Ray Hauge

Adriano Manocchia wrote:
Whoa. No need to get snippy. I was being sincere in my gratitude for the 
suggestions. If nothing else, I'm sure I'll be making more use of Xdebug 
in the future.


On Feb 27, 2008, at 3:55 PM, Shawn McKenzie wrote:


Adriano Manocchia wrote:

Well, I just spent more time messing with httpd's conf and it the
problem seems to have resolved itself by turning off hostname lookups. I
know there's overhead associated with it, but I don't really understand
why it only affected PHP, and so drastically. At any rate, I guess this
issue is solved. Thanks for the help.

Adriano


Yes, we all knew exactly what your problem was.  Sorry we didn't post
quicker ;-)

-Shawn

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



He was messing with you if you couldn't tell.  I'm not sure if you're 
just messing back, but it was at least interesting for me to read the 
progression of events and learn a little bit myself :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Sometimes I wonder why I even started programming...

2008-02-27 Thread Ray Hauge

Jason Pruim wrote:
So I was supposed to go home a half hour ago but that didn't happen... I 
hate deadlines! :P


Can someone tell me why this code works for setting the table name:

function authentication($user, $pass, $authenticated, $table){
   
// Keep in mind, PASSWORD has meaning in MySQL

// Do your string sanitizing here
// (e.g. - $user = mysql_real_escape_string($_POST['user']);)
$salt = salt;
$salt1 = $salt;
$salt1 .= $pass;

$password = md5($salt1);
$loginQuery = SELECT * FROM current WHERE 
loginName='.$user.' AND loginPassword='.$password.' LIMIT 0,1;;
$loginResult = mysql_query($loginQuery) or die(Wrong data 
supplied or database error  .mysql_error());

while($row1 = mysql_fetch_array($loginResult)) {
$_SESSION['user'] = $row1['loginName'];
$_SESSION['loggedin'] = YES;
$authenticated = true;
$_SESSION['table'] = $row1['tableName'];
   
}

return $table;
return $authenticated;
}   


But this code doesn't:

 function authentication($user, $pass, $authenticated, $table){
   
// Keep in mind, PASSWORD has meaning in MySQL

// Do your string sanitizing here
// (e.g. - $user = mysql_real_escape_string($_POST['user']);)
$salt = salt;
$salt1 = $salt;
$salt1 .= $pass;

$password = md5($salt1);
$loginQuery = SELECT * FROM current WHERE 
loginName='.$user.' AND loginPassword='.$password.' LIMIT 0,1;;
$loginResult = mysql_query($loginQuery) or die(Wrong data 
supplied or database error  .mysql_error());

while($row1 = mysql_fetch_array($loginResult)) {
$_SESSION['user'] = $row1['loginName'];
$_SESSION['loggedin'] = YES;
$authenticated = true;
$table = $row1['tableName'];
   
}

return $table;
return $authenticated;
}\


the query that I'm using is simply this: $query = SELECT * FROM 
.$_SESSION['table']. order by .$sortOrder.;


Or this: $query = SELECT * FROM .$table. order by .$sortOrder.;

Depending on if you use the working or the non-working code :)

Any ideas?

--

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






The only difference I'm seeing is you're assigning the 
$row1['tableName'] to $table rather than $_SESSION['table'].  Is that 
intended?  $table isn't defined in the top function, so it would most 
likely return null.


Also, since you're only expecting one result, you could do away with the 
 while loop and just run $row1 = mysql_fetch_array($loginResult). It 
would accomplish the same goal (nitpicking... sorry).


Also, why are there two return statements? The second will never run.

Maybe I missed something though.

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Sometimes I wonder why I even started programming...

2008-02-27 Thread Ray Hauge

Jason Pruim wrote:


On Feb 27, 2008, at 5:12 PM, Daniel Brown wrote:


On Wed, Feb 27, 2008 at 4:55 PM, Jason Pruim [EMAIL PROTECTED] wrote:

So I was supposed to go home a half hour ago but that didn't happen...
I hate deadlines! :P


   You whine like a mule.


I know... But I get good answers when I do :P




[snip!]

   function authentication($user, $pass, $authenticated, $table){

   // Keep in mind, PASSWORD has meaning in MySQL
   // Do your string sanitizing here
   // (e.g. - $user = 
mysql_real_escape_string($_POST['user']);)

   $salt = salt;
   $salt1 = $salt;
   $salt1 .= $pass;

   $password = md5($salt1);
   $loginQuery = SELECT * FROM current WHERE 
loginName='.$user.'

AND loginPassword='.$password.' LIMIT 0,1;;
   $loginResult = mysql_query($loginQuery) or 
die(Wrong data supplied

or database error  .mysql_error());
   while($row1 = mysql_fetch_array($loginResult)) {
   $_SESSION['user'] = $row1['loginName'];
   $_SESSION['loggedin'] = YES;
   $authenticated = true;
   $table = $row1['tableName'];

   }
   return $table;
   return $authenticated;
   }   \


   I recognize that code, Jason!  At least the base of it (and the
comments).  ;-P


As well you should!




   See in the first block how you're using $_SESSION?  That's why
you're able to read it later because you have two return $xxx
lines in each function.

   As soon as a function reaches a `return` statement, it returns
that data and exits, so the second `return` is never processed.


so the return $table; line doesn't ever get processed?

Is there anyway to make it get processed? :) I'm attempting to rewrite 
code so I don't HAVE to use session variables... Hoping I can make it 
work :)



--

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



You could return an array with string keys.

$array['table'] = 'asdf';
$array['authenticated'] = false;

return $array;

That's just one option, but it would work.

--
Ray Hauge
www.primateapplications.com

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



[PHP] Test

2008-02-27 Thread Ray Hauge
I recently figured out how to use two SMTP accounts in Thunderbird. 
Hopefully this will help the list to not count me as spam so much (I was 
using my own host to send as gmail... doesn't work so well).


Thanks,
--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] Functions not available when run as Scheduled Task?

2008-02-27 Thread Ray Hauge

Brian Dunning wrote:
Don't laugh but we have a Win 2003 Server set up with WAMP, and the 
PHP/MySQL scripts work great. I set one up to run as a scheduled task:


C:\php5\php.exe D:\wamp\www\scriptname.php

...but nothing happens and the Scheduled Tasks log says that it exited 
with an (ff). So I entered the above manually into a command prompt, and 
it said that mysql_connect() is an unknown function! WTF? It's like it's 
trying to use a different php.ini file that maybe has mysql commented 
out. I double checked that all the php.ini files on the machine do have 
mysql enabled, and anyway mysql works fine normally.


Anyone know what PHP is doing to me here in the scheduled service?



I think that there might be a separate php-cli.ini file that is not 
loading the modules that apache does.  I'm too lazy to verify, but I 
remember running into that myself a time or two.  Check the output of 
phpinfo(); or C:\php5\php.exe -v (I think that'll work on Windows).


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] How do you send stylized email?

2008-02-26 Thread Ray Hauge

Robert Cummings wrote:

On Tue, 2008-02-26 at 10:38 -0500, tedd wrote:

At 4:27 PM +0100 2/26/08, Jochem Maas wrote:

tedd schreef:

Now you sound like my wife.  :-)

for your sake I hope I don't look like her :-P

No, I have an absolutely beautiful wife -- no complaints in that department.


that said I'd hazard a guess and say you listen to what she says ... my ex
used to say the same thing.

Ex's are the experience you need to get it to work.

I've always said that everyone should go through at least one divorce 
before getting married.


Marriage?? That's for backwards people stuck in ancient pointless
traditions :) And moreso in today's culture... it's just a commercial
suckfest when your money could better go to student loans and raising a
family.

I've been happily living in sin with my common-law wife for 9 years.
Besides, isn't marriage primarily a religious thing? In the old
testament marriage was often implied by the simple act of laying with a
woman... or two... or three... Polygamy, how did that fall out of
religious favour? :)

Cheers,
Rob.


I know it was a rhetorical question, but I was curious.

A lot of the modern standards started when St. Augustine started 
teaching that the fall of Adam and Eve was the original sin which was 
sex.  Somehow that took hold and then sex became a bad thing and to be 
the most holy of holy you should be celibate.


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

As far as the history of monogamy goes, I had to look this one up.  It 
also seems to stem from the teachings of St. Augustine (late AD 300s). 
Martin Luther eventually allowed polygamy after coming to the conclusion 
that there was no scriptural evidence that polygamy was wrong. 
Obviously that's no longer in effect though.  It has also been allowed 
after certain wars to beef up the population again.


http://en.wikipedia.org/wiki/Polygamy#Christianity

I typically don't use wikipedia for sole sources, but everything else I 
could find was some religious site that was very biased.


How's that for off topic?

--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] How do you send stylized email?

2008-02-26 Thread Ray Hauge

Robert Cummings wrote:

So... using this system, a world where everyone is as holy as can be
would be a world devoid of humans (gotta have sex to reproduce). I don't
think St. Augustine was thinking it through :)

Cheers,
Rob.


Haha.  I've often wondered why Christianity has survived so long because 
of this.  I'm just glad there's a lot of sinners out there, or at least 
people who aren't that crazy :)


--
Ray Hauge
www.primateapplications.com

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



Re: [PHP] LOL, preg_match still not working.

2007-02-17 Thread Ray Hauge
Maybe you just copied it wrong, but nocomments and invalidchars are not 
quoted, or they're constants.


I don't think you have to, but you might need to escape some of the 
characters (namely * and .) in your regex.  It's been a while, so I'd 
have to look it up.


What's the error you are getting?

Ray Hauge
Primate Applications


Beauford wrote:

Hi,

I previously had some issues with preg_match and many of you tried to help,
but the same  problem still exists. Here it is again, if anyone can explain
to me how to get this to work it would be great - otherwise I'll just remove
it as I just spent way to much time on this.

Thanks

Here's the code.

	if(empty($comment)) { $formerror['comment'] = nocomments; 
	}

elseif(!preg_match('|[EMAIL PROTECTED]*();:_. /\t-]+$|',
$comment)) {
$formerror['comment'] = invalidchars;
}   

This produces an error, which I believe it should not.

Testing 12345. This is a test of the emergency broadcast system.

WAKE UP!!



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



Re: [PHP] Amortization calculator

2007-02-05 Thread Ray Hauge

Dan Harrington wrote:

Hello,

I am looking for a 365-day  (as opposed to 360) amortization calculator.
Does anyone know of one written in PHP that could be used to calculate
payments, PI, etc on loans with the various variables changeable like this?
http://ray.met.fsu.edu/cgi-bin/amortize

Thanks
Dan





Usually 360 means number of months, not days, in an amortization 
calculator (30 years).  That's a pretty standard loan term.


I used this when I had to write my own amortization calculator:
http://www.hughchou.org/calc/formula.html

I think there's a PHP version you can download on it.

--
Ray Hauge
Primate Applications

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



Re: [PHP] Jabber conection manager

2007-02-04 Thread Ray Hauge

Le Phuoc Canh wrote:

It seem that you want to develop a webchat :), today there is a lot library
about Jabber protocol, but all in JAVA language, if you want you can use
library of jivesoftware to develop. I use Wildfire for IM server, and Claros
for webchat in servlet. You can try it for develop Jabber connection manage.
Best Regard.

-Original Message-
From: chetan rane [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 03, 2007 10:07 PM

To: php-general@lists.php.net
Subject: [PHP] Jabber conection manager

HI all

i want to develop a Jabber connection manage its role will be

1. accept HTTp request from the Client
2. establish connection with a jabber server using TCp 3. and later start
the instant mechanism between them

has any one worked on this please let me know how to do it


--
Have A plesant Day
Chetan. D. Rane
Location: Pune , India
Contact: +91-9890792762
otherID: [EMAIL PROTECTED]
 [EMAIL PROTECTED]



I've used http://cjphp.netflint.net/ for a project at work before.  It 
was a great simple way to just interface with a jabber server.  I didn't 
need to do anything fancy at the time though.  You could probably use 
that source as a base if you wanted.  It's GPL.



--
Ray Hauge
Primate Applications

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



[PHP] MS Outlook 2003 Options

2006-12-21 Thread Ray Hauge
Okay, this doesn't have to do with PHP directly, but it does have to do
with this list.  I'm using MS Outlook 2003.  My company has an exchange
server, and the Evolution OWA client doesn't work well enough for all
the calendaring stuff I have to do.  So, I was wondering if anyone else
out there has run into the problems I am having.

 

First, and foremost, Outlook doesn't thread messages very well.  Are
there any plug-ins or options that can be set to get my PHP folder to
display a proper threaded view?  I used to have this in Kmail, and I
desperately miss it.

 

Second is bottom posting.  Is there any way to get Outlook to put my
reply at the bottom of the page?  Again with the Kmail :-)

 

I've been looking for information on these for the past hour or so, but
my searching powers aren't working Damn kryptonite!

 

 

Thanks!

 

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com

 



[PHP] Test

2006-12-21 Thread Ray Hauge

Hey guys,

I just switched email accounts, so I'm testing to make sure that the 
subscription worked.


Thanks,
Ray

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



[PHP] Test

2006-12-21 Thread Ray Hauge

Hello everyone,

I just switched to one of my personal accounts.  Just making sure that 
the subscription went well.


Thanks,
Ray

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



RE: [PHP] Are PHP5 features worth it?

2006-12-20 Thread Ray Hauge
PHP 5.2 supports JSON internally now, so you don't have to use XML.
There's pros and cons associated with JSON, but that was possible with
PHP4 as well.

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 20, 2006 8:37 AM
To: Robert Cummings
Cc: Bernhard Zwischenbrugger; php-general@lists.php.net
Subject: Re: [PHP] Are PHP5 features worth it?

Robert Cummings wrote:
 On Wed, 2006-12-20 at 15:14 +0100, Bernhard Zwischenbrugger wrote:
 AJAX Webapplications are not possible in PHP4.
 
 Bullshit.

Indeed, what with PHP being server-side and AJAX being client-side.

Where AJAX is concerned the server-side technology is irrelevant.

-Stut

-- 
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] Are PHP5 features worth it?

2006-12-20 Thread Ray Hauge
I think all this talk goes to show you that the differences between PHP4
and PHP5 are somewhat personal at this point in the game.  Some people
like the better OOP features of PHP5, some people think PHP5 is faster,
some people like the XML/WebServices in PHP5 better, and many others
(don't forget PDO, or exceptions).

For the OP, I think it's really going to come down to what you think.
Everyone's mileage is varying on this one.

Here's my .02.  If you go with PHP5, go with at least PHP 5.1.x, if not
5.2.  I'm not sure how stable 5.2 is lately. I had heard of some issues,
but they could have been from things most people don't do.  I'm pretty
sure that people don't install 5.0.x anymore, but 5.1 is a lot better
(from what I've heard anyway.  I never used 5.0.x)

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 20, 2006 12:22 PM
To: Robert Cummings
Cc: Bernhard Zwischenbrugger; php-general@lists.php.net
Subject: Re: [PHP] Are PHP5 features worth it?

Robert Cummings wrote:
 On Wed, 2006-12-20 at 17:38 +0100, Bernhard Zwischenbrugger wrote:
 Is there a way to parse XML in PHP4?
 
 Yes. And even if there weren't any libs, there's nothing stopping
anyone
 from writing a parser in PHP itself!

ai, and in most cases a regexp will cut it,
gotta love those 1 line parsers :-)

 
 Cheers,
 Rob.

-- 
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] Curl and cookies

2006-12-15 Thread Ray Hauge
I don't know if you can do what you are asking for, but you could get
around it a little bit.  In the curl request you specify the cookie file
and the cookie jar file.  Once you have made your requests, you could
read them with file_get_contents() and put that into a $_SESSION
variable.  You could then put that information back into the cookie
file(s) with file_put_contents() [PHP5]

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com
-Original Message-
From: Fernando M. M. [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 15, 2006 8:07 AM
To: php-general@lists.php.net
Subject: [PHP] Curl and cookies



Hello,

I have just started using curl and i have some question about
cookies.

The website i'm logging in controls everything using cookies (from
login to the actions inside it).

Is there a way to store the cookie values
into a php session variable ($_SESSION['cookie'])?

How do i make curl receive
the cookie and store in this variable?

How do i make curl send it?

Thanks,

Fernando.

-- 

Blog:
http://blog.forumdebian.com.br/fernando
Contato:
http://www.forumdebian.com.br/fernando/contato.php

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



[PHP] Newline Before XML Document

2006-12-12 Thread Ray Hauge
I've read a lot of information about this error (in Firefox):

 

XML Parsing Error: xml declaration not at start of external entity

 

Basically it means that the XML did not start at the beginning of the
file.  The weird part of this is that if I save the document to a file
on the webroot and then view it that way, the XML is displayed
correctly.

 

So far I've tried using output buffering to make sure no other
information was sent before I output the XML, but that didn't work.
I've also tried replacing all return characters and newline characters,
but that also didn't work.

 

In Konqueror I get the following error message:

 

fatal parsing error: invalid name for processing instruction in line 2,
column 6

?xml version=1.0 encoding=utf-8?

 

I even tried the following on the ob_get_contents():

$xml_string = substr($xml_string, strstr($xml_string, ''));

 

Has anyone else run into this problem?  As far as I can tell this
document starts on line 1.

 

Thanks,

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com

 



RE: [PHP] Newline Before XML Document

2006-12-12 Thread Ray Hauge
I found the problem.

I was re-writing the page from using the old DOMXML to the new DOM.  We
recently switched to PHP5, and there's only one script (so far) that
creates XML, so it was easier to just use the domxml-php4-to-php5.php
class that is available online.  I didn't realize that there was an
extra line after the closing '?' in that file.  That was causing the
extra invisible line to show up.

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Ray Hauge 
Sent: Tuesday, December 12, 2006 9:14 AM
To: php-general@lists.php.net
Subject: [PHP] Newline Before XML Document

I've read a lot of information about this error (in Firefox):

 

XML Parsing Error: xml declaration not at start of external entity

 

Basically it means that the XML did not start at the beginning of the
file.  The weird part of this is that if I save the document to a file
on the webroot and then view it that way, the XML is displayed
correctly.

 

So far I've tried using output buffering to make sure no other
information was sent before I output the XML, but that didn't work.
I've also tried replacing all return characters and newline characters,
but that also didn't work.

 

In Konqueror I get the following error message:

 

fatal parsing error: invalid name for processing instruction in line 2,
column 6

?xml version=1.0 encoding=utf-8?

 

I even tried the following on the ob_get_contents():

$xml_string = substr($xml_string, strstr($xml_string, ''));

 

Has anyone else run into this problem?  As far as I can tell this
document starts on line 1.

 

Thanks,

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com

 

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



RE: [PHP] Ensuring that variable contains a number

2006-12-06 Thread Ray Hauge
I think that will only check for a digit value of some kind.  It's not
going to check that $input is positive or if it is an integer.  For
instance, it could be a negative float value as long as $input is
interpreted as a float and not a string. The period would throw it off
it it's a string.  I'd have to test, but anyway you could do something
like this:

?php
function isPositiveInteger($input) {
$integer = floor($input);
$decimal = $input - $integer;
$returnVal = true;

if ($input  0) {
$returnVal = false;
}

if ($decimal != 0) {
$returnVal = false;
}

return $returnVal;

}

?

That should work.  There might be a bug in there, but I'll leave that up
to people to test it ;)

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Brad Fuller [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 06, 2006 2:20 PM
To: 'php php'
Subject: RE: [PHP] Ensuring that variable contains a number

 How can I ensure that a variable contains a postive integer number?
 I'm currently using this code:
 
 $number=(1-$number);
 $number=(1-$number);
 if ( $number1 ) { $number=1; }
 
 But I'm sure that there is a better way. What would that be?


this will check that $input is a positive integer.

if(preg_match(/^\d+$/, $input)) {
// OK
} else {
// NOT OK
}

-- 
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] EZ array problem - What's wrong with my brain?

2006-12-01 Thread Ray Hauge
http://www.php.net/manual/en/language.types.array.php

If you check out the documentation on arrays, you will see the second
code example shows the expected behavior of arrays in this case.

$arr = array(foo = bar, 12 = true);

echo $arr[foo]; // bar
echo $arr[12];// 1

Now, since each element can be indexed by either a string or an integer,
then you can do something like this:

$arr = array(1.2 = array(1,2,3,4));
$arr[0] =  $arr[1.2];

That would set up your doubly indexed array so that you could use either
associative keys or numeric keys.

http://www.php.net/manual/en/language.references.php

PHP.net can explain how references work better than I can. Basically it
creates a symbolic link (to use a *nix term) to the key 1.2.  It
shouldn't take up too much memory to do that.

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Fredrik Thunberg [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 01, 2006 8:52 AM
To: Brian Dunning; php-general@lists.php.net
Subject: Re: [PHP] EZ array problem - What's wrong with my brain?

Try

$try = $var[1.2];

If your array looks like the one below then there is no $var[0] and 
therefore you get NULL


/Thunis
Brian Dunning skrev:
 That seems right to me too - but everything I try returns NULL. I set 
 $try=$var[0], and $try ends up being null; print_r($try) gives blank. 
 I even tried $try=$var[1] and it was the same result. Am I in the 
 Twilight Zone?


 On Dec 1, 2006, at 12:26 AM, Youri LACAN-BARTLEY wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Well, I've only just fallen out of bed, but I'd say you'd be able to
 access it via $var[0][0][0] as in $var[1.2][code][0] to change
111
 to something else and $var[1.2][status][0] to set/change new.

 Brian Dunning wrote:
 var_dump() gives me this:

 array(1) {
   [1.2]=
   array(2) {
 [code]=
 array(1) {
   [0]=
   string(3) 111
 }
 [status]=
 array(1) {
   [0]=
   string(3) new
 }
   }
 }

 I'm trying to set a variable to that 1.2. Shouldn't I be able to
get
 it with $var = $arr[0][0]?

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

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.5 (MingW32)

 iD8DBQFFb+cnWC9/YPePNU4RAmnzAKDGUlHxZiQvyhLfSiHKXV9sI73fTQCfe/Ub
 pKYeQqK4FcNhmTdEIm41kic=
 =PSbi
 -END PGP SIGNATURE-

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


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

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



RE: [PHP] EZ array problem - What's wrong with my brain?

2006-12-01 Thread Ray Hauge
I forgot to mention that you won't be able to use 0, 1, etc. as PHP
will convert those to integers.  If you do use them, then they will
replace [0] with whatever you put in there, and if you are using the
references, it will replace both instances with your new [0]

HTH

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Ray Hauge 
Sent: Friday, December 01, 2006 9:21 AM
To: Fredrik Thunberg; Brian Dunning; php-general@lists.php.net
Subject: RE: [PHP] EZ array problem - What's wrong with my brain?

http://www.php.net/manual/en/language.types.array.php

If you check out the documentation on arrays, you will see the second
code example shows the expected behavior of arrays in this case.

$arr = array(foo = bar, 12 = true);

echo $arr[foo]; // bar
echo $arr[12];// 1

Now, since each element can be indexed by either a string or an integer,
then you can do something like this:

$arr = array(1.2 = array(1,2,3,4));
$arr[0] =  $arr[1.2];

That would set up your doubly indexed array so that you could use either
associative keys or numeric keys.

http://www.php.net/manual/en/language.references.php

PHP.net can explain how references work better than I can. Basically it
creates a symbolic link (to use a *nix term) to the key 1.2.  It
shouldn't take up too much memory to do that.

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Fredrik Thunberg [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 01, 2006 8:52 AM
To: Brian Dunning; php-general@lists.php.net
Subject: Re: [PHP] EZ array problem - What's wrong with my brain?

Try

$try = $var[1.2];

If your array looks like the one below then there is no $var[0] and 
therefore you get NULL


/Thunis
Brian Dunning skrev:
 That seems right to me too - but everything I try returns NULL. I set 
 $try=$var[0], and $try ends up being null; print_r($try) gives blank. 
 I even tried $try=$var[1] and it was the same result. Am I in the 
 Twilight Zone?


 On Dec 1, 2006, at 12:26 AM, Youri LACAN-BARTLEY wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Well, I've only just fallen out of bed, but I'd say you'd be able to
 access it via $var[0][0][0] as in $var[1.2][code][0] to change
111
 to something else and $var[1.2][status][0] to set/change new.

 Brian Dunning wrote:
 var_dump() gives me this:

 array(1) {
   [1.2]=
   array(2) {
 [code]=
 array(1) {
   [0]=
   string(3) 111
 }
 [status]=
 array(1) {
   [0]=
   string(3) new
 }
   }
 }

 I'm trying to set a variable to that 1.2. Shouldn't I be able to
get
 it with $var = $arr[0][0]?

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

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.5 (MingW32)

 iD8DBQFFb+cnWC9/YPePNU4RAmnzAKDGUlHxZiQvyhLfSiHKXV9sI73fTQCfe/Ub
 pKYeQqK4FcNhmTdEIm41kic=
 =PSbi
 -END PGP SIGNATURE-

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


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

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

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



RE: [PHP] Remote MySQL connection via PHP file

2006-12-01 Thread Ray Hauge
That seems like it wouldn't be very secure at all.  Maybe it's just
because I don't understand the reason for *having* to do it that way.
My first suggestion would be to see if there's any way you don't have to
do that.  If you have to do it, I would suggest maybe having it on an
NFS share, or maybe FTP.  Something that requires authentication would
be best.

--
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com

-Original Message-
From: Scott [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 01, 2006 12:18 PM
To: php-general@lists.php.net
Subject: [PHP] Remote MySQL connection via PHP file

Hi all,

I've been searching around for a while, but cannot find a solution. For 
a project of mine, I need to keep the connection information to a MySQL 
server database on another server.

Example remote file:

?php
$user = joe;
$pass = 1234;
?

Example local file:

?php
include http://www.remoteserver.com/remote_file.php;;
// Use variables $user and $pass somehow...
?

I've tried including the file which has the username/pass, etc 
information via HTTP, but this doesn't seem to work. I assume because it

returns what a web browser would return if this file was loaded into 
one, a blank screen.

I've tried using the return statement in the file which houses the 
information, but this seems to return a boolean value (1 or 0)... not 
sure what's up with that.

Any help with this would be most appreciated.

Thank you.

Scott

-- 
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] LDAP password question

2006-11-30 Thread Ray Hauge
Hello,

 

I was actually wondering if the PHP implementation of an LDAP client
encodes the password before being sent, or if it sends the password in
plain-text.  The most information I've got on this subject, so far, is
from http://adldap.sourceforge.net/faq.php

 

Q. Why am I getting poor performance with Windows 2003 Server?

A. Microsoft figured out that plain text passwords aren't a good thing
and tightened the security on Windows 2003 Server. The passwords
floating around with 2000 server were all encrypted but there are some
new timeout problems during negotiation (I think). Anyways, I've set
another LDAP option in version 1.2 to force encrypted passwords, and it
has resolved this issue.

 

After looking through their source code, this information seems to be
for modifying passwords or creating a user.  I would assume that
passwords are plain text without SSL when using ldap_bind().

 

Thanks,

 

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com



From: Alain Roger [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 30, 2006 6:15 AM
To: Ray Hauge; PHP General List
Subject: Re: [PHP] LDAP password question

 

Hi Ray,

the question is for which reason you need to know something about the
pwd ?
to log on ?

if yes, it's not needed. I personally did like that :
1. with login + pwd given by user, i try to bind.
2. if bind works, it means that user login+pwd are equal to AD
login+pwd.
3. if error during bind, so error in pwd or login.

that's all.

Alain

On 11/30/06, Ray Hauge [EMAIL PROTECTED] wrote:

I'm working on integrating an application with an AD server, and I was
wondering if the password is encrypted at all, or if I need to go
through the troubles of setting up ldaps://



I checked the documentation, but I couldn't find any information about 
plain-text vs. encrypted.



Thanks!



--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com 








-- 
Alain

Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5 



[PHP] LDAP password question

2006-11-29 Thread Ray Hauge
I'm working on integrating an application with an AD server, and I was
wondering if the password is encrypted at all, or if I need to go
through the troubles of setting up ldaps://

 

I checked the documentation, but I couldn't find any information about
plain-text vs. encrypted.

 

Thanks!

 

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com

 



RE: [PHP] Additional query for number of records in table

2006-11-17 Thread Ray Hauge
I've run into this before, and if you use MySQL you can do something
like this:

SELECT SQL_CALC_FOUND_ROWS * FROM Products LIMIT $From, $To

SELECT FOUND_ROWS()

http://dev.mysql.com/doc/refman/5.0/en/information-functions.html

The second query will give you the number of rows that would have been
returned without the LIMIT clause.  There's no way to do it with one
query though... at least easily or quickly.

Ray

-Original Message-
From: Brad Bonkoski [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 17, 2006 1:57 PM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] Additional query for number of records in table

[EMAIL PROTECTED] wrote:
 hi,
 I have query to select products for specific category from DB,
something
 like:
 SELECT prod_id, prod_name,...
 FROM products
 LIMIT $From, $To

 where $From and $To values depend of on what page you are. let say
there
 are 100 products and I'm listing 25 products per page. for page 1
$From=0,
 $To=24. for page 2 $From=25 and$To=49, etc.

 works fine.

 though, to calculate how many pages I have I need total number of
records.
 do I have to run first a query (something like SELECT COUNT(*) as
 NoOfRecords FROM products) and then query above or there is solution
to
 have both info using one query?

 as a solution, I can run a query to grab all records and then list
just 25
 products but I think it's not so smart idea :)

 thanks for any help.

 -afan

   
I would say the select count(*) from ... query would be a fairly low 
cost query.
Perhaps you could store off the number of rows in a session variable so 
you don't have to execute the count query when you move to the next
page.
-B

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

2006-11-09 Thread Ray Hauge
It sounds more like you installed the Zend Platform with the developer's
license that comes with Zend Studio.  If you're on linux it creates a
symlink and it always backs up your current INI file, but when you
install Zend Platform, it adds the sections needed for debugging, etc.
at the end of your current .ini file.  I'm not sure what it does on
Windows.  

In any case, I'd check with Zend.  They'd be a lot more knowledgeable
about their own applications than we are... not to mention that you have
a support contract with the Studio license.

HTH
Ray

-Original Message-
From: Alain Roger [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 09, 2006 9:51 AM
To: PHP General List
Subject: [PHP] Zend

Hi,

For my work, i bought Zend studio 5.2 and for sure when i installed it,
it
modified the path for the PHP.INI file to its local version.
after checking the content of the php.ini file from Zend distribution,
it
seems to be a different version than the one from official PHP.

I would like to switch to the previous location of php.ini (in original
php
folder) but i would like to know if someone experiment some issues by
not
replacing all data from php.ini (version of zend) inside the original
php.ini file (from PHP distribution) ?

I would be glad to be sure that i still can code and debug php code via
Zend
tool/

thanks a lot,
Alain

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



RE: [PHP] Microsoft Partners With Zend

2006-11-06 Thread Ray Hauge
I'd say to just use the Zend Core for Windows.  If you want to use
Visual Studio to edit PHP files, I have seen some information about how
to do it that doesn't involve any PHP compilers.  As Zend and MS work
together Zend Core for Windows will only get more and more stable.  I'm
pretty sure that Zend Core can be freely downloaded as well.

http://www.zend.com/products/zend_core/windows_preview

Ray

PS. Sorry about the top-post, but I recently moved to Outlook, and I
haven't bothered to configure it for bottom-posting yet.

-Original Message-
From: Rory Browne [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 06, 2006 2:50 PM
To: Martin Cetkovsky
Cc: php-general@lists.php.net
Subject: Re: [PHP] Microsoft Partners With Zend

On 11/6/06, Martin Cetkovsky [EMAIL PROTECTED] wrote:

 Jay Blanchard wrote:
  [snip]
  I guess that's sorta what I'm afraid of... PHP#
  (like the did to Java - J++ - C# )
 
  Don't get me wrong. C# is a great language (probably one of the few
  things
  that M$ did right), and I'd LOVE to use a real IDE like Visual
  Studio to
  dev in...
 
  But I'm also terrified they'll pervert PHP.
  [/snip]
 
  Please NO PHP.NET === ACCCKKK

 The .NET compiler for PHP exists for many years. It is created and
 managed by students of the Charles University in Prague.


There are already two such compilers, phlanger, and php4mono. You could
probably also user quercus, and ikvm if  you wanted to.

I can imagine playing around with php4mono, or quercus at some stage,
but I
can't see myself going near Phalanger. This is mainly due to its dirty
licence:

A few extracts:

You may not modify the Software.,

You may not reverse engineer, decompile, or disassemble the Software,
except and only to the extent that such activity is expressly permitted
by
applicable law notwithstanding this limitation.,

and

Your rights under the License end automatically if you breach it in any
way.

combined with

The Software includes libraries in its distribution package (directory
Extensions) that are part of the PHP software

I therefore have a negative viewpoint on the developers, given their
failure
to distribute phlanger under an apahe-style licence similar to that
used by
the real PHP.

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



RE: [PHP] Microsoft Partners With Zend

2006-11-02 Thread ray . hauge
That test was very basic though.  It's easy for the kernel to cache the
same response, but it does at least show that it can/does improve
performance.  I think it would be silly to expect those kinds of
numbers for every application.  You also have to remember that the
stability is based on the Windows server, which its track record isn't
exactly as good as Linux/BSD systems.

Ray

  Original Message 
 Subject: Re: [PHP] Microsoft Partners With Zend
 From: Curt Zirzow [EMAIL PROTECTED]
 Date: Wed, November 01, 2006 4:53 pm
 To: steve [EMAIL PROTECTED]
 Cc: Daevid Vincent [EMAIL PROTECTED], php-general@lists.php.net
 
 On 11/1/06, steve [EMAIL PROTECTED] wrote:
  On 11/1/06, Daevid Vincent [EMAIL PROTECTED] wrote:
   Personally I'm unsure. I would like to think that Zend is smart enough to
   realize M$ tactics of embrace/extend and will not allow that to happen.
 
  MS added a FastCGI module to IIS. Thats the big thing.
 
 They demo'd it at the zend conference with IIS7 on vista (installed on
 a macbook pro), there is also a bunch of work zend has done to improve
 speed.. the non improved php5 version benched like 30 requests/sec,
 the zend patched  version did over 100 requests/sec.
 
 Then they demo'd the kernel cache; 6500 requests/sec. (and no i didn't
 typo and add an extra zero).
 
 Curt.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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



[PHP] Frameworks

2006-11-02 Thread ray . hauge
I know this subject has been covered in the past, but my question is why
use them?  I'm hoping to not create a religious war...  I see that
frameworks would probably help you develop some things faster, but most
of the time they don't do the things the way I would want them to work. 
If I did use one, it almost seems like I would use it to get through
something  until I had time to do things the way I wanted/needed to do
them.  There's a lot of talk about frameworks lately, and especially
the Zend Framework, so I'd like to look into what it's all about.  I
think I might be missing out the framework issue, so I'd like to hear
other people's opinions.

I do like the mail, pdf, and a few other parts of the Zend Framework.  I
also like that it's more like a set of tools than a monolithic beast
that would take a lot of memory just to load up into your application.

Your thoughts?

Thanks,
Ray

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



RE: [PHP] Microsoft Partners With Zend

2006-11-02 Thread ray . hauge


  Original Message 
 Could you expand the term kernel cache to a formal name so I know if
 that's an MS technology I don't care about, or a general Zend
 technology that might apply to LAMP, which I'd be interested in
 reading more about?

Yeah, the kernel caching is through Microsoft's FastCGI
implementation, not something from Zend.  There might have been
something in IIS 7 that deals with this, but I'm not completely sure on
that.  If people were interested MS said that the FastCGI stuff was
available on the IIS website.

Ray

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



RE: [PHP] Closing a connection to browser without exiting the script

2006-11-02 Thread ray . hauge
  Original Message 
 Subject: [PHP] Closing a connection to browser without exiting the
 script
 From: David Négrier [EMAIL PROTECTED]
 Date: Wed, November 01, 2006 2:24 pm
 To: php-general@lists.php.net
 
 Hello there,
 
 I'm having a somewhat unusual question here, and I cannot find any way 
 to solve it.
 
 I have a PHP page that displays a message, and then, performs a very 
 long operation. Note that it displays the message first.
 I do not intend to give some feedback to the user when the operation is 
 done.
 
 I've seen I can use ignore_user_abort() to prevent the user from 
 stopping the ongoing operation, but that solves only part of my problem. 
 Because as long as the page is not fully loaded, the mouse cursor in the 
 user's browser is showing a watch.
 
 So ideally, what I would like is to be able to close the connection from 
 the server-side, but without using the exit() function, so my script 
 keeps running afterwards.
 
 I know I could use a system() call to launch another process to do the 
 processing, but I would like to avoid doing that, because there are many 
 variables in the context that I cannot easily pass in parameter.
 
 I also tried to use the register_shutdown_function() to perform my 
 operation after the page is displayed but since PHP 4.1.0, the 
 connection is closed after the function is called
 
 Would any of you have an idea on how I could close that connection?
 
 Thanks a lot,
 David
 www.thecodingmachine.com

It's a bit different of an idea, but you could put your reqest to
perform the operation in a text file in some directory.  Then you have
a seperate PHP script that checks that directory for any files that
would tell it to operate.  Then you tell Cron to run that script every
minute, 10 minutes, whatever works best for you.

With this idea you can write out the file and then tell the person that
you have submitted a request.  Then the cron job checks for the request
and performs it.  You could use a database instead of a file as well
with the idea of a queue.  That would probably work better, because
then if you needed to you can keep track of which user's process was
run, and then update the user table.  Say the user table has a
column processing with three possible values.  0 (not processed), 1
(in processing), 2 (finished processing).  You could probably expand
upon that idea quite a bit more if you need to.

It's no single magic bullet function call, but that's how I'd probably
do it.

Ray

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



RE: [PHP] Microsoft Partners With Zend

2006-11-01 Thread ray . hauge
I don't think there's anything to worry about MS making any changes with
PHP.  I'm at the Zend conference righ t now, and they've had some talks
about working with MS.  Mostly they're trying to fix a lot of the
segfaults and performance issues that PHP has on theh Win32 platform. 
You might see some changes in the future that pertain to Active
Directory integration for single sign-on (other than ldap) and a few
other Win32 based technologies.

For Zend... you get more people using PHP, because now they can use PHP
with confidence and ditch ASP if they need to ;)

Ray


  Original Message 
 Subject: RE: [PHP] Microsoft Partners With Zend
 From: Jay Blanchard [EMAIL PROTECTED]
 Date: Wed, November 01, 2006 3:23 pm
 To: Daevid Vincent [EMAIL PROTECTED], PHP General
 php-general@lists.php.net
 
 [snip]
 I guess that's sorta what I'm afraid of... PHP# 
 (like the did to Java - J++ - C# )
 
 Don't get me wrong. C# is a great language (probably one of the few
 things
 that M$ did right), and I'd LOVE to use a real IDE like Visual
 Studio to
 dev in... 
 
 But I'm also terrified they'll pervert PHP.
 [/snip]
 
 Please NO PHP.NET === ACCCKKK
 
 -- 
 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] Microsoft Partners With Zend

2006-11-01 Thread ray . hauge
I don't think there's anything to worry about MS making any changes with
PHP.  I'm at the Zend conference righ t now, and they've had some talks
about working with MS.  Mostly they're trying to fix a lot of the
segfaults and performance issues that PHP has on theh Win32 platform. 
You might see some changes in the future that pertain to Active
Directory integration for single sign-on (other than ldap) and a few
other Win32 based technologies.

For Zend... you get more people using PHP, because now they can use PHP
with confidence and ditch ASP if they need to ;)

Ray


  Original Message 
 Subject: RE: [PHP] Microsoft Partners With Zend
 From: Jay Blanchard [EMAIL PROTECTED]
 Date: Wed, November 01, 2006 3:23 pm
 To: Daevid Vincent [EMAIL PROTECTED], PHP General
 php-general@lists.php.net
 
 [snip]
 I guess that's sorta what I'm afraid of... PHP# 
 (like the did to Java - J++ - C# )
 
 Don't get me wrong. C# is a great language (probably one of the few
 things
 that M$ did right), and I'd LOVE to use a real IDE like Visual
 Studio to
 dev in... 
 
 But I'm also terrified they'll pervert PHP.
 [/snip]
 
 Please NO PHP.NET === ACCCKKK
 
 -- 
 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] Running a Java Program

2006-10-26 Thread Ray Hauge
On Thursday 26 October 2006 6:48 pm, Prathaban Mookiah wrote:
 Hello List,

 I have a situation where, when the user logs into the system (Apache 2/PHP
 5.1/Win XP) the php script should activate a Java program to run in the
 background. This program will keep running in the background while
 everytime the user requests something, the subsequent php scripts
 communicates with this Java program on a preassigned port. (This is for
 controlling a robot I descibed in on of my earlier mails)

 My questions are:

 1. How do I make the Java program to keep running even after the PHP script
 terminates. In Linux I would have easily done using '' - how about
 windows?

 2. What is the safest way to do it?


 Thanks in advance.

 Prathap

 P.S - Richard  Tedd - I appreciate your comments on my previous issue.

Does the Java program HAVE to be started by a script?  I've worked in a few 
places that had desktop apps that would just run on startup, or a service, 
and then the webserver/php would communicate to it since it's already 
running.  The downside to that is manual intervention when the program stops.  
Although... you could probably to an exec() and if it was installed as a 
service you should be able to run net start appname' (or something like 
that.

I haven't kept up on your previous post so I may be completely wrong ;)

-- 
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Running a Java Program

2006-10-26 Thread Ray Hauge
On Thursday 26 October 2006 7:28 pm, Prathaban Mookiah wrote:
 Ray,

 Nope - I cannot have the program running all the time because the port that
 it this program will connect to will be accessed by other programs too. So
 it needs to run only when the user is online and logged into the system.

 Any ideas?

 Prathap


I kind of mentioned it before, but what about making the java program a 
service?  Then you could exec()/shell_exec() net start or net stop as 
needed.  Beyond that I don't have any ideas without checking Google.

-- 
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] exec returns no output?

2006-09-30 Thread Ray Hauge
On Saturday 30 September 2006 7:22 am, Nick Wilson wrote:
 hi all,

 i've searched and racked my brains, checked config files and all sorts
 but cannot work out why the following command would give me an empty
 array (and certainly not actually perform the requested command...)

 exec('scp -v -i /id_dsa file.txt [EMAIL PROTECTED]:/target/dir/', $argh);
 print_r($argh);

 I can only surmise there is some setting todo with ssh/scp that im
 unaware of?

 any ideas welcomed, thanks!
 --
 Nick Wilson
 http://performancing.com/user/1

Do you use generated keys without a password for logging in?  Otherwise exec() 
is just going to sit there while the scp command waits for a password.

-- 
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] class usage

2006-09-29 Thread Ray Hauge
On Friday 29 September 2006 4:35 am, benifactor wrote:
 the real question is what
 are some real life examples of class usage and why is it used as  opposed
 to regular non oop? thank you for any input into the subject that you may
 have.

I think people have pretty much hit the nail on the head with OOP.  One thing 
that I would like to point out is that OOP isn't necessarily needed in every 
case.  There are times when making a class to abstract a certain 
feature/process is a good idea, and there there are times where it can go a 
bit too far.  This is definitely a very simple example, but the usual Hello 
World script doesn't exactly need to be writen in a class structure.

I usually try to ask myself this question when I'm designing something:

What are the benefits of using OOP?

If the answer is simply To use OOP then you're probably headed in the wrong 
direction, at which point I step back and look at the big picture again.

In short, OOP is something to be used to your advantage, but if overused can 
just cause unnecessary overhead and confusion (IMO)

-- 
Ray Hauge
Application Development Lead
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Re: Re: Frustrated trying to get help from your site

2006-09-25 Thread Ray Hauge
On Friday 22 September 2006 16:48, Michelle Konzack wrote:
 Am 2006-09-22 13:36:40, schrieb Arno Kuhl:
  I'm not sure which examples you're referring to but if you mean the user
  contributed notes then the download documentation does include this - at

 Yes

  least one of the .chm versions does. It's great, but you need to download
  it

 .chm ?  -  Windows ??? Me??? plof

  regularly if you want the latest notes (obviously). Use one of the skins
  and it's even better (I use the phpZ skin which displays a tab for the
  user notes).

 You mean in winhlp32.exe ? Right ?

 It is a realy nice tool but unfortunatly for the false OS.

 I was already thinking on coding a linhelp program, but
 it seems there is one but I have not found it.

 I like to have html files which I can put on my internal
 documentation server.

 Greetings
 Michelle Konzack
 Systemadministrator
 Tamay Dogan Network
 Debian GNU/Linux Consultant

It's not the best in the world, but it works.

http://xchm.sourceforge.net/index.html

But since the documentation is online and always updated that way, I prefer to 
just use the website.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



  1   2   3   >