Re: [PHP] Help insert not working, implode errors....

2008-11-17 Thread Jim Lucas

Terion Miller wrote:

Help I inherited this script and just found that its not inserting anything
into the "workorderform" table in the db, and I'm getting implode() errors
for the 'bannersize' isset line

New and need help in over my head:
here is the code:




First off, I would argue that this code never worked, unless you changed the order of the arguments 
being passed to your implode() calls.


The arguments are backwards in all three calls.

check out this

http://php.net/implode

it might give you insight on how to make it work.

--
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
> Jochem Maas wrote:
>> must  . resist 
>>
>> "I take you didn't score to hig on the spelling test? and collage,
>> is that the the cut-n-paste school of IT?"
>>
>>  dang it, failed. ;-)
>>   
> 
> 
> Haha! 'high' was just my 'h' key not pressing, and college is just one
> of those words I have trouble with.

I demand credit for the utter brilliance of the cut-n-paste crack ;-)

> 
> I'm not illiterate; promise :p

:-)

> 
> - Craige

just for laughs .. given the 'dabble' thread "Cleeder" is phonetically
very very close to a dutch word meaning 'messing around' .. rather in the way
a 2yo might mess around with a bowl of yogurt.

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
tedd schreef:
> At 12:52 AM +0100 11/18/08, Jochem Maas wrote:
>> Craige Leeder schreef:
>>  > I'm 100% self taught for now. I'm just out of higschool, and hopefully
>>>  going off to collage next year.
>>
>> must  . resist 
>>
>> "I take you didn't score to hig on the spelling test? and collage,
>> is that the the cut-n-paste school of IT?"
>>
>>  dang it, failed. ;-)
> 
> Hang in there Jochem -- he's probably smarter than we were when we were
> his age.

pity the poor soul ;-) being clever only gets you deeper into 'dabble'. :-P

> Cheers,
> 
> tedd


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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Ross McKay
On Mon, 17 Nov 2008 11:43:31 -0800, Yeti wrote:

>Ok, ok I admit it. PHP is a programming language. I guess I drank too
>much assembly code today.
>By the way ... Motorola 68000! Those were to good old days.

680x0 was the nicest machine I ever met - especially nice when writing
for OS-9/68000. Yup, them was the daze...

My perspective: scripting can be "programming light" (or lite, if you're
illiterate and/or in marketing), but can just as easily be serious
programming. This is especially so, now that many scripting languages
support OO to some degree. Equally, I've seen some C code that I'd be
somewhat reticent to call "programming".

Programming isn't all about stacks of procedural code either; consider
declarative programming. (Yes, Ash, XHTML and CSS are effectively a form
of declarative programming!)

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

The trick with languages is to:

* pick the one (or more) appropriate for the task
* pick the design approach appropriate to the language (and other tools)

To be a decent web developer, with database-driven pages, one often has
to manage a design that spans multiple languages and sometimes more than
one programming paradigm. Consider a simple HTML input form sending
information to a database:

* (X)HTML for the page, including the input form
* CSS for managing layout and styling, even active menus etc.
* maybe some JavaScript for smart validation or field management
* server-side programming for accepting the form post
* maybe some database programming (SQL) for updating the database

Compound that with some mostly-declarative XSLT, Flash, Java, .htaccess
etc. and you've got a relatively complicated toolset that traditional
programmers scratch their heads over when initially making the switch
from their one-language development environment. (Frameworks strive to
clean that up for developers)

So, is PHP programming? :)
-- 
Ross McKay, Toronto, NSW Australia
"Pay no attention to that man behind the curtain" - Wizard of Oz

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



Re: [PHP] while question

2008-11-17 Thread Micah Gersten
Jay Blanchard wrote:
> [snip]
> ...foreach...
> [/snip]
>
> You could also use a for loop if you wanted to count;
>
> for($i = 0; $i < count($array); $i++){
>echo $i . "\n";
> }
>
>
>   

This is not good because you are calling count every loop iteration.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




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



Re: [PHP] while-question

2008-11-17 Thread tedd

At 7:02 PM -0500 11/17/08, Craige Leeder wrote:

I'm not illiterate; promise :p

- Craige



Yeah, his parents were married before he was born.

Cheers,

tedd



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

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



Re: [PHP] while-question

2008-11-17 Thread tedd

At 12:52 AM +0100 11/18/08, Jochem Maas wrote:

Craige Leeder schreef:
 > I'm 100% self taught for now. I'm just out of higschool, and hopefully

 going off to collage next year.


must  . resist 

"I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?"

 dang it, failed. ;-)


Hang in there Jochem -- he's probably smarter than we were when we 
were his age.


Cheers,

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

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread tedd

At 11:40 AM +1100 11/18/08, Ross McKay wrote:

On Mon, 17 Nov 2008 14:30:34 -0500, tedd.sperling wrote:


I can program with rocks -- and do a good job of it. I can make a one
that can stand for a couple of thousand years.


http://xkcd.com/505/



Ross:

That's super and fits.

The only difference in the comic was the programmer was using zeros 
(absence of rock). That technical advancement came after I started 
programming.


Cheers,

tedd

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

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread tedd

At 10:49 PM + 11/17/08, Ashley Sheridan wrote:

So just trolling here, but do conditional comments in HTML make it a
programming language? :p


Why not?

Sure, it's a mark-up language but if you don't program it right, it 
will screw up -- it's just more forgiving than most. Also, CSS is a 
programming language and it doesn't have any conditional branching 
other than browser hacks. If you think either of those two are not 
languages, then I think you're underestimating their power.


I think the division between what is/isn't a computer language is 
somewhat blurred today as compared as to what it used to be.


I remember we had the types who said that if you weren't programming 
on a mainframe, then you weren't programming. Others said if it's not 
compiled, then it's not a real application either. Both statement 
were equally lame.


There has always been (probably always will be) those who want to 
separate people into different camps based upon their opinion -- but 
so what? Who cares? I don't.


Over the years, I've had an assortment of clients who knew nothing 
about computer languages, but insisted on a specific language because 
of their limited understanding. I even had one client where I 
provided the end application that did everything he wanted, but he 
refused to consider it because if was written in a language that his 
friends thought too basic. Yes it was BASIC, but it worked better 
than the C++ crap that his programmers eventually developed two years 
later.


My position -- give me a problem and get out of my way while I solve 
it. Some clients have problems with that and other don't. The ones 
that don't usually get a better product.


Cheers,

tedd

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

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Ross McKay
On Mon, 17 Nov 2008 14:30:34 -0500, tedd.sperling wrote:

>I can program with rocks -- and do a good job of it. I can make a one 
>that can stand for a couple of thousand years.

http://xkcd.com/505/
-- 
Ross McKay, Toronto, NSW Australia
"Before enlightenment: chop wood, carry water;
 After enlightenment: chop wood, carry water" - Wu Li

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



Re: [PHP] while question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
> Ashley Sheridan wrote:
>> On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
>>  
>>> Only thing to note with the foreach is that you are actually working
>>> on a copy of the array, so if you intend to modify it, pass it by
>>> reference.
>>>
>>> - Craige
>>> 
>> Can you do that? I assume it would look like this:
>>
>> foreach(&$array as $a) {}
>>   
> 
> Close. It actually looks like this:
> 
> foreach ($array as $key => &$value)  {}
> 
> This makes sense because for each  iteration of the loop, PHP places a
> copy of the key in $key, and a copy of the value in $value. Therefor,
> you are specifying with this code that you want it to place a reference
> of the value into $value.

indeed but beware, using a variable named $value after such a foreach loop
in the same scope will lead to all sorts of things you don't expect.

> 
> - Craige
> 
> 
> 


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



RE: [PHP] web shot script

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 18:48 -0500, Joey wrote:
> Sorry for the delay.
> 
> The purpose is to be able to see what is running on a site at any given time.
> If we are webhosting we want to make sure something is live or not and see 
> the whole page, without visiting each and every site.  Plus the sites might 
> change so we want to know at any given time.
> 
> > -Original Message-
> > From: Jim Lucas [mailto:[EMAIL PROTECTED]
> > Sent: Friday, October 24, 2008 11:48 AM
> > To: Andrew Barnett
> > Cc: Afan Pasalic; Joey; PHP
> > Subject: Re: [PHP] web shot script
> > 
> > Andrew Barnett wrote:
> > > You might actually be onto something there Afan.
> > >
> > > As long as Ghostscript and Imagemagick are installed on the server, you 
> > > will
> > > be able to convert a PDF to an image. So maybe that will help.
> > >
> > > Although, is it possible to have a continuous length PDF, or does it only
> > > fit to specific page sizes.
> > >
> > > Its probably worth a shot though Joey.
> > >
> > >
> > > Andrew
> > >
> > 
> > Isn't the idea of getting different screen shots about SEEING how the page
> > looks on various system configurations?  Windows, Mac, *nix then throw in
> > various browsers like IE, FF, Opera, Google?
> > 
> > This is the service that I thought these other companies provided.  You 
> > could
> > probably do something like this on one computer by having VMWare (or 
> > similar)
> > software running to see all the different renderings.
> > 
> > --
> > Jim Lucas
> > 
> >"Some men are born to greatness, some achieve greatness,
> >and some have greatness thrust upon them."
> > 
> > Twelfth Night, Act II, Scene V
> > by William Shakespeare
> 
> 
> 
Why don't you set up a cron job (can be on any computer, doesn't have to
be the server) that just grabs a page from a list of sites using wget.
You could then check for the response codes for any problems, and
possible add a grep in there to make sure the site is not showing any
errors?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while-question

2008-11-17 Thread Craige Leeder

Jochem Maas wrote:

must  . resist 

"I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?"

 dang it, failed. ;-)
  



Haha! 'high' was just my 'h' key not pressing, and college is just one 
of those words I have trouble with.



I'm not illiterate; promise :p

- Craige

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



[PHP] Re: $60 Reward, 1 Hour Eclipse Project

2008-11-17 Thread johny why
Thanks Nathan, but as I mentioned, I AM using the Zend Eclipse debugging 
plugin.


Using the Zend internal php debugger does not "save" me the trouble of 
running a web-server. The point is, i NEED to perform the code step-through 
on my IIS server, because that is my real-world production environment, and 
that is where my php application is failing.


I'm not seeking advice or tutorials. I'm asking for a real-time walkthrough. 



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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
tedd schreef:
> At 10:00 AM -0800 11/17/08, bruce wrote:
>> curious qiestion
>>
>> to all on here who dabble in php... how many of you have actully gone to
>> college, taken algorithm courses, microprocessor courses,
>> design/architecture courses, etc..
>>
>> or is the majority of the work here from people who've grabbed the
>> tools and
>> started programming... ?
> 
> 
> Dabbling?

Im neck deep in dabble every other week .. obviously it's always
someone else dabble ;-)


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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
> bruce wrote:
>> curious qiestion
>>
>> to all on here who dabble in php... how many of you have actully gone to
>> college, taken algorithm courses, microprocessor courses,
>> design/architecture courses, etc..
>>
>> or is the majority of the work here from people who've grabbed the
>> tools and
>> started programming... ?
>>   
> 
> I'm 100% self taught for now. I'm just out of higschool, and hopefully
> going off to collage next year.

must  . resist 

"I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?"

 dang it, failed. ;-)


> Everything I've learned at this stage is from books, tutorials, and
> experience.
> 
> - Craige
> 


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



[PHP] Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

2008-11-17 Thread Jochem Maas
Christopher Vogt schreef:
> Hej Jochem,
> 
>> this kind of thing belongs on php-general (and lets keep it on list
>> please), if you have a serious proposal/rfc and/or one develops from a 
>> discussion
>> there then likely some of the old-hats will likely recommend escalating to
>> internal.
> 
> I'm sorry I wasn't aware of this "procedure". I will start discussions
> on general@ from now on.
> 
>>> But the question remains. Are there reasons to have a Fatal error here?
>> yes, it tells you your doing something impossible.
> 
> Well yes, but this does not mean it has to terminate. It could skip it
> instead.

well I suppose, but then that comes down to 'you can implement a language
to do pretty much whatever you want' theoretically.

most likely there are BC issues, performance issues and technical limitations
that dictate E_FATAL in the case.

>>> For comparison: Python throws an exception in a comparable case,
>>> allowing me to handle the error.
>> PHP != Python. python is pure OO. php is hybrid. you have to refactor your
>> code in different ways.
> 
> Python is, just as PHP, a multi-paradigm language. Both support
> procedural, OOP and even functional programming styles.

fair enough, but php's engine doesn't and will not (AFAIKT from core dev team
stance) throw exceptions (although some new OO extensions do and/or can), the
engine triggers errors.

you want it to trigger exceptions, fine. simply throw an exception if your
object factory can't build the requested object.

>> what this comes down to is this, python gives you exceptions free of
>> charge, php asks you to implement and throw them yourself ...
> 
> You are right. This seems to be, what it comes down too. I can't say
> that I am happy with it. And I think being able to handle fatal errors,
> whenever possible would be a very useful feature.
> 
> What about E_RECOVERABLE_ERROR, couldn't calling a method on a
> non-object trigger E_RECOVERABLE_ERROR, instead of E_ERROR?

E_FATAL means the engine is in an unrecoverable state - they can't be handled in
the php code by their very definition, whether this is strictly true in this 
case
I don't know. E_RECOVERABLE_ERROR was introduced long after it was decided
E_FATAL must/should be used in the described scenario.

if you really think the behaviour could be changed without breaking BC by all
means submit a patch ... if it's good and the argumentation sound the core devs
may accept it, otherwise change your code to work with the implementation that
exists rather than complain that php is not like .
no?


> 
> Best regards
> 
> Christopher
> 


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



Re: [PHP] while-question

2008-11-17 Thread Craige Leeder

bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?
  


I'm 100% self taught for now. I'm just out of higschool, and hopefully 
going off to collage next year.


Everything I've learned at this stage is from books, tutorials, and 
experience.


- Craige

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



RE: [PHP] web shot script

2008-11-17 Thread Joey
Sorry for the delay.

The purpose is to be able to see what is running on a site at any given time.
If we are webhosting we want to make sure something is live or not and see the 
whole page, without visiting each and every site.  Plus the sites might change 
so we want to know at any given time.

> -Original Message-
> From: Jim Lucas [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 24, 2008 11:48 AM
> To: Andrew Barnett
> Cc: Afan Pasalic; Joey; PHP
> Subject: Re: [PHP] web shot script
> 
> Andrew Barnett wrote:
> > You might actually be onto something there Afan.
> >
> > As long as Ghostscript and Imagemagick are installed on the server, you will
> > be able to convert a PDF to an image. So maybe that will help.
> >
> > Although, is it possible to have a continuous length PDF, or does it only
> > fit to specific page sizes.
> >
> > Its probably worth a shot though Joey.
> >
> >
> > Andrew
> >
> 
> Isn't the idea of getting different screen shots about SEEING how the page
> looks on various system configurations?  Windows, Mac, *nix then throw in
> various browsers like IE, FF, Opera, Google?
> 
> This is the service that I thought these other companies provided.  You could
> probably do something like this on one computer by having VMWare (or similar)
> software running to see all the different renderings.
> 
> --
> Jim Lucas
> 
>"Some men are born to greatness, some achieve greatness,
>and some have greatness thrust upon them."
> 
> Twelfth Night, Act II, Scene V
> by William Shakespeare



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



[PHP] Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

2008-11-17 Thread Christopher Vogt
Hej Jochem,

> this kind of thing belongs on php-general (and lets keep it on list
> please), if you have a serious proposal/rfc and/or one develops from a 
> discussion
> there then likely some of the old-hats will likely recommend escalating to
> internal.

I'm sorry I wasn't aware of this "procedure". I will start discussions
on general@ from now on.

>> But the question remains. Are there reasons to have a Fatal error here?
> 
> yes, it tells you your doing something impossible.

Well yes, but this does not mean it has to terminate. It could skip it
instead.

>> For comparison: Python throws an exception in a comparable case,
>> allowing me to handle the error.
> 
> PHP != Python. python is pure OO. php is hybrid. you have to refactor your
> code in different ways.

Python is, just as PHP, a multi-paradigm language. Both support
procedural, OOP and even functional programming styles.

> what this comes down to is this, python gives you exceptions free of
> charge, php asks you to implement and throw them yourself ...

You are right. This seems to be, what it comes down too. I can't say
that I am happy with it. And I think being able to handle fatal errors,
whenever possible would be a very useful feature.

What about E_RECOVERABLE_ERROR, couldn't calling a method on a
non-object trigger E_RECOVERABLE_ERROR, instead of E_ERROR?

Best regards

Christopher


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



Re: [PHP] while question

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 18:01 -0500, Craige Leeder wrote:
> Ashley Sheridan wrote:
> > On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
> >   
> >> Only thing to note with the foreach is that you are actually working on 
> >> a copy of the array, so if you intend to modify it, pass it by reference.
> >>
> >> - Craige
> >> 
> > Can you do that? I assume it would look like this:
> >
> > foreach(&$array as $a) {}
> >   
> 
> Close. It actually looks like this:
> 
> foreach ($array as $key => &$value)  {}
> 
> This makes sense because for each  iteration of the loop, PHP places a 
> copy of the key in $key, and a copy of the value in $value. Therefor, 
> you are specifying with this code that you want it to place a reference 
> of the value into $value.
> 
> - Craige
> 
> 
> 
Ah, that could be very useful to know, thanks!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while question

2008-11-17 Thread Craige Leeder

Ashley Sheridan wrote:

On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
  
Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige


Can you do that? I assume it would look like this:

foreach(&$array as $a) {}
  


Close. It actually looks like this:

foreach ($array as $key => &$value)  {}

This makes sense because for each  iteration of the loop, PHP places a 
copy of the key in $key, and a copy of the value in $value. Therefor, 
you are specifying with this code that you want it to place a reference 
of the value into $value.


- Craige



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



RE: [PHP] Date Issue

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 16:57 -0600, Boyd, Todd M. wrote:
> > -Original Message-
> > From: Craige Leeder [mailto:[EMAIL PROTECTED]
> > Sent: Monday, November 17, 2008 4:50 PM
> > To: Boyd, Todd M.
> > Cc: [EMAIL PROTECTED]; php-general@lists.php.net
> > Subject: Re: [PHP] Date Issue
> > 
> > Boyd, Todd M. wrote:
> > >> Are you sure this isn't like Javascript's "getMonth" function? Its
> > index may begin at 0, making "day 0" the "first day" of the year.
> > >>
> > Hmm, though I know us programmers love to start counting at zero, why
> > would something as static as a date start counting at zero? I would
> > have
> > imagined something like that would start at 1.
> 
> I dunno. Threw me for a hell of a loop (no pun intended) when I first started 
> playing with Javascript dates, though. Year = starts at 1 (not literally, but 
> for all intents and purposes). Day = starts at 1. Month = starts at 0? What?! 
> :)
> 
> 
> // Todd
It makes no sense does it?! I was lucky enough to have an Oreilly book
with me at the time I was learning javascript. Only book of theirs i
wasnt so hot on was an ajax one.


Ash
www.ashleysheridan.co.uk


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



RE: [PHP] Date Issue

2008-11-17 Thread Boyd, Todd M.
> -Original Message-
> From: Craige Leeder [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 17, 2008 4:50 PM
> To: Boyd, Todd M.
> Cc: [EMAIL PROTECTED]; php-general@lists.php.net
> Subject: Re: [PHP] Date Issue
> 
> Boyd, Todd M. wrote:
> >> Are you sure this isn't like Javascript's "getMonth" function? Its
> index may begin at 0, making "day 0" the "first day" of the year.
> >>
> Hmm, though I know us programmers love to start counting at zero, why
> would something as static as a date start counting at zero? I would
> have
> imagined something like that would start at 1.

I dunno. Threw me for a hell of a loop (no pun intended) when I first started 
playing with Javascript dates, though. Year = starts at 1 (not literally, but 
for all intents and purposes). Day = starts at 1. Month = starts at 0? What?! :)


// Todd


Re: [PHP] Variable Argument List

2008-11-17 Thread Craige Leeder

Richard Heyes wrote:

yup..
Warning:  func_get_args():  Called from the global scope - no
function context



Doesn't the name of the function give you a clue as to its use? You
need to call it inside a function.

  
He was answering Nathan's question regarding what would happen IF you 
called it outside a function. He wasn't actually stupid enough to call 
it outside a function in actual code.


- Craige

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



[PHP] Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

2008-11-17 Thread Christopher Vogt
Hej Stefan,

>> This was/is a question if something is worth a change request. This
>> concerns the development of PHP and in my eyes belongs on internals. Am
>> I mistaken here?
> 
> Yes, because you are like the 100th person to request that. A mail to
> general@ probably would have told you that.

I am sorry about that. I'll first consult general@ in the future.

Best regards

Christopher

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



Re: [PHP] Help insert not working, implode errors....

2008-11-17 Thread Ashley Sheridan
My eyes are bleeding!

Did you ever see it working before?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Date Issue

2008-11-17 Thread Craige Leeder

Boyd, Todd M. wrote:

Are you sure this isn't like Javascript's "getMonth" function? Its index may begin at 0, making 
"day 0" the "first day" of the year.

HTH,


Todd Boyd
Web Programmer

Hmm, though I know us programmers love to start counting at zero, why 
would something as static as a date start counting at zero? I would have 
imagined something like that would start at 1.


Guess it's just me.
- Craige

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



Re: [PHP] while question

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
> Alain Roger wrote:
> > Hi,
> >
> > i'm on PHP training and our lector is telling us that to avoid counting an
> > array item amout thanks count($my_array), he tells we can do:
> > while($my_array)
> > {
> >  ... do something
> > }
> > but from experience this is an infinity loop...
> >
> > it should be always something like
> > $count = count($my_array);
> > while($i <= $count)
> > {
> > ...
> > do something
> > ...
> > $i++;
> > }
> >
> > has someone already use such syntax ? i mean as the first one.
> > thx.
> >   
> While you teacher technically is wrong, you probably could implement 
> something using the next() and current() array functions, though you're 
> best to just use a foreach loop. foreach was designed specifically as an 
> array looping construct, so it's optimized pretty well.
> 
> Only thing to note with the foreach is that you are actually working on 
> a copy of the array, so if you intend to modify it, pass it by reference.
> 
> - Craige
> 
> 
> 
Can you do that? I assume it would look like this:

foreach(&$array as $a) {}


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while question

2008-11-17 Thread Craige Leeder

Alain Roger wrote:

Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.
  
While you teacher technically is wrong, you probably could implement 
something using the next() and current() array functions, though you're 
best to just use a foreach loop. foreach was designed specifically as an 
array looping construct, so it's optimized pretty well.


Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige



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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 20:20 +, Stut wrote:

> On 17 Nov 2008, at 19:43, Yeti wrote:
> > Ok, ok I admit it. PHP is a programming language. I guess I drank too
> > much assembly code today.
> > By the way ... Motorola 68000! Those were to good old days.
> 
> And my penis is way bigger than yours, but I digress.
> 
> Seriously tho, I define programming / coding / software development as  
> writing instructions for a computer to follow. I don't care whether  
> you do it in Perl, PHP, C, C++, Ruby, Python, COBOl or assembly,  
> you're programming.
> 
> If you feel that you need to demote people using certain languages to  
> less than programmers then 1) don't ever expect a job from me, and 2)  
> get over yourself and try living in the real world where the problem  
> that matters more than the solution.
> 
> -Stut
> 
> -- 
> http://stut.net/
> 

So just trolling here, but do conditional comments in HTML make it a
programming language? :p

Sorry, I couldn't resist. I deserve the wrath you lot bring down! ;)


Ash
www.ashleysheridan.co.uk


[PHP] Help insert not working, implode errors....

2008-11-17 Thread Terion Miller
Help I inherited this script and just found that its not inserting anything
into the "workorderform" table in the db, and I'm getting implode() errors
for the 'bannersize' isset line

New and need help in over my head:
here is the code:


 'OK' ){
header ("Location: LogOut.php");
}

if (isset($_POST['AdminID'])){
$AdminID = $_POST['AdminID'];
} elseif (isset($_GET['AdminID'])){
$AdminID = $_GET['AdminID'];
} else {
header ("Location: LogOut.php");
}

if (isset($_POST['GO'])){$GO = $_POST['GO'];} else {$GO = "";}
if (isset($_POST['Location'])){$Location = $_POST['Location'];} else
{$Location = "";}
{$errmsg = 'Please Select a Location';}
if (isset($_POST['WorkOrderName'])){$WorkOrderName =
$_POST['WorkOrderName'];} else {$WorkOrderName = "";}
if (isset($_POST['IONumber'])){$IONumber = $_POST['IONumber'];} else
{$IONumber = "";}
if (isset($_POST['OrderType'])){$OrderType =
implode($_POST['OrderType'],',');} else {$OrderType = "";}
if (isset($_POST['WorkOrderNumber'])){$WorkOrderNumber =
$_POST['WorkOrderNumber'];} else {$WorkOrderNumber = "";}
if (isset($_POST['Advertiser'])){$Advertiser = $_POST['Advertiser'];} else
{$Advertiser = "";}
if (isset($_POST['AccountNum'])){$AccountNum = $_POST['AccountNum'];} else
{$AccountNum = "";}
if (isset($_POST['Address'])){$Address = $_POST['Address'];} else {$Address
= "";}
if (isset($_POST['City'])){$City = $_POST['City'];} else {$City = "";}
if (isset($_POST['State'])){$State = $_POST['State'];} else {$State = "";}
if (isset($_POST['Zip'])){$Zip = $_POST['Zip'];} else {$Zip = "";}
if (isset($_POST['Phone'])){$Phone = $_POST['Phone'];} else {$Phone = "";}
if (isset($_POST['Fax'])){$Fax = $_POST['Fax'];} else {$Fax = "";}
if (isset($_POST['ContactName'])){$ContactName = $_POST['ContactName'];}
else {$ContactName = "";}
if (isset($_POST['URL'])){$URL = $_POST['URL'];} else {$URL = "";}
if (isset($_POST['AdvertisingAgency'])){$AdvertisingAgency =
$_POST['AdvertisingAgency'];} else {$AdvertisingAgency = "";}
if (isset($_POST['ClickThru'])){$ClickThru = $_POST['ClickThru'];} else
{$ClickThru = "";}
if (isset($_POST['Impressions'])){$Impressions = $_POST['Impressions'];}
else {$Impressions = "";}
if (isset($_POST['AdSize'])){$AdSize = $_POST['AdSize'];} else {$AdSize =
"";}
if (isset($_POST['StartMonth']) && isset($_POST['StartDay']) &&
isset($_POST['StartYear'])){
$StartDate = $_POST['StartYear'] ."-". $_POST['StartMonth'] ."-".
$_POST['StartDay'];
} else {
$StartDate = "";
}
if (isset($_POST['EndMonth']) && isset($_POST['EndDay']) &&
isset($_POST['EndYear'])){
$EndDate = $_POST['EndYear'] ."-". $_POST['EndMonth'] ."-".
$_POST['EndDay'];
} else {
$EndDate = "";
}
if (isset($_POST['CPM'])){$CPM = $_POST['CPM'];} else {$CPM = "";}
if (isset($_POST['FlatRate'])){$FlatRate = $_POST['FlatRate'];} else
{$FlatRate = "";}
if (isset($_POST['IncludeSites'])){$IncludeSites = $_POST['IncludeSites'];}
else {$IncludeSites = "";}
if (isset($_POST['Package'])){$Package = $_POST['Package'];} else {$Package
= "";}

if (isset($_POST['Salesperson'])){$Salesperson = $_POST['Salesperson'];}
else {$Salesperson = "";}
if (isset($_POST['SalespersonID'])){$SalespersonID =
$_POST['SalespersonID'];} else {$SalespersonID = "";}
if (isset($_POST['SalespersonEmail'])){$SalespersonEmail =
$_POST['SalespersonEmail'];} else {$SalespersonEmail = "";}
if (isset($_POST['SalespersonExt'])){$SalespersonExt =
$_POST['SalespersonExt'];} else {$SalespersonExt = "";}
if (isset($_POST['NameCampaign'])){$NameCampaign = $_POST['NameCampaign'];}
else {$NameCampaign = "";}
if (isset($_POST['SpecialInstructions'])){$SpecialInstructions =
$_POST['SpecialInstructions'];} else {$SpecialInstructions = "";}
if (isset($_POST['AdContactName'])){$AdContactName =
$_POST['AdContactName'];} else {$AdContactName = "";}
if (isset($_POST['AdContactPhone'])){$AdContactPhone =
$_POST['AdContactPhone'];} else {$AdContactPhone = "";}
if (isset($_POST['AdContactEmail'])){$AdContactEmail =
$_POST['AdContactEmail'];} else {$AdContactEmail = "";}
if (isset($_POST['Artwork'])){$Artwork = $_POST['Artwork'];} else {$Artwork
= "";}
if (isset($_POST['PrintMonth']) && isset($_POST['PrintDay']) &&
isset($_POST['PrintYear'])){
$PrintDate = $_POST['PrintYear'] ."-". $_POST['PrintMonth'] ."-".
$_POST['PrintDay'];
} else {
$PrintDate = "";
}
if (isset($_POST['ElectronicAd'])){$ElectronicAd = $_POST['ElectronicAd'];}
else {$ElectronicAd = "";}
if (isset($_POST['EmailProof'])){$EmailProof = $_POST['EmailProof'];} else
{$EmailProof = "";}
if (isset($_POST['ProofMonth']) && isset($_POST['ProofDay']) &&
isset($_POST['ProofYear'])){
$ProofDate = $_POST['ProofYear'] ."-". $_POST['ProofMonth'] ."-".
$_POST['ProofDay'];
} else {
$ProofDate = "";
}
if (isset($_POST['ArtInstructions'])){$ArtInstructions =
$_POST['ArtInstructions'];} else {$ArtInstructions = "";}
if (isset($_POST['Focus'])){$Focus = $_POST['Focus'];} else {$Focus = "";}
if (isset($_POST['BannerSize'])){$BannerSize =
implode($_POST['BannerSize'],',')

RE: [PHP] while-question

2008-11-17 Thread tedd

At 2:55 PM -0500 11/17/08, Wolf wrote:
Tedd, glad you got hooked on Phonics.  One of these days I hope from 
graduating from just looking at the pictures, but right now the 
pictures are oh so enticing!. ;) 


Wolf


Wolf:

Lot's of exciting things -- hard to keep up on bots, automated 
buying, data mining, and other such things that make my head hurt.


Cheers,

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

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread tedd

At 8:20 PM + 11/17/08, Stut wrote:

On 17 Nov 2008, at 19:43, Yeti wrote:

Ok, ok I admit it. PHP is a programming language. I guess I drank too
much assembly code today.


Seriously tho, I define programming / coding / software development 
as writing instructions for a computer to follow. I don't care 
whether you do it in Perl, PHP, C, C++, Ruby, Python, COBOl or 
assembly, you're programming.


If you feel that you need to demote people using certain languages 
to less than programmers then 1) don't ever expect a job from me, 
and 2) get over yourself and try living in the real world where the 
problem that matters more than the solution.


-Stut



And the computer does not have to be electronic nor the language written.

Cheers,

tedd

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

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Stut

On 17 Nov 2008, at 19:43, Yeti wrote:

Ok, ok I admit it. PHP is a programming language. I guess I drank too
much assembly code today.
By the way ... Motorola 68000! Those were to good old days.


And my penis is way bigger than yours, but I digress.

Seriously tho, I define programming / coding / software development as  
writing instructions for a computer to follow. I don't care whether  
you do it in Perl, PHP, C, C++, Ruby, Python, COBOl or assembly,  
you're programming.


If you feel that you need to demote people using certain languages to  
less than programmers then 1) don't ever expect a job from me, and 2)  
get over yourself and try living in the real world where the problem  
that matters more than the solution.


-Stut

--
http://stut.net/

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



RE: [PHP] while-question

2008-11-17 Thread Wolf
> Dabbling?
> 
> I think that making a living from it isn't dabbling, so I may not be 
> qualified to speak for the dabblers.
> 
> But for me, I was writing code before there were such courses. Later, 
> when I went to college I was taught adventures in keypunching and 
> received several "next to worthless" degrees.
> 
> I say "next to worthless" only because what they taught really wasn't 
> applicable to real world programming. As for management, clients, and 
> hr types, the degrees mattered, but not for much more than that.
> 
> In any event, I doubt if any college courses are keeping up with 
> current web technology -- there has always been a lag between what's 
> practiced and what's taught. What I've seen of college web sites, 
> seems to support that claim.
> 
> If I was taught in college all I needed to know, then what am I doing 
> with these dozens of web books scattered about my office? I probably 
> read a new book every other week.

I don't "dabble" in it either, unless you consider making my living from being 
a dabbler, in which case I'll continue to dabble and see the pay for it.  My 
alma-mater tried to stay current to some degree, but when they let someone who 
wrote the C++ book try to teach it, well they gave that person more rope then 
they needed.

Tedd, glad you got hooked on Phonics.  One of these days I hope from graduating 
from just looking at the pictures, but right now the pictures are oh so 
enticing!. ;)  

Wolf

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Yeti
Ok, ok I admit it. PHP is a programming language. I guess I drank too
much assembly code today.
By the way ... Motorola 68000! Those were to good old days.

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



RE: [PHP] Experience (was: while-question)

2008-11-17 Thread Boyd, Todd M.
> -Original Message-
> From: Yeti [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 17, 2008 1:23 PM
> To: Boyd, Todd M.; PHP General Mailing List
> Subject: Re: [PHP] Experience (was: while-question)
> 
> who says PHP means programming?
> All I see is script code, unless you write your own extension or you
> contribute to php-internal

Well, now, you're just splitting hairs. Programming, scripting,
coding--whatever you want to call it. They all involve similar methods.
I made a program in VB.NET that takes a text file list of phone numbers
and creates a geocoded XML tree by state, areacode, prefix, and finally
extension. I compiled it into an executable. That was programming, yes?
I then took that exact same code (the only part that changed was the
output--it streams as an XML attachment instead of creating the output
file on the local file system), and created an ASP.NET web site out of
it. That wasn't programming?


Todd Boyd
Web Programmer

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 11:23 -0800, Yeti wrote:
> who says PHP means programming?
> All I see is script code, unless you write your own extension or you
> contribute to php-internal

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

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread tedd

At 11:23 AM -0800 11/17/08, Yeti wrote:

who says PHP means programming?


Who says it doesn't?

I can program with rocks -- and do a good job of it. I can make a one 
that can stand for a couple of thousand years.


Show me code that can last longer.

Cheers,

tedd

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

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



RE: [PHP] while-question

2008-11-17 Thread tedd

At 10:00 AM -0800 11/17/08, bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?



Dabbling?

I think that making a living from it isn't dabbling, so I may not be 
qualified to speak for the dabblers.


But for me, I was writing code before there were such courses. Later, 
when I went to college I was taught adventures in keypunching and 
received several "next to worthless" degrees.


I say "next to worthless" only because what they taught really wasn't 
applicable to real world programming. As for management, clients, and 
hr types, the degrees mattered, but not for much more than that.


In any event, I doubt if any college courses are keeping up with 
current web technology -- there has always been a lag between what's 
practiced and what's taught. What I've seen of college web sites, 
seems to support that claim.


If I was taught in college all I needed to know, then what am I doing 
with these dozens of web books scattered about my office? I probably 
read a new book every other week.


Cheers,

tedd

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

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



Re: [PHP] Experience (was: while-question)

2008-11-17 Thread Yeti
who says PHP means programming?
All I see is script code, unless you write your own extension or you
contribute to php-internal

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



Re: [PHP] while-question

2008-11-17 Thread Nathan Rixham

bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?



the bulk of it self taught and via vast amounts of reading and many 
years of on the job experience (needs must), some formal education in 
the form of a year wasted getting a diploma whenst I was young (mainly 
as the topics covered where out of date and unused in general business).


HOWEVER, (a big one) I've recently converted, never really been an 
advocate of formal training until recently; I would highly recommend 
taking some certification courses (zend, sun, mysql etc), and some 
formal study on the finer details of programming / architecture.


If I could do it all again I'd do both, work to get experience and 
challeges, read the great books and the manuals, and get certified 
properly at the same time.


finally, using good tools makes a vast difference, for instance I use 
eclipse + pdt + zend eclipse debugger + svn + rse + bugzilla + mylyn + 
phpdoc + phpunit (adding in ant + cruise control to the mix soon for 
continuous integration)


[snip myself]

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



Re: [PHP] Variable Argument List

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 11:54 -0500, Shiplu wrote:
> On Fri, Nov 14, 2008 at 8:13 PM, Daniel Kolbo <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I am trying to do something like the following:
> >
> >  >
> > function hello($var1 = 'default1', $var2 = 'default2') {
> >   echo "$var1:$var2";
> > }
> >
> > $func= "hello";
> > $args = "'yo','bob'";
> > $func($args);
> >
> > ?>
> >
> > I understand why this outputs:
> > 'yo','bob':default2
> > However, I want it to output:
> > yo:bob
> >
> > Is this possible? I tried using different combinations of {}, but I cannot
> > seem to get it to happen.  I need some kind of "preprocessor" feature
> > perhaps.
> 
> Its possible. use eval.
> 
> eval("$func($args);");

If you used eval in the above statement (yes, you did) then you answered
the problem incorrectly:



Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



RE: [PHP] Experience (was: while-question)

2008-11-17 Thread Boyd, Todd M.
> -Original Message-
> From: bruce [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 17, 2008 12:00 PM
> To: 'Robert Cummings'; 'Stut'
> Cc: 'Nathan Rixham'; php-general@lists.php.net
> Subject: RE: [PHP] while-question
> 
> curious qiestion
> 
> to all on here who dabble in php... how many of you have actully gone
> to
> college, taken algorithm courses, microprocessor courses,
> design/architecture courses, etc..
> 
> or is the majority of the work here from people who've grabbed the
> tools and
> started programming... ?

Currently in college seeking a Computer Information Systems degree
(Bachelor of Science). I will then continue into the Masters' program.
I've taken courses on Database Systems, Decision Support Systems and
Warehouse Management, Programming and Algorithms, Advanced Algorithms,
Assembly Language (Motorola 68000), Operating Systems (Win32/POSIX),
Systems Analysis, and Software Engineering (I'm sure I'm missing a
couple from early college and high school... Pascal, VB, etc., but
whatev). When I get my first degree, I will have added Artificial
Intelligence, Systems Design, and Distributed Computing to that list.

However--I have not been taught one lick of PHP in college. Then again,
I think the language has very little to do with the program's power;
it's mostly up to the programmer and his/her methods.


Todd Boyd
Web Programmer

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



Re: [PHP] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 19:07 +0100, Jochem Maas wrote:
> Robert Cummings schreef:
> > On Mon, 2008-11-17 at 14:54 +, Stut wrote:
> >> On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
> >>> if you really want a challenge try this one..
> >>>
> >>> task: add the numbers 5 and 17 together, using php, without using  
> >>> the + operator. fill it in:
> >>>
> >>> function add($a , $b) {
> >>> //code here but no + - / * operators
> >>> return $answer;
> >>> }
> >>>
> >>> echo add(5, 17);
> >> Elemental my dear Mr Rixham...
> > 
> > What level is that elemental?
> 
> well it's all bitwise operating ... can't get much more
> elemental that a bit in CS. but I think he meant to
> say elementary (assuming the Sherlocks Holmes catchphrase)
> 
> > 
> >> function add($a , $b)
> >> {
> >>$answer = $a ^ $b;
> >>while (0 != ($a & $b))
> >>{
> >>  $b = ($a & $b) << 1;
> >>  $answer = $answer ^ $b;
> >>}
> >>return $answer;
> >> }
> 
> nice, I think :P
> 
> > He only said you couldn't use the + operator... nothing was said about
> > using the - operator.
> 
> 
> //code here but no + - / * operators
> 

Oh... duh! :) You know what they say, if you're going to say something,
say it all in one place, not part of something in one place, and the
rest later on. Not everyone reads to the end you insensitive clod ;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



RE: [PHP] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 10:00 -0800, bruce wrote:
> curious qiestion
> 
> to all on here who dabble in php... how many of you have actully gone to
> college, taken algorithm courses, microprocessor courses,
> design/architecture courses, etc..
> 
> or is the majority of the work here from people who've grabbed the tools and
> started programming... ?

I think it's a mixed crowd here. I have a Bachelor of Computer Science.
The various algorithms courses were some of my favourite courses in the
program along with parallel and distributed computing.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Robert Cummings schreef:
> On Mon, 2008-11-17 at 14:54 +, Stut wrote:
>> On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
>>> if you really want a challenge try this one..
>>>
>>> task: add the numbers 5 and 17 together, using php, without using  
>>> the + operator. fill it in:
>>>
>>> function add($a , $b) {
>>> //code here but no + - / * operators
>>> return $answer;
>>> }
>>>
>>> echo add(5, 17);
>> Elemental my dear Mr Rixham...
> 
> What level is that elemental?

well it's all bitwise operating ... can't get much more
elemental that a bit in CS. but I think he meant to
say elementary (assuming the Sherlocks Holmes catchphrase)

> 
>> function add($a , $b)
>> {
>>$answer = $a ^ $b;
>>while (0 != ($a & $b))
>>{
>>  $b = ($a & $b) << 1;
>>  $answer = $answer ^ $b;
>>}
>>return $answer;
>> }

nice, I think :P

> He only said you couldn't use the + operator... nothing was said about
> using the - operator.


//code here but no + - / * operators




> 
> $total = -(-5 - 17);
> 
> Cheers,
> Rob.


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



RE: [PHP] while-question

2008-11-17 Thread bruce
curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17, 2008 9:53 AM
To: Stut
Cc: Nathan Rixham; php-general@lists.php.net
Subject: Re: [PHP] while-question


On Mon, 2008-11-17 at 14:54 +, Stut wrote:
> On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
> > if you really want a challenge try this one..
> >
> > task: add the numbers 5 and 17 together, using php, without using
> > the + operator. fill it in:
> >
> > function add($a , $b) {
> > //code here but no + - / * operators
> > return $answer;
> > }
> >
> > echo add(5, 17);
>
> Elemental my dear Mr Rixham...

What level is that elemental?

> function add($a , $b)
> {
>$answer = $a ^ $b;
>while (0 != ($a & $b))
>{
>  $b = ($a & $b) << 1;
>  $answer = $answer ^ $b;
>}
>return $answer;
> }

He only said you couldn't use the + operator... nothing was said about
using the - operator.

$total = -(-5 - 17);

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for 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] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 14:54 +, Stut wrote:
> On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
> > if you really want a challenge try this one..
> >
> > task: add the numbers 5 and 17 together, using php, without using  
> > the + operator. fill it in:
> >
> > function add($a , $b) {
> > //code here but no + - / * operators
> > return $answer;
> > }
> >
> > echo add(5, 17);
> 
> Elemental my dear Mr Rixham...

What level is that elemental?

> function add($a , $b)
> {
>$answer = $a ^ $b;
>while (0 != ($a & $b))
>{
>  $b = ($a & $b) << 1;
>  $answer = $answer ^ $b;
>}
>return $answer;
> }

He only said you couldn't use the + operator... nothing was said about
using the - operator.

$total = -(-5 - 17);

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] Re: Accented character in Regex.

2008-11-17 Thread Nathan Rixham

Nathan Rixham wrote:

Shiplu wrote:

How to match accented characters by preg match?? I need to match ">Sin
garantía<" by "/>([^<]+)
convert to utf8 and use the U modifier on the regex string?


sorry.. lowercase "u" for utf8! (U is ungreedy)

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



Re: [PHP] Date Issue

2008-11-17 Thread Nathan Rixham

Boyd, Todd M. wrote:

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17, 2008 10:50 AM
To: php-general@lists.php.net
Subject: [PHP] Date Issue

$smont = 10;
$sday = 13;
$syear = 2008;
$timestamp = mktime(0,0,0,$smont,$sday,$syear);
$thismonth = getdate($timestamp);

Here is where the problem comes into play.

echo $thismonth['yday'];

This displays 286 when in fact its 287.
Is there a problem in my ini file or what is the deal.


Are you sure this isn't like Javascript's "getMonth" function? Its index may begin at 0, making 
"day 0" the "first day" of the year.

HTH,


Todd Boyd
Web Programmer


yup..



(it is a leap year)
so recap: yday 0 = 1st jan

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



[PHP] Accented character in Regex.

2008-11-17 Thread Shiplu
How to match accented characters by preg match?? I need to match ">Sin
garantía<" by "/>([^<]+)http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

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



[PHP] Re: Accented character in Regex.

2008-11-17 Thread Nathan Rixham

Shiplu wrote:

How to match accented characters by preg match?? I need to match ">Sin
garantía<" by "/>([^<]+)
convert to utf8 and use the U modifier on the regex string?

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



[PHP] Re: while question

2008-11-17 Thread tedd

At 2:25 PM + 11/17/08, Nathan Rixham wrote:


sounds like a poor teacher


It's more likely a poor student who wants us to answer the questions, 
but hasn't the time to investigate the answer OR write a question 
more correctly himself.


Cheers,

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

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



Re: [PHP] Variable Argument List

2008-11-17 Thread Richard Heyes
> yup..
> Warning:  func_get_args():  Called from the global scope - no
> function context

Doesn't the name of the function give you a clue as to its use? You
need to call it inside a function.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 15th)

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



RE: [PHP] Date Issue

2008-11-17 Thread Boyd, Todd M.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 17, 2008 10:50 AM
> To: php-general@lists.php.net
> Subject: [PHP] Date Issue
> 
> $smont = 10;
> $sday = 13;
> $syear = 2008;
> $timestamp = mktime(0,0,0,$smont,$sday,$syear);
> $thismonth = getdate($timestamp);
> 
> Here is where the problem comes into play.
> 
> echo $thismonth['yday'];
> 
> This displays 286 when in fact its 287.
> Is there a problem in my ini file or what is the deal.

Are you sure this isn't like Javascript's "getMonth" function? Its index may 
begin at 0, making "day 0" the "first day" of the year.

HTH,


Todd Boyd
Web Programmer


Re: [PHP] Variable Argument List

2008-11-17 Thread Shiplu
On Fri, Nov 14, 2008 at 8:13 PM, Daniel Kolbo <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to do something like the following:
>
> 
> function hello($var1 = 'default1', $var2 = 'default2') {
>   echo "$var1:$var2";
> }
>
> $func= "hello";
> $args = "'yo','bob'";
> $func($args);
>
> ?>
>
> I understand why this outputs:
> 'yo','bob':default2
> However, I want it to output:
> yo:bob
>
> Is this possible? I tried using different combinations of {}, but I cannot
> seem to get it to happen.  I need some kind of "preprocessor" feature
> perhaps.

Its possible. use eval.

eval("$func($args);");

>
> Thanks,
> dK
>



-- 
Blog: http://talk.cmyweb.net/ Follow me: http://twitter.com/shiplu

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



[PHP] Date Issue

2008-11-17 Thread admin
$smont = 10;
$sday = 13;
$syear = 2008;
$timestamp = mktime(0,0,0,$smont,$sday,$syear);
$thismonth = getdate($timestamp);

Here is where the problem comes into play.

echo $thismonth['yday'];

This displays 286 when in fact its 287.
Is there a problem in my ini file or what is the deal.

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



RE: [PHP] Another question about Google maps

2008-11-17 Thread tedd

At 8:37 AM -0600 11/17/08, Boyd, Todd M. wrote:

tedd, I think it might be displaying your extra divs (if there are any..
just skimmed the source momentarily) for a split second before they are
hidden with Javascript. Maybe try setting the CSS for your 3 map divs
(mapsearch, idlediv, searchdiv or whatever) to display:none and show
them when the page is loaded? Or give all 3 the same top/left
coordinates, etc...

Just a shot in the dark. I may read over the code a bit more if I get
some time later today. I'm no expert, but I've been working with the
Google Maps API rather extensively lately, and maybe I can offer a fresh
set of eyes.

HTH,


Todd Boyd
Web Programmer


Todd:

That would be great. Also, if you see anything there you like, of 
course you may use it.


I think the div's are Okay -- I always check my code through the W3C 
validator and that does a good job of checking that. I wish that 
Google and W3C would decide on what's "acceptable".


I also tried "display: none" via css, but could not get the right 
combination of hide/display to make it work right. However, I'll look 
into your suggestion.


If you can find anything to correct, that would be good. But it's 
just a minor annoyance and I thought someone might readily know what 
the problem was.


Cheers,

tedd

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

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



Re: [PHP] Days until Easter and Christmas

2008-11-17 Thread Bastien Koert
On Sun, Nov 16, 2008 at 1:18 PM, Yeti <[EMAIL PROTECTED]> wrote:

> > I guess Canadians are slower, eh?  :-)
> LOL
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Only cuz it colder here!

-- 

Bastien

Cat, the other other white meat


Re: [PHP] ability to find include files...

2008-11-17 Thread Thodoris



hi t!!

strace is something i would have used.. but unfortunately, strace (at least as 
far as i can tell) doesn't work with web based apps...

thanks


-Original Message-
From: Thodoris [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 16, 2008 11:42 PM
To: Andrew Ballard
Cc: bruce; php-general@lists.php.net
Subject: Re: [PHP] ability to find include files...




On Sat, Nov 15, 2008 at 6:07 PM, bruce <[EMAIL PROTECTED]> wrote:
  
Hi list...


starting to go through a debug/understanding session of a couple of php web
apps. i'm wondering if there's any kind of tool/method that i can use to see
which files are accessed/included/required when a given page is displayed..

this would allow me to quickly understand the "flow" of the apps. searching
via google hasn't really turned up anything...

thoughts/comments/pointers welcome.

thanks!




Yes. How about get_included_files().

http://www.php.net/get_included_files

Andrew

  


This of course shows the included files but if you *really* need to go much 
deeper (although this is probably an overkill) you could try tracing when the 
process opens a file using strace along with grep if you are in unix.


  


Yes that is true because you can use it only with the cli. But you could 
probably make a command line (stripped) version of the script just to 
see what are the files that it opens. But this is truly an overkill. 
There are better methods to debug this IMO than tracing the scripts 
behavior.


I would suggest to use var_dump to dump all the vars you need to 
understand and then use die to end the script wherever you need to stop 
the execution.


If the project you are trying to understand depends on a framework 
things become more complicated and you need a better understanding on 
the framework (I guess).


--
Thodoris


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



Re: [PHP] Re: Cannot create statement handler

2008-11-17 Thread Thodoris



Thodoris wrote:

I was wondering if anyone sees something I am bypassing:

I have this sample code that works in another server:

query($sql);
   // die(var_dump($sthr));
   $res = $sthr->fetch(PDO::FETCH_ASSOC);

   return $res['Name'];

}

try {
   $dbh = new PDO('mysql:host=localhost;port=3306;dbname=ins', 
'root', '', array(PDO::ATTR_PERSISTENT => false));


   $sql = "SELECT * FROM Contracts";
   $sth = $dbh->query($sql);

   print "";

   while($res = $sth->fetch(PDO::FETCH_ASSOC)) {
   $name = getClientFullName($dbh,$res['ClientId']);
   print $name."";
   }
} catch (Exception $e) {
   print $e->getMessage();
}
?>

but in my case I can't make it work on my own server. I have removed 
both PHP and apache and compiled everything for source just to make 
sure that I will avoid possible problems using rpm. It seems that if 
I dump $sthr it returns false.


Although if I print the query and use it directly it works fine.

Apache 2.2.10
PHP 5.2.6
Linux EL5

I've posted this some days ago but none had any idea about this. Do 
think this could be a bug?




obvious but:
do a phpinfo() and check PDO is installed on the failing server
check db is on the failing server
check mysql is running on the failing server
check username and pass are correct for db
check username and pass combo can access via localhost




Yes all that are true because I am able to run a i simple query and 
retrieve the data normally. Not to mention that I double checked this. 
But  when passing  the database handler into a function  then I get the 
results I mentioned before:


Call to a member function fetch() on a non-object



Nonetheless it is a good tip since someone can fail look in to the obvious.

--
Thodoris


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



RE: [PHP] ability to find include files...

2008-11-17 Thread bruce
hi t!!

strace is something i would have used.. but unfortunately, strace (at least as 
far as i can tell) doesn't work with web based apps...

thanks


-Original Message-
From: Thodoris [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 16, 2008 11:42 PM
To: Andrew Ballard
Cc: bruce; php-general@lists.php.net
Subject: Re: [PHP] ability to find include files...




On Sat, Nov 15, 2008 at 6:07 PM, bruce <[EMAIL PROTECTED]> wrote:
  
Hi list...

starting to go through a debug/understanding session of a couple of php web
apps. i'm wondering if there's any kind of tool/method that i can use to see
which files are accessed/included/required when a given page is displayed..

this would allow me to quickly understand the "flow" of the apps. searching
via google hasn't really turned up anything...

thoughts/comments/pointers welcome.

thanks!



Yes. How about get_included_files().

http://www.php.net/get_included_files

Andrew

  

This of course shows the included files but if you *really* need to go much 
deeper (although this is probably an overkill) you could try tracing when the 
process opens a file using strace along with grep if you are in unix.


-- 
Thodoris


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



Re: [PHP] Re: Cannot create statement handler

2008-11-17 Thread Thodoris Goltsios





Thodoris wrote:

I was wondering if anyone sees something I am bypassing:

I have this sample code that works in another server:

query($sql);
   // die(var_dump($sthr));
   $res = $sthr->fetch(PDO::FETCH_ASSOC);

   return $res['Name'];

}

try {
   $dbh = new PDO('mysql:host=localhost;port=3306;dbname=ins', 
'root', '', array(PDO::ATTR_PERSISTENT => false));


   $sql = "SELECT * FROM Contracts";
   $sth = $dbh->query($sql);

   print "";

   while($res = $sth->fetch(PDO::FETCH_ASSOC)) {
   $name = getClientFullName($dbh,$res['ClientId']);
   print $name."";
   }
} catch (Exception $e) {
   print $e->getMessage();
}
?>

but in my case I can't make it work on my own server. I have removed 
both PHP and apache and compiled everything for source just to make 
sure that I will avoid possible problems using rpm. It seems that if 
I dump $sthr it returns false.


Although if I print the query and use it directly it works fine.

Apache 2.2.10
PHP 5.2.6
Linux EL5

I've posted this some days ago but none had any idea about this. Do 
think this could be a bug?




obvious but:
do a phpinfo() and check PDO is installed on the failing server
check db is on the failing server
check mysql is running on the failing server
check username and pass are correct for db
check username and pass combo can access via localhost




Yes all that are true because I am able to run a i simple query and 
retrieve the data normally. Not to mention that I double checked this. 
But  when passing  the database handler into a function  then I get 
the results I mentioned before:


Call to a member function fetch() on a non-object



Nonetheless it is a good tip since someone can fail look in to the 
obvious.




At last I have found what the problem was. It was more of a mysql 
configuration problem than PHP. I needed to activate MySQL's buffered 
queries that I was not aware that defaults to non-active in my 
configuration.


I saw a relative bug that suggested this so the only thing that I should 
do was:


$dbh = new PDO('mysql:host=localhost;port=3306;dbname=xxx', 'xxx', 
'xxx', array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY=>true));


So I probably got stuck to the *obvious*.


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



Re: [PHP] while-question

2008-11-17 Thread Nathan Rixham

Stut wrote:

On 17 Nov 2008, at 14:31, Nathan Rixham wrote:

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using the 
+ operator. fill it in:


function add($a , $b) {
//code here but no + - / * operators
return $answer;
}

echo add(5, 17);


Elemental my dear Mr Rixham...

function add($a , $b)
{
  $answer = $a ^ $b;
  while (0 != ($a & $b))
  {
$b = ($a & $b) << 1;
$answer = $answer ^ $b;
  }
  return $answer;
}

-Stut



what an answer; very nice and indeed full marks mr stut!

now then..
echo add(5,17) . ' ' . (5 + 17) . PHP_EOL;
echo add(-5,17) . ' ' . (-5 + 17) . PHP_EOL;
echo add(5,-17) . ' ' . (5 + -17) . PHP_EOL;
echo add(-5,-17) . ' ' . (-5 + -17) . PHP_EOL;

(can you tell I've been down this route before?)

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



Re: [PHP] while-question

2008-11-17 Thread Andrew Ballard
On Mon, Nov 17, 2008 at 9:47 AM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Nathan Rixham schreef:
>> Jochem Maas wrote:
>>> $a = range(1,10);
>>> for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);
>>
>> think the point of this is to count the items in an array without count
>> mate :p no point in the above you could just:
>> $c = count($a);
>
> I thought the point was to avoid count() on every iteration.
> not using count() but instead looping the complete array is stupid,
> if the OP's teacher thinks count() is bad then that teacher suck's,
> count() is efficient as it can be ... it does'nt actually do a
> count when it's called merely looks up the length property of the
> array (unless I'm grossly mistaken)
>
>>
>> foreach!
>> $a = range(1,10);
>> $c = 0;
>> foreach($a as $b) {
>>  $c++;
>> }
>> echo $c. PHP_EOL;
>>
>> if you really want a challenge try this one..
>>
>> task: add the numbers 5 and 17 together, using php, without using the +
>> operator. fill it in:
>>
>> function add($a , $b) {
>>  //code here but no + - / * operators
>
> I'll assume no post/pre-increment operators either.
>
>>  return $answer;
>> }
>>
>> echo add(5, 17);
>
> function add($a, $b) {
>$a = array_merge(array_fill(0, $a, 1), array_fill(0, $b, 1));
>return count($a);
> }
>
> not very efficient :-) .. probably one of a 1000 ways to fudge it :-)
>

And another... :)

function add($a, $b) {
return array_sum(func_get_args());
}

Andrew

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



Re: [PHP] while-question

2008-11-17 Thread Stut

On 17 Nov 2008, at 14:31, Nathan Rixham wrote:

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using  
the + operator. fill it in:


function add($a , $b) {
//code here but no + - / * operators
return $answer;
}

echo add(5, 17);


Elemental my dear Mr Rixham...

function add($a , $b)
{
  $answer = $a ^ $b;
  while (0 != ($a & $b))
  {
$b = ($a & $b) << 1;
$answer = $answer ^ $b;
  }
  return $answer;
}

-Stut

--
http://stut.net/

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



Re: [PHP] Variable Argument List

2008-11-17 Thread Nathan Rixham

Richard Heyes wrote:

...


And you might also be interested in func_get_args(), which returns an
array of args passed to the function (don't know what it does if used
outside a function. Probably get an error).



yup..
Warning:  func_get_args():  Called from the global scope - no 
function context


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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Nathan Rixham schreef:
> Jochem Maas wrote:
>> $a = range(1,10);
>> for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);
> 
> think the point of this is to count the items in an array without count
> mate :p no point in the above you could just:
> $c = count($a);

I thought the point was to avoid count() on every iteration.
not using count() but instead looping the complete array is stupid,
if the OP's teacher thinks count() is bad then that teacher suck's,
count() is efficient as it can be ... it does'nt actually do a
count when it's called merely looks up the length property of the
array (unless I'm grossly mistaken)

> 
> foreach!
> $a = range(1,10);
> $c = 0;
> foreach($a as $b) {
>  $c++;
> }
> echo $c. PHP_EOL;
> 
> if you really want a challenge try this one..
> 
> task: add the numbers 5 and 17 together, using php, without using the +
> operator. fill it in:
> 
> function add($a , $b) {
>  //code here but no + - / * operators

I'll assume no post/pre-increment operators either.

>  return $answer;
> }
> 
> echo add(5, 17);

function add($a, $b) {
$a = array_merge(array_fill(0, $a, 1), array_fill(0, $b, 1));
return count($a);
}

not very efficient :-) .. probably one of a 1000 ways to fudge it :-)

> 


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



RE: [PHP] Another question about Google maps

2008-11-17 Thread Boyd, Todd M.
> -Original Message-
> From: tedd [mailto:[EMAIL PROTECTED]
> Sent: Saturday, November 15, 2008 2:11 PM
> To: php-general@lists.php.net
> Subject: [PHP] Another question about Google maps
> 
> Hi gang:
> 
> I posted this question on the Google Map Discussion group/list
> thingie, but got zip in replies. Maybe someone here might have an
> idea.
> 
> Here's the url:
> 
> http://masoncollision.com/contact.php
> 
> In both Safari and FireFox for the Mac (I have not tested it with
> other browsers) as the page loads the map border is momentary drawn
> twice. The map border is shown stacked one above the other making the
> page much longer than it actually is. But immediately thereafter, the
> map is drawn correctly and the page returns to the size it's supposed
> to be.
> 
> I just want to get rid of the momentary flash.
> 
> Anyone have any ideas?

tedd, I think it might be displaying your extra divs (if there are any..
just skimmed the source momentarily) for a split second before they are
hidden with Javascript. Maybe try setting the CSS for your 3 map divs
(mapsearch, idlediv, searchdiv or whatever) to display:none and show
them when the page is loaded? Or give all 3 the same top/left
coordinates, etc...

Just a shot in the dark. I may read over the code a bit more if I get
some time later today. I'm no expert, but I've been working with the
Google Maps API rather extensively lately, and maybe I can offer a fresh
set of eyes.

HTH,


Todd Boyd
Web Programmer

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



[PHP] Re: Cannot create statement handler

2008-11-17 Thread Nathan Rixham

Thodoris wrote:

I was wondering if anyone sees something I am bypassing:

I have this sample code that works in another server:

query($sql);
   // die(var_dump($sthr));
   $res = $sthr->fetch(PDO::FETCH_ASSOC);

   return $res['Name'];

}

try {
   $dbh = new PDO('mysql:host=localhost;port=3306;dbname=ins', 'root', 
'', array(PDO::ATTR_PERSISTENT => false));


   $sql = "SELECT * FROM Contracts";
   $sth = $dbh->query($sql);

   print "";

   while($res = $sth->fetch(PDO::FETCH_ASSOC)) {
   $name = getClientFullName($dbh,$res['ClientId']);
   print $name."";
   }
} catch (Exception $e) {
   print $e->getMessage();
}
?>

but in my case I can't make it work on my own server. I have removed 
both PHP and apache and compiled everything for source just to make sure 
that I will avoid possible problems using rpm. It seems that if I dump 
$sthr it returns false.


Although if I print the query and use it directly it works fine.

Apache 2.2.10
PHP 5.2.6
Linux EL5

I've posted this some days ago but none had any idea about this. Do 
think this could be a bug?




obvious but:
do a phpinfo() and check PDO is installed on the failing server
check db is on the failing server
check mysql is running on the failing server
check username and pass are correct for db
check username and pass combo can access via localhost


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



Re: [PHP] while-question

2008-11-17 Thread Nathan Rixham

Jochem Maas wrote:

$a = range(1,10);
for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);


think the point of this is to count the items in an array without count 
mate :p no point in the above you could just:

$c = count($a);

foreach!
$a = range(1,10);
$c = 0;
foreach($a as $b) {
 $c++;
}
echo $c. PHP_EOL;

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using the + 
operator. fill it in:


function add($a , $b) {
 //code here but no + - / * operators
 return $answer;
}

echo add(5, 17);

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



[PHP] Cannot create statement handler

2008-11-17 Thread Thodoris

I was wondering if anyone sees something I am bypassing:

I have this sample code that works in another server:

query($sql);
   // die(var_dump($sthr));
   $res = $sthr->fetch(PDO::FETCH_ASSOC);

   return $res['Name'];

}

try {
   $dbh = new PDO('mysql:host=localhost;port=3306;dbname=ins', 'root', 
'', array(PDO::ATTR_PERSISTENT => false));


   $sql = "SELECT * FROM Contracts";
   $sth = $dbh->query($sql);

   print "";

   while($res = $sth->fetch(PDO::FETCH_ASSOC)) {
   $name = getClientFullName($dbh,$res['ClientId']);
   print $name."";
   }
} catch (Exception $e) {
   print $e->getMessage();
}
?>

but in my case I can't make it work on my own server. I have removed 
both PHP and apache and compiled everything for source just to make sure 
that I will avoid possible problems using rpm. It seems that if I dump 
$sthr it returns false.


Although if I print the query and use it directly it works fine.

Apache 2.2.10
PHP 5.2.6
Linux EL5

I've posted this some days ago but none had any idea about this. Do 
think this could be a bug?


--
Thodoris


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



[PHP] Re: while question

2008-11-17 Thread Nathan Rixham

Alain Roger wrote:

Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.



sounds like a poor teacher, however I have a feeling he simply wants you 
to be able to count the items in an array without using the count() 
function. In this case you would be best to use a foreach loop.


you are correct in saying that a while($myarray) loop would be infinite, 
unless you use a function to reduce the array on each iteration of the 
while loop as such:



but.. get a new teacher :p (no offense)

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Timo Erbach schreef:
> ...but for best performance you should do:
> 
> 
> $counter = count($array);
> for($i = 0; $i < $counter; $i++){
>   echo $i . "\n";
> }

just for fun:

$a = range(1,10);
for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);

... gives an idea of the power and flexibility of a for loop
constructor, i.e. you can pretty much write a complete program
using just a for construct without even defining a loop body.

> 
> So the expression count() in the for()-loop is only
> parsed once and not every loop.
> 
> Regards
> Timo
> [snip]
> ...foreach...
> [/snip]
> 
> You could also use a for loop if you wanted to count;
> 
> for($i = 0; $i < count($array); $i++){
>   echo $i . "\n";
> }
> 
> 


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



[PHP] while-question

2008-11-17 Thread Timo Erbach

...but for best performance you should do:


$counter = count($array);
for($i = 0; $i < $counter; $i++){
  echo $i . "\n";
}

So the expression count() in the for()-loop is only
parsed once and not every loop.

Regards
Timo 


[snip]
...foreach...
[/snip]

You could also use a for loop if you wanted to count;

for($i = 0; $i < count($array); $i++){
  echo $i . "\n";
}


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



RE: [PHP] while question

2008-11-17 Thread Jay Blanchard
[snip]
...foreach...
[/snip]

You could also use a for loop if you wanted to count;

for($i = 0; $i < count($array); $i++){
   echo $i . "\n";
}



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



[PHP] Re: $60 Reward, 1 Hour Eclipse Project

2008-11-17 Thread Nathan Rixham

johny why wrote:

- Tasks

$60 reward to walk me through a successful Eclipse PHP debug session of 
doProject on my IIS server.


The only task here is to get a debug session going.

There will not be any IIS support or PHP programming involved.

Should only be some basic config settings in Eclipse.


- Time Frame

Payment will only be made if this task is achieved within 2 hours. I 
think should be under an hour total for someone who knows this stuff well.



- Method

You will watch my desktop remotely, and talk me through all steps, by 
phone or chat or voice chat.


No hands-on work involved, just need to talk me through it.

Please do not send pre-written Eclipse instructions - remote 
walk-through only.



- Environment

I am running IIS 6, PHP 4.4.6, Windows 2000 server, Zend debugger (ok to 
use xdebug if you prefer)


Eclipse All-In-One PDT is already installed on my server. Zend debug 
extension is also installed. The php.ini has the Zend debug settings.


Unfortunately, I do not have the luxury to switch to Apache.



just use the Zend Executable Debugger Eclipse Plugin
http://downloads.zend.com/pdt/debugger/

save's a bit of hassle and means you don't need a web server to debug or 
 develop 99% of the time


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



Re: [PHP] while question

2008-11-17 Thread Thodoris



Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.

  


Probably the easiest way for doing this is using foreach:

$a = array(1,2,3,4,5);

foreach ($a as $i) {
   print $i."";
}

This outputs:
1
2
3
4
5

This for e.g. gives an infinite loop:

$a = array(1,2,3,4,5);

while ($a) {
   print $i."";
   $i++;
}

So you are right because $a will always evaluate as true since it not 
empty. For these kinds of questions you should read the manual first and 
then ask here.


http://gr2.php.net/manual/en/control-structures.while.php

--
Thodoris


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



Re: [PHP] while question

2008-11-17 Thread Stut

On 17 Nov 2008, at 13:01, Alain Roger wrote:
i'm on PHP training and our lector is telling us that to avoid  
counting an

array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.


The while would work if you removed elements of $my_array inside the  
loop, but you would still need to be sure that it would eventually be  
empty.


I would guess that your lecturers point is that you shouldn't call  
count on every iteration as it's a waste of time. He may also be  
confusing while for foreach in which case I'd leave because you're  
unlikely to learn anything from him.


-Stut

--
http://stut.net/


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



[PHP] while question

2008-11-17 Thread Alain Roger
Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.

-- 
Alain

Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008


[PHP] Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

2008-11-17 Thread Paweł Stradomski
W liście Christopher Vogt z dnia poniedziałek 17 listopada 2008:

> I have a good understanding of OOP. This is not a start for me. I am
> just refactoring existing PHP code to be object-oriented. You say there
> are plenty of reasons for a Fatal error, so please tell me a few, so I
> understand the reasons.
You're calling a method. This requires code execution, but the code isn't 
there. If you were accessing a property of non-existing object (that is, if 
you were doing $user->fullname;) then you'd get a warning and NULL. It's not 
so for functions, as they're request for code execution, not for value 
(remember, not all functions return values as they most important effect - 
it's not Haskell).

Calling non-existing function returns in fatal error in PHP; it's the same 
for:
$object->iHaveNoSuchMethod();
$null->method();
nosuchfunction();

-- 
Paweł Stradomski

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



[PHP] Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

2008-11-17 Thread Jochem Maas
Christopher Vogt schreef:
> Hej Jochem,
> 
> I understand there are many PHP beginners flooding the wrong lists with
> the wrong questions, so I don't mind your harsh response. But I am not
> one of them.

I disagree. this kind of thing belongs on php-general (and lets keep it on list
please), if you have a serious proposal/rfc and/or one develops from a 
discussion
there then likely some of the old-hats will likely recommend escalating to
internals.

>> please don't post this kind of question to internals. use [EMAIL PROTECTED]
> 
> This was/is a question if something is worth a change request. This
> concerns the development of PHP and in my eyes belongs on internals. Am
> I mistaken here?
> 
>> plenty, I suggest taking the time to get a better understanding of OO,
>> the php implementation and the various related tools it offers
>> (instanceof, "method-chaining", exceptions, etc, etc).
> 
> I have a good understanding of OOP. This is not a start for me. I am
> just refactoring existing PHP code to be object-oriented. You say there
> are plenty of reasons for a Fatal error, so please tell me a few, so I
> understand the reasons.

fine, so your not an OO noob. nonetheless your going have to get accustomed
and intimate with php's implementation which is what it is, it works, it's 
consistent
but may not conform to all your expectations that you bring with you from other
languages ... it's a question of you adapting to php not the other way around.

if everyone who came to a language had that language implementation changed
to meet their expectations of what it should be doing and how said language
would quickly deteriorate into complete shite ... something noone would want to
use or develop.

> 
>> calling a method on an object that doesn't exist is tantamount to calling a 
>> function
>> which doesn't exist ... both are a fatal error.
> 
> Yes and maybe that is wrong two. But besides that, there is a difference
> between the two. It hardly happens that a bug results in a call to a
> non-existing function. But a bug can easily lead to an uninitialized
> variable which is then treated as an object.
> 
> The problem with Fatal errors is that there is no way for me to handle
> them. I use an error_handler in the production system. When an error or
> unhandled exception occurs it displays an end-user-friendly error
> message and then sends an email to our team's mailbox. Working with
> arrays I can handle all sensible run-time errors using this methods.
> Working with objects, I apparently cannot, because Fatal Error aren't
> handled by the error_handler.
> 
> That's a serious problem because it completely hides a likely group of
> errors from the notification system. I hopes this motivates the question
> a little better.
> 
> But the question remains. Are there reasons to have a Fatal error here?

yes, it tells you your doing something impossible.

> For comparison: Python throws an exception in a comparable case,
> allowing me to handle the error.

PHP != Python. python is pure OO. php is hybrid. you have to refactor your
code in different ways.

if your writing code that blindly makes use of a $user var that may or may not
be a valid object then you code is incorrect. not being able to trap Fatals is
essentially a non-issue as your code should be structured so that they cannot 
occur.

there are a number of ways of dealing with the issue you have.

1. test the validity of the object

if ($user instanceof User) {
// do something
}

2. start using exceptions

try {
$user = UserGetter::get($id);

// do stuff with $user
} catch (UserException $e) {
// handle exception
}

// where UserGetter::get() is something like ...

class UserGetter {
static function get($id) {  
$data = getUserDataFromDB($id)
if ($data)
return new User($data);

throw new UserException("$id is invalid");
}
}

what this comes down to is this, python gives you exceptions free of
charge, php asks you to implement and throw them yourself ... this is
primarily the result of php's procedural legacy. ce la vie.

> 
> Best regards
> 
> Christopher


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



[PHP] Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

2008-11-17 Thread Christopher Vogt
Hej Jochem,

I understand there are many PHP beginners flooding the wrong lists with
the wrong questions, so I don't mind your harsh response. But I am not
one of them.

> please don't post this kind of question to internals. use [EMAIL PROTECTED]

This was/is a question if something is worth a change request. This
concerns the development of PHP and in my eyes belongs on internals. Am
I mistaken here?

> plenty, I suggest taking the time to get a better understanding of OO,
> the php implementation and the various related tools it offers
> (instanceof, "method-chaining", exceptions, etc, etc).

I have a good understanding of OOP. This is not a start for me. I am
just refactoring existing PHP code to be object-oriented. You say there
are plenty of reasons for a Fatal error, so please tell me a few, so I
understand the reasons.

> calling a method on an object that doesn't exist is tantamount to calling a 
> function
> which doesn't exist ... both are a fatal error.

Yes and maybe that is wrong two. But besides that, there is a difference
between the two. It hardly happens that a bug results in a call to a
non-existing function. But a bug can easily lead to an uninitialized
variable which is then treated as an object.

The problem with Fatal errors is that there is no way for me to handle
them. I use an error_handler in the production system. When an error or
unhandled exception occurs it displays an end-user-friendly error
message and then sends an email to our team's mailbox. Working with
arrays I can handle all sensible run-time errors using this methods.
Working with objects, I apparently cannot, because Fatal Error aren't
handled by the error_handler.

That's a serious problem because it completely hides a likely group of
errors from the notification system. I hopes this motivates the question
a little better.

But the question remains. Are there reasons to have a Fatal error here?

For comparison: Python throws an exception in a comparable case,
allowing me to handle the error.

Best regards

Christopher

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



[PHP] Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

2008-11-17 Thread Jochem Maas
please don't post this kind of question to internals. use [EMAIL PROTECTED]

Christopher Vogt schreef:
> Hej,
> 
> I use PHP 5.2.6. I am refactoring some code to use more
> object-orientation. I encounter a problem, where the new object-oriented
> version results in a fatal error, where the old array-oriented version
> didn't.
> 
> I fetch records a database. Sometime it happens that a record does not
> exist anymore. Let's assume it's a user, then $user will be NULL.
> 
> echo $user['fullname']; // no error at all, $user['fullname'] === NULL
> 
> Shouldn't this at least trigger a Notice?
> 
> echo $user->get_fullname(); // Fatal error
> 
> I agree this should trigger an error, but a "Fatal error" is a little
> too much, I think. It terminates the script leaving the html-document
> incomplete. I would prefer a "Warning" and NULL instead.

either go back to using arrays or fix your code. your asking for something
to change when you have little idea of why or what it is in the first place.

> 
> Is there any reason against it?

plenty, I suggest taking the time to get a better understanding of OO, the php
implementation and the various related tools it offers (instanceof, 
"method-chaining",
exceptions, etc, etc).

calling a method on an object that doesn't exist is tantamount to calling a 
function
which doesn't exist ... both are a fatal error.

> 
> Best regards
> 
> Christopher
> 


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