Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Lester Caine

Nathan Rixham wrote:

Peter Lind wrote:

On 13 April 2010 17:27, Paul M Foster  wrote:

On Tue, Apr 13, 2010 at 03:20:23PM +0200, Merlin Morgenstern wrote:


Hello everybody,

I have form where users enter data to be saved in a db.

How can I make php save the form data into a session before the user
leaves the page without pressing the submit button? Some members leave
the page and return afterwards wondering where their already entered
data is.

I hate to be a contrarian (not really), but there is a paradigm for
using web forms. If you want the internet to save your data, you have to
press the little button. If you don't, then it won't be saved. Not hard
to figure out, not hard to do. If you have to go do something else while
you're in the middle of a form, open a new tab/window and do it. When
you come back to your original form, the data will still be there (but
again, not *saved* until you hit the little button).

Sorry, I just get cranky with people who won't follow the rules.


There are rules and then there's stupidity based on tradition. The
fact that websites previously threw away whatever work you had done
because you automatically got logged out of your session after half an
hour of typing does not mean you should call this a rule that should
be adhere to. Google figured it out and did so well: backup
automatically and let the user discard manually - not the other way
round that leads to lost work.

Apart from that, I note that the OP has seemingly managed to solve the
problem and all these emails are rather pointless.


Concur, and this is nothing to do with the web; http only constrains
that the data should be POSTed or PUT; not /when/ a save action is
triggered.

Functionality is in the realm of the application, and if the client
application (in this case the web page) determines that information
should be iteratively saved, then that's what it should do.

see google docs, gmail etc for real world examples.


And a few BANK sites could do with considering waring people that they will time 
out before you have time to actually write in their message box for on-line 
emails which you have to use since they will not accept off-line ones. I had a 
complex message FROM them to answer - and save just told me the seesion had 
timed out! Bank solution - I should have copied their message to a word 
processor, and then copied the answer back later ... perhaps they should add 
that with a warning when trying to use their email page ;)


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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



[PHP] problems with feature '--with-pdo-oci' RPM (spec)

2010-04-13 Thread Raul da Silva {Sp4wn}
Hi,

Good morning for all,

I'd like to understand why when i try to install the package 'php52-pdo-oci'
generated by 'rpmbuild -ba php52.spec' with feature inside of file , doesn't
work and returns the follow error :

# rpm -qpl /usr/src/linux/RPMS/x86_64/php52-pdo-oci-5.2.12-2.fc11.x86_64.rpm
/etc/php.d/pdo_oci.ini
/usr/lib64/php/modules/pdo_oci.so

# rpm --test -ivh
/usr/src/redhat/RPMS/x86_64/php52-pdo-oci-5.2.12-2.fc11.x86_64.rpm
error: Failed dependencies:
libclntsh.so.10.1()(64bit) is needed by
php52-pdo-oci-5.2.12-2.fc11.x86_64


I checked this steps, its ok :

1)
# ls -l /usr/lib/oracle/10.2.0.4/client64/lib/libclntsh.so
lrwxrwxrwx 1 root root 17 2010-04-12 19:38 /usr/lib/oracle/
10.2.0.4/client64/lib/libclntsh.so -> libclntsh.so.10.1

2)
# ldconfig -p | grep libclntsh.so
libclntsh.so.10.1 (libc6,x86-64) => /usr/lib/oracle/
10.2.0.4/client64/lib/libclntsh.so.10.1
libclntsh.so (libc6,x86-64) => /usr/lib/oracle/
10.2.0.4/client64/lib/libclntsh.so


What is wrong ? , thanks for help


Att,

Raul


Re: [PHP] Array differences

2010-04-13 Thread Rene Veerman
On Wed, Apr 14, 2010 at 7:01 AM, Ashley M. Kirchner  wrote:
> I have the following scenario:
>
>
>
>     $array1 = array("12", "34", "56", "78", "90");
>
>     $array2 = array("12", "23", "56", "78", "89");
>
>
>
>     $result = array_diff($array1, $array2);
>
>
>
>     print_r($result);
>
>
>
>
>
> This returns:
>
>
>
>     Array
>
>     (
>
>         [1] => 34
>
>         [4] => 90
>
>     )
>
>
>
>
>
> However what I really want is a two-way comparison.  I want elements that
> don't exist in either to be returned:
>
>
>
> 34 and 90 because they don't exist in $array2, AND 23 and 89 because they
> don't exist in $array1.  So, is that a two step process of first doing an
> array_diff($array1, $array2) then reverse it by doing array_diff($array2,
> $array1) and merge/unique the results?  Any caveats with that?
>
>
>
>     $array1 = array("12", "34", "56", "78", "90");
>
>     $array2 = array("12", "23", "56", "78", "89");
>
>
>
>     $diff1 = array_diff($array1, $array2);
>
>     $diff2 = array_diff($array2, $array1);
>
>
>
>     $result = array_unique(array_merge($diff1, $diff2));
>
>
>
>     print_r($result);
>
>
>
>
>
> -- A
>
>

ok, adding this to the todo-list for htmlMicroscope... ETA on delivery
of 1.3.0-final: about 2 to 3 months i'm afraid.
Gotta get a new laundromat for my home too and stuff like that :)

-- 
-
Greetings from Rene7705,

I have made some free open source webcomponents designed
and written by me available through:
http://code.google.com/u/rene7705/ , or
http://mediabeez.ws (latest dev versions, currently offline)

Personal info about me is available through http://www.facebook.com/rene7705
-

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



[PHP] Array differences

2010-04-13 Thread Ashley M. Kirchner
I have the following scenario:

 

 $array1 = array("12", "34", "56", "78", "90");

 $array2 = array("12", "23", "56", "78", "89");

 

 $result = array_diff($array1, $array2);

 

 print_r($result);

 

 

This returns:

 

 Array

 (

 [1] => 34

 [4] => 90

 )

 

 

However what I really want is a two-way comparison.  I want elements that
don't exist in either to be returned:

 

34 and 90 because they don't exist in $array2, AND 23 and 89 because they
don't exist in $array1.  So, is that a two step process of first doing an
array_diff($array1, $array2) then reverse it by doing array_diff($array2,
$array1) and merge/unique the results?  Any caveats with that?

 

 $array1 = array("12", "34", "56", "78", "90");

 $array2 = array("12", "23", "56", "78", "89");

 

 $diff1 = array_diff($array1, $array2);

 $diff2 = array_diff($array2, $array1);

 

 $result = array_unique(array_merge($diff1, $diff2));

 

 print_r($result);

 

 

-- A



[PHP] Re: would there be an interest in having htmlMicroscope include dygraphs?

2010-04-13 Thread Rene Veerman
On Wed, Apr 14, 2010 at 1:44 AM, Rene Veerman  wrote:
> On Wed, Apr 14, 2010 at 1:23 AM, Rene Veerman  wrote:
>> On Wed, Apr 14, 2010 at 1:19 AM, Rene Veerman  wrote:
>>> htmlMicroscope (that i wrote and opensourced) can be used to look at
>>> very big arrays easilly in a browser.
>>> I fully intend to fix the final bugs and release a real 1.3.0 release,
>>> and not abandon that project..
>>>
>>> In fact, i could use a simple project to work on atm, to re-focus
>>> myself on useful work and a useful day-night rythm (as made apparent
>>> by my recent off-topic and weird posts to this list)..
>>>
>>> I would like to include http://www.danvk.org/dygraphs/ into htmlMicroscope.
>>> Would you think it usefull?
>>>
>>> htmlMicroscope can be downloaded through the googlecode link in my 
>>> signature..
>>>
>>> Again, please excuse my recent off-topic posting to this list.
>>> My psychiateric out-patient help team has confirmed that they were
>>> informed by a member of this list of my recent [OFF-TOPIC] post in
>>> dutch (of which i cannot even be sure if "everyone got that mail"),
>>> but i do thank you people for reporting me to said psychiateric help
>>> team.
>>> My contact with them is good, they did not "invite me for a irl
>>> conversation". I'm allowed to stay at my parents and heal myself (from
>>> sleep-deprivation) under the guidance of my dear parents.
>>>
>>> Please people, just +1 or -1 this idea of adding dygraphs to
>>> htmlMicroscope. The coding should be simple, and i do promise to clean
>>> up the 1.3.0-beta-rc1 to a real 1.3.0 version that works properly for
>>> displaying arrays with unicode data, json-arrays-as-keys, etc, ranging
>>> 100-200mb in transport-to-browser-size..
>>>
>>> Yes, i am a bit worried about being seen as the weird psycho on this
>>> forum. Psychotic i'm not, just sleep-deprived a bit, and i've slept
>>> very well in the past 72 hrs. Over 10hrs per 24hrs for the past 72hrs.
>>> So i'm healing, not degrading.
>>> And of course i'm taking (dutch brandname:) risperdal quicklets, as
>>> per my mum's orders (rather than a psych worker's "closed ward"
>>> orders)..
>>>
>>> I'll be doing house-cleanup in about a week, and will be spending
>>> nights at home in about 2 weeks, allowing me probably to put
>>> mediabeez.ws back up online for development versions of
>>> htmlMicroscope.
>>>
>>> Again, my apologies for poluting the list with what is considered 
>>> too-off-topic
>>>
>>> Please do not inform the psych-services again of any posts of mine
>>> here mentioning telepathy.
>>> It was already reported to them, and they (Noortje) actually called me
>>> and we talked it over, that it shouldn't happen again, me posting
>>> private conversations onto some random list.
>>> My reasons for posting "[OFF-TOPIC] telepathy and psychiatery" to this
>>> list were simple; i was trying to alleviate the fears of other
>>> telepaths like me, to prevent _them_ from having to go through the
>>> hell of psychiateric closed wards...
>>>
>>> Please help me get back into programming.
>>> Oh, and if anyone asks about me, point me to my facebook page. Just
>>> don't rat me out to psych services and/or my family, who cannot handle
>>> that level of information yet.
>>>
>>
>>
>>
>>
>> oh, and telepathy is not considered a dellusion by everyone; these
>> websites are _not_ mine;
>>
>> http://www.telepathyrevealed.com
>> http://social-psychiatry.com/telepathy-techniques-develop-abilities/;
>>
>
> i'm moving all my telepathy comments to my facebook page;
> http://www.facebook.com/#!/profile.php?v=info&ref=profile&id=11004170278
>
> (hope that url works for you too)..
>
>
> --
> -
> Greetings from Rene7705,
>
> I have made some free open source webcomponents designed
> and written by me available through:
> http://code.google.com/u/rene7705/ , or
> http://mediabeez.ws (latest dev versions, currently offline)
>
> You can also find me on facebook.com under email addr "rene7...@gmail.com"..
> -
>

my latest signature, with actual facebook link:

think that'll do it for now.. any "weird" extra comments of mine i'll
simply post to this thread on this list only..

-- 
-
Greetings from Rene7705,

I have made some free open source webcomponents designed
and written by me available through:
http://code.google.com/u/rene7705/ , or
http://mediabeez.ws (latest dev versions, currently offline)

You can also find me on facebook.com
http://www.facebook.com/people/Rene-Veerman/11004170278
-

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



[PHP] Re: would there be an interest in having htmlMicroscope include dygraphs?

2010-04-13 Thread Rene Veerman
On Wed, Apr 14, 2010 at 1:23 AM, Rene Veerman  wrote:
> On Wed, Apr 14, 2010 at 1:19 AM, Rene Veerman  wrote:
>> htmlMicroscope (that i wrote and opensourced) can be used to look at
>> very big arrays easilly in a browser.
>> I fully intend to fix the final bugs and release a real 1.3.0 release,
>> and not abandon that project..
>>
>> In fact, i could use a simple project to work on atm, to re-focus
>> myself on useful work and a useful day-night rythm (as made apparent
>> by my recent off-topic and weird posts to this list)..
>>
>> I would like to include http://www.danvk.org/dygraphs/ into htmlMicroscope.
>> Would you think it usefull?
>>
>> htmlMicroscope can be downloaded through the googlecode link in my 
>> signature..
>>
>> Again, please excuse my recent off-topic posting to this list.
>> My psychiateric out-patient help team has confirmed that they were
>> informed by a member of this list of my recent [OFF-TOPIC] post in
>> dutch (of which i cannot even be sure if "everyone got that mail"),
>> but i do thank you people for reporting me to said psychiateric help
>> team.
>> My contact with them is good, they did not "invite me for a irl
>> conversation". I'm allowed to stay at my parents and heal myself (from
>> sleep-deprivation) under the guidance of my dear parents.
>>
>> Please people, just +1 or -1 this idea of adding dygraphs to
>> htmlMicroscope. The coding should be simple, and i do promise to clean
>> up the 1.3.0-beta-rc1 to a real 1.3.0 version that works properly for
>> displaying arrays with unicode data, json-arrays-as-keys, etc, ranging
>> 100-200mb in transport-to-browser-size..
>>
>> Yes, i am a bit worried about being seen as the weird psycho on this
>> forum. Psychotic i'm not, just sleep-deprived a bit, and i've slept
>> very well in the past 72 hrs. Over 10hrs per 24hrs for the past 72hrs.
>> So i'm healing, not degrading.
>> And of course i'm taking (dutch brandname:) risperdal quicklets, as
>> per my mum's orders (rather than a psych worker's "closed ward"
>> orders)..
>>
>> I'll be doing house-cleanup in about a week, and will be spending
>> nights at home in about 2 weeks, allowing me probably to put
>> mediabeez.ws back up online for development versions of
>> htmlMicroscope.
>>
>> Again, my apologies for poluting the list with what is considered 
>> too-off-topic
>>
>> Please do not inform the psych-services again of any posts of mine
>> here mentioning telepathy.
>> It was already reported to them, and they (Noortje) actually called me
>> and we talked it over, that it shouldn't happen again, me posting
>> private conversations onto some random list.
>> My reasons for posting "[OFF-TOPIC] telepathy and psychiatery" to this
>> list were simple; i was trying to alleviate the fears of other
>> telepaths like me, to prevent _them_ from having to go through the
>> hell of psychiateric closed wards...
>>
>> Please help me get back into programming.
>> Oh, and if anyone asks about me, point me to my facebook page. Just
>> don't rat me out to psych services and/or my family, who cannot handle
>> that level of information yet.
>>
>
>
>
>
> oh, and telepathy is not considered a dellusion by everyone; these
> websites are _not_ mine;
>
> http://www.telepathyrevealed.com
> http://social-psychiatry.com/telepathy-techniques-develop-abilities/;
>

i'm moving all my telepathy comments to my facebook page;
http://www.facebook.com/#!/profile.php?v=info&ref=profile&id=11004170278

(hope that url works for you too)..


-- 
-
Greetings from Rene7705,

I have made some free open source webcomponents designed
and written by me available through:
http://code.google.com/u/rene7705/ , or
http://mediabeez.ws (latest dev versions, currently offline)

You can also find me on facebook.com under email addr "rene7...@gmail.com"..
-

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



[PHP] would there be an interest in having htmlMicroscope include dygraphs?

2010-04-13 Thread Rene Veerman
htmlMicroscope (that i wrote and opensourced) can be used to look at
very big arrays easilly in a browser.
I fully intend to fix the final bugs and release a real 1.3.0 release,
and not abandon that project..

In fact, i could use a simple project to work on atm, to re-focus
myself on useful work and a useful day-night rythm (as made apparent
by my recent off-topic and weird posts to this list)..

I would like to include http://www.danvk.org/dygraphs/ into htmlMicroscope.
Would you think it usefull?

htmlMicroscope can be downloaded through the googlecode link in my signature..

Again, please excuse my recent off-topic posting to this list.
My psychiateric out-patient help team has confirmed that they were
informed by a member of this list of my recent [OFF-TOPIC] post in
dutch (of which i cannot even be sure if "everyone got that mail"),
but i do thank you people for reporting me to said psychiateric help
team.
My contact with them is good, they did not "invite me for a irl
conversation". I'm allowed to stay at my parents and heal myself (from
sleep-deprivation) under the guidance of my dear parents.

Please people, just +1 or -1 this idea of adding dygraphs to
htmlMicroscope. The coding should be simple, and i do promise to clean
up the 1.3.0-beta-rc1 to a real 1.3.0 version that works properly for
displaying arrays with unicode data, json-arrays-as-keys, etc, ranging
100-200mb in transport-to-browser-size..

Yes, i am a bit worried about being seen as the weird psycho on this
forum. Psychotic i'm not, just sleep-deprived a bit, and i've slept
very well in the past 72 hrs. Over 10hrs per 24hrs for the past 72hrs.
So i'm healing, not degrading.
And of course i'm taking (dutch brandname:) risperdal quicklets, as
per my mum's orders (rather than a psych worker's "closed ward"
orders)..

I'll be doing house-cleanup in about a week, and will be spending
nights at home in about 2 weeks, allowing me probably to put
mediabeez.ws back up online for development versions of
htmlMicroscope.

Again, my apologies for poluting the list with what is considered too-off-topic

Please do not inform the psych-services again of any posts of mine
here mentioning telepathy.
It was already reported to them, and they (Noortje) actually called me
and we talked it over, that it shouldn't happen again, me posting
private conversations onto some random list.
My reasons for posting "[OFF-TOPIC] telepathy and psychiatery" to this
list were simple; i was trying to alleviate the fears of other
telepaths like me, to prevent _them_ from having to go through the
hell of psychiateric closed wards...

Please help me get back into programming.
Oh, and if anyone asks about me, point me to my facebook page. Just
don't rat me out to psych services and/or my family, who cannot handle
that level of information yet.


-- 
-
Greetings from Rene7705,

I have made some free open source webcomponents designed
and written by me available through:
http://code.google.com/u/rene7705/ , or
http://mediabeez.ws (latest dev versions, currently offline)

You can also find me on facebook.com under email addr "rene7...@gmail.com"..
-

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



[PHP] Re: would there be an interest in having htmlMicroscope include dygraphs?

2010-04-13 Thread Rene Veerman
On Wed, Apr 14, 2010 at 1:19 AM, Rene Veerman  wrote:
> htmlMicroscope (that i wrote and opensourced) can be used to look at
> very big arrays easilly in a browser.
> I fully intend to fix the final bugs and release a real 1.3.0 release,
> and not abandon that project..
>
> In fact, i could use a simple project to work on atm, to re-focus
> myself on useful work and a useful day-night rythm (as made apparent
> by my recent off-topic and weird posts to this list)..
>
> I would like to include http://www.danvk.org/dygraphs/ into htmlMicroscope.
> Would you think it usefull?
>
> htmlMicroscope can be downloaded through the googlecode link in my signature..
>
> Again, please excuse my recent off-topic posting to this list.
> My psychiateric out-patient help team has confirmed that they were
> informed by a member of this list of my recent [OFF-TOPIC] post in
> dutch (of which i cannot even be sure if "everyone got that mail"),
> but i do thank you people for reporting me to said psychiateric help
> team.
> My contact with them is good, they did not "invite me for a irl
> conversation". I'm allowed to stay at my parents and heal myself (from
> sleep-deprivation) under the guidance of my dear parents.
>
> Please people, just +1 or -1 this idea of adding dygraphs to
> htmlMicroscope. The coding should be simple, and i do promise to clean
> up the 1.3.0-beta-rc1 to a real 1.3.0 version that works properly for
> displaying arrays with unicode data, json-arrays-as-keys, etc, ranging
> 100-200mb in transport-to-browser-size..
>
> Yes, i am a bit worried about being seen as the weird psycho on this
> forum. Psychotic i'm not, just sleep-deprived a bit, and i've slept
> very well in the past 72 hrs. Over 10hrs per 24hrs for the past 72hrs.
> So i'm healing, not degrading.
> And of course i'm taking (dutch brandname:) risperdal quicklets, as
> per my mum's orders (rather than a psych worker's "closed ward"
> orders)..
>
> I'll be doing house-cleanup in about a week, and will be spending
> nights at home in about 2 weeks, allowing me probably to put
> mediabeez.ws back up online for development versions of
> htmlMicroscope.
>
> Again, my apologies for poluting the list with what is considered 
> too-off-topic
>
> Please do not inform the psych-services again of any posts of mine
> here mentioning telepathy.
> It was already reported to them, and they (Noortje) actually called me
> and we talked it over, that it shouldn't happen again, me posting
> private conversations onto some random list.
> My reasons for posting "[OFF-TOPIC] telepathy and psychiatery" to this
> list were simple; i was trying to alleviate the fears of other
> telepaths like me, to prevent _them_ from having to go through the
> hell of psychiateric closed wards...
>
> Please help me get back into programming.
> Oh, and if anyone asks about me, point me to my facebook page. Just
> don't rat me out to psych services and/or my family, who cannot handle
> that level of information yet.
>




oh, and telepathy is not considered a dellusion by everyone; these
websites are _not_ mine;

http://www.telepathyrevealed.com
http://social-psychiatry.com/telepathy-techniques-develop-abilities/;

-- 
-
Greetings from Rene7705,

I have made some free open source webcomponents designed
and written by me available through:
http://code.google.com/u/rene7705/ , or
http://mediabeez.ws (latest dev versions, currently offline)

You can also find me on facebook.com under email addr "rene7...@gmail.com"..
-

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



Re: [PHP] Basic switch statement

2010-04-13 Thread Nathan Rixham
Robert Cummings wrote:
> Nathan Rixham wrote:
>> Robert Cummings wrote:
>>> Nathan Rixham wrote:
 Robert Cummings wrote:
> Nathan Rixham wrote:
>> Robert Cummings wrote:
>>> steve_r wrote:
 I'm new to programming

 function check_it2($val) {
 echo gettype($val);
 switch($val) {
 case($val > 0 ):
 echo "Switch greater than 0";

>>> You're a tad confused :)
>>>
>>> Q: What is the result of $val > 0?
>>> A: false.
>>>
>>> Q: What is the value of $val?
>>> A: -1
>>>
>>> Q: Is -1 equivalent to false?
>>> A: Yes!
>>>
>>> Use an if statement for this kind of logic.
>> This is a fantastic example of false logic and an easy pitfall.
>>
>> in fact this would make a great interview question!
>>
>> to expand a little on the various scenarios (just for clarity, Rob is
>> wrong)
>>
>> $val = 1;
>> 1 > 0 equates to TRUE
>> is 1 equivalent to TRUE : YES
>>
>> $val = 0;
>> 0 > 0 equates to FALSE
>> is 0 equivalent to FALSE : YES
>>
>> $val = -1;
>> -1 > 0 equates to FALSE
>> is -1 equivalent to FALSE: NO
>>
> Fail on that last one. -1 is equivalent to FALSE :B
>
 well that's one job you're not getting :p
>>> Well I DID get 66.7%. I've met "coders" that would stare at the answer
>>> and still not understand :D
>>
>> the travesty is that you didn't spend most of yesterday on trains brushing
>> up on / studying formal logic!
> 
> Muphry's Law!!!
> 
> http://en.wikipedia.org/wiki/Muphry's_law
> 
> *heheh*

in situations like this one might consider changing the conversation
previous!

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



Re: [PHP] Basic switch statement

2010-04-13 Thread Robert Cummings

Nathan Rixham wrote:

Robert Cummings wrote:

Nathan Rixham wrote:

Robert Cummings wrote:

Nathan Rixham wrote:

Robert Cummings wrote:

steve_r wrote:

I'm new to programming

function check_it2($val) {
echo gettype($val);
switch($val) {
case($val > 0 ):
echo "Switch greater than 0";


You're a tad confused :)

Q: What is the result of $val > 0?
A: false.

Q: What is the value of $val?
A: 0

Q: Is 0 equivalent to false?
A: Yes!

Use an if statement for this kind of logic.

This is a fantastic example of false logic and an easy pitfall.

in fact this would make a great interview question!

to expand a little on the various scenarios (just for clarity, Rob is
right)

$val = 1;
1 > 0 equates to TRUE
is 1 equivalent to TRUE : YES

$val = 0;
0 > 0 equates to FALSE
is 0 equivalent to FALSE : YES

$val = -1;
-1 > 0 equates to FALSE
is -1 equivalent to FALSE: YES

so no matter what value you set $val to; it's always true.

Fail on that last one. -1 is not equivalent to FALSE :B


well that's one job I'm not getting :p

Well you DID get 66.7%. I've met "coders" that would stare at the answer
and still not understand :D


the travesty is that I spent most of yesterday on trains brushing up on
/ studying formal logic!


Muphry's Law!!!

http://en.wikipedia.org/wiki/Muphry's_law

*heheh*

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] Basic switch statement

2010-04-13 Thread Nathan Rixham
Robert Cummings wrote:
> Nathan Rixham wrote:
>> Robert Cummings wrote:
>>> Nathan Rixham wrote:
 Robert Cummings wrote:
> steve_r wrote:
>> I'm new to programming
>>
>> function check_it2($val) {
>> echo gettype($val);
>> switch($val) {
>> case($val > 0 ):
>> echo "Switch greater than 0";
>> 
> You're a tad confused :)
>
> Q: What is the result of $val > 0?
> A: false.
>
> Q: What is the value of $val?
> A: 0
>
> Q: Is 0 equivalent to false?
> A: Yes!
>
> Use an if statement for this kind of logic.
 This is a fantastic example of false logic and an easy pitfall.

 in fact this would make a great interview question!

 to expand a little on the various scenarios (just for clarity, Rob is
 right)

 $val = 1;
 1 > 0 equates to TRUE
 is 1 equivalent to TRUE : YES

 $val = 0;
 0 > 0 equates to FALSE
 is 0 equivalent to FALSE : YES

 $val = -1;
 -1 > 0 equates to FALSE
 is -1 equivalent to FALSE: YES

 so no matter what value you set $val to; it's always true.
>>> Fail on that last one. -1 is not equivalent to FALSE :B
>>>
>>
>> well that's one job I'm not getting :p
> 
> Well you DID get 66.7%. I've met "coders" that would stare at the answer
> and still not understand :D

the travesty is that I spent most of yesterday on trains brushing up on
/ studying formal logic!



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



Re: [PHP] Basic switch statement

2010-04-13 Thread Robert Cummings

Nathan Rixham wrote:

Robert Cummings wrote:

Nathan Rixham wrote:

Robert Cummings wrote:

steve_r wrote:

I'm new to programming, drive a truck in the day, now taking night
courses
to get a better job for my family.  Please bear with me if this is a
dumb
question, I don't have much experience.

I'm taking a night class in HTML and PHP and can't figure out a
problem and
can't find the answer in the book for the course ("Beginning PHP5" by
Wrox
Press), on the switch manual page on php.net, or in any postings to
this
mailing list.

I'm trying to pass a value to a simple integer to a function, and then
use
that value in a switch statement.  The problem I'm having is that
regardless
of the value of 'val', the first case statement always executes.  Even
if I
put '$val = 0' right before the case statement, the first case
statement
executes.  The syntax looks correct based on the php.net man page for
switch
and from the user examples.  It also matches the example in the book.

function check_it2($val) {
echo gettype($val);
switch($val) {
case($val > 0 ):
echo "Switch greater than 0";
$diff_obj = 1;
break;
case($val < 0 ):
echo "Less than 0";
$diff_obj = -1;
break;
default:
echo "Equal to 0";
$diff_obj = 0;
}
print("Here's \$diff_obj2 in the function: " . $diff_obj);
return $diff_obj;
}

You're a tad confused :)

Q: What is the result of $val > 0?
A: false.

Q: What is the value of $val?
A: 0

Q: Is 0 equivalent to false?
A: Yes!

Use an if statement for this kind of logic.

This is a fantastic example of false logic and an easy pitfall.

in fact this would make a great interview question!

to expand a little on the various scenarios (just for clarity, Rob is
right)

$val = 1;
1 > 0 equates to TRUE
is 1 equivalent to TRUE : YES

$val = 0;
0 > 0 equates to FALSE
is 0 equivalent to FALSE : YES

$val = -1;
-1 > 0 equates to FALSE
is -1 equivalent to FALSE: YES

so no matter what value you set $val to; it's always true.

Fail on that last one. -1 is not equivalent to FALSE :B



well that's one job I'm not getting :p


Well you DID get 66.7%. I've met "coders" that would stare at the answer 
and still not understand :D


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] Basic switch statement

2010-04-13 Thread Nathan Rixham
Robert Cummings wrote:
> Nathan Rixham wrote:
>> Robert Cummings wrote:
>>> steve_r wrote:
 I'm new to programming, drive a truck in the day, now taking night
 courses
 to get a better job for my family.  Please bear with me if this is a
 dumb
 question, I don't have much experience.

 I'm taking a night class in HTML and PHP and can't figure out a
 problem and
 can't find the answer in the book for the course ("Beginning PHP5" by
 Wrox
 Press), on the switch manual page on php.net, or in any postings to
 this
 mailing list.

 I'm trying to pass a value to a simple integer to a function, and then
 use
 that value in a switch statement.  The problem I'm having is that
 regardless
 of the value of 'val', the first case statement always executes.  Even
 if I
 put '$val = 0' right before the case statement, the first case
 statement
 executes.  The syntax looks correct based on the php.net man page for
 switch
 and from the user examples.  It also matches the example in the book.

 function check_it2($val) {
 echo gettype($val);
 switch($val) {
 case($val > 0 ):
 echo "Switch greater than 0";
 $diff_obj = 1;
 break;
 case($val < 0 ):
 echo "Less than 0";
 $diff_obj = -1;
 break;
 default:
 echo "Equal to 0";
 $diff_obj = 0;
 }
 print("Here's \$diff_obj2 in the function: " . $diff_obj);
 return $diff_obj;
 }
>>> You're a tad confused :)
>>>
>>> Q: What is the result of $val > 0?
>>> A: false.
>>>
>>> Q: What is the value of $val?
>>> A: 0
>>>
>>> Q: Is 0 equivalent to false?
>>> A: Yes!
>>>
>>> Use an if statement for this kind of logic.
>>
>> This is a fantastic example of false logic and an easy pitfall.
>>
>> in fact this would make a great interview question!
>>
>> to expand a little on the various scenarios (just for clarity, Rob is
>> right)
>>
>> $val = 1;
>> 1 > 0 equates to TRUE
>> is 1 equivalent to TRUE : YES
>>
>> $val = 0;
>> 0 > 0 equates to FALSE
>> is 0 equivalent to FALSE : YES
>>
>> $val = -1;
>> -1 > 0 equates to FALSE
>> is -1 equivalent to FALSE: YES
>>
>> so no matter what value you set $val to; it's always true.
> 
> Fail on that last one. -1 is not equivalent to FALSE :B
> 

well that's one job I'm not getting :p

cheers for the picking that one up Rob

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



Re: [PHP] Basic switch statement

2010-04-13 Thread Robert Cummings

Nathan Rixham wrote:

Robert Cummings wrote:

steve_r wrote:

I'm new to programming, drive a truck in the day, now taking night
courses
to get a better job for my family.  Please bear with me if this is a dumb
question, I don't have much experience.

I'm taking a night class in HTML and PHP and can't figure out a
problem and
can't find the answer in the book for the course ("Beginning PHP5" by
Wrox
Press), on the switch manual page on php.net, or in any postings to this
mailing list.

I'm trying to pass a value to a simple integer to a function, and then
use
that value in a switch statement.  The problem I'm having is that
regardless
of the value of 'val', the first case statement always executes.  Even
if I
put '$val = 0' right before the case statement, the first case statement
executes.  The syntax looks correct based on the php.net man page for
switch
and from the user examples.  It also matches the example in the book.

function check_it2($val) {
echo gettype($val);
switch($val) {
case($val > 0 ):
echo "Switch greater than 0";
$diff_obj = 1;
break;
case($val < 0 ):
echo "Less than 0";
$diff_obj = -1;
break;
default:
echo "Equal to 0";
$diff_obj = 0;
}
print("Here's \$diff_obj2 in the function: " . $diff_obj);
return $diff_obj;
}

You're a tad confused :)

Q: What is the result of $val > 0?
A: false.

Q: What is the value of $val?
A: 0

Q: Is 0 equivalent to false?
A: Yes!

Use an if statement for this kind of logic.


This is a fantastic example of false logic and an easy pitfall.

in fact this would make a great interview question!

to expand a little on the various scenarios (just for clarity, Rob is right)

$val = 1;
1 > 0 equates to TRUE
is 1 equivalent to TRUE : YES

$val = 0;
0 > 0 equates to FALSE
is 0 equivalent to FALSE : YES

$val = -1;
-1 > 0 equates to FALSE
is -1 equivalent to FALSE: YES

so no matter what value you set $val to; it's always true.


Fail on that last one. -1 is not equivalent to FALSE :B

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] Saving form data into session before leaving a page

2010-04-13 Thread Nathan Rixham
Peter Lind wrote:
> On 13 April 2010 17:27, Paul M Foster  wrote:
>> On Tue, Apr 13, 2010 at 03:20:23PM +0200, Merlin Morgenstern wrote:
>>
>>> Hello everybody,
>>>
>>> I have form where users enter data to be saved in a db.
>>>
>>> How can I make php save the form data into a session before the user
>>> leaves the page without pressing the submit button? Some members leave
>>> the page and return afterwards wondering where their already entered
>>> data is.
>> I hate to be a contrarian (not really), but there is a paradigm for
>> using web forms. If you want the internet to save your data, you have to
>> press the little button. If you don't, then it won't be saved. Not hard
>> to figure out, not hard to do. If you have to go do something else while
>> you're in the middle of a form, open a new tab/window and do it. When
>> you come back to your original form, the data will still be there (but
>> again, not *saved* until you hit the little button).
>>
>> Sorry, I just get cranky with people who won't follow the rules.
> 
> There are rules and then there's stupidity based on tradition. The
> fact that websites previously threw away whatever work you had done
> because you automatically got logged out of your session after half an
> hour of typing does not mean you should call this a rule that should
> be adhere to. Google figured it out and did so well: backup
> automatically and let the user discard manually - not the other way
> round that leads to lost work.
> 
> Apart from that, I note that the OP has seemingly managed to solve the
> problem and all these emails are rather pointless.

Concur, and this is nothing to do with the web; http only constrains
that the data should be POSTed or PUT; not /when/ a save action is
triggered.

Functionality is in the realm of the application, and if the client
application (in this case the web page) determines that information
should be iteratively saved, then that's what it should do.

see google docs, gmail etc for real world examples.

Regards!

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



Re: [PHP] Basic switch statement

2010-04-13 Thread Nathan Rixham
Robert Cummings wrote:
> steve_r wrote:
>> I'm new to programming, drive a truck in the day, now taking night
>> courses
>> to get a better job for my family.  Please bear with me if this is a dumb
>> question, I don't have much experience.
>>
>> I'm taking a night class in HTML and PHP and can't figure out a
>> problem and
>> can't find the answer in the book for the course ("Beginning PHP5" by
>> Wrox
>> Press), on the switch manual page on php.net, or in any postings to this
>> mailing list.
>>
>> I'm trying to pass a value to a simple integer to a function, and then
>> use
>> that value in a switch statement.  The problem I'm having is that
>> regardless
>> of the value of 'val', the first case statement always executes.  Even
>> if I
>> put '$val = 0' right before the case statement, the first case statement
>> executes.  The syntax looks correct based on the php.net man page for
>> switch
>> and from the user examples.  It also matches the example in the book.
>>
>> function check_it2($val) {
>> echo gettype($val);
>> switch($val) {
>> case($val > 0 ):
>> echo "Switch greater than 0";
>> $diff_obj = 1;
>> break;
>> case($val < 0 ):
>> echo "Less than 0";
>> $diff_obj = -1;
>> break;
>> default:
>> echo "Equal to 0";
>> $diff_obj = 0;
>> }
>> print("Here's \$diff_obj2 in the function: " . $diff_obj);
>> return $diff_obj;
>> }
> 
> You're a tad confused :)
> 
> Q: What is the result of $val > 0?
> A: false.
> 
> Q: What is the value of $val?
> A: 0
> 
> Q: Is 0 equivalent to false?
> A: Yes!
> 
> Use an if statement for this kind of logic.

This is a fantastic example of false logic and an easy pitfall.

in fact this would make a great interview question!

to expand a little on the various scenarios (just for clarity, Rob is right)

$val = 1;
1 > 0 equates to TRUE
is 1 equivalent to TRUE : YES

$val = 0;
0 > 0 equates to FALSE
is 0 equivalent to FALSE : YES

$val = -1;
-1 > 0 equates to FALSE
is -1 equivalent to FALSE: YES

so no matter what value you set $val to; it's always true.

lovely

Regards!


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



Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Peter Lind
On 13 April 2010 17:27, Paul M Foster  wrote:
> On Tue, Apr 13, 2010 at 03:20:23PM +0200, Merlin Morgenstern wrote:
>
>> Hello everybody,
>>
>> I have form where users enter data to be saved in a db.
>>
>> How can I make php save the form data into a session before the user
>> leaves the page without pressing the submit button? Some members leave
>> the page and return afterwards wondering where their already entered
>> data is.
>
> I hate to be a contrarian (not really), but there is a paradigm for
> using web forms. If you want the internet to save your data, you have to
> press the little button. If you don't, then it won't be saved. Not hard
> to figure out, not hard to do. If you have to go do something else while
> you're in the middle of a form, open a new tab/window and do it. When
> you come back to your original form, the data will still be there (but
> again, not *saved* until you hit the little button).
>
> Sorry, I just get cranky with people who won't follow the rules.

There are rules and then there's stupidity based on tradition. The
fact that websites previously threw away whatever work you had done
because you automatically got logged out of your session after half an
hour of typing does not mean you should call this a rule that should
be adhere to. Google figured it out and did so well: backup
automatically and let the user discard manually - not the other way
round that leads to lost work.

Apart from that, I note that the OP has seemingly managed to solve the
problem and all these emails are rather pointless.



-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


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



Re: [PHP] Solution

2010-04-13 Thread Karl DeSaulniers

My mistake. You are correct.

Karl


On Apr 13, 2010, at 2:16 PM, Jim Lucas wrote:

Karl DeSaulniers wrote:

Hey Gary, instead try something like this maybe?


$dbc=mysqli_connect('localhost','root','','test') or die('Error
connecting to MySQL server');

$query_name="INSERT INTO name(fname='$fname', lname='$lname')";
$query_address="INSERT INTO address (street='$street', town='$town',
state='$state', zip='$zip')";


Their are a few syntax variations available, but the one that they  
used is not a
valid format.  The following are the insert statements written in a  
valid format.


$query_name = "INSERT INTO name (
 fname,lname
   ) VALUES (
   '$fname', '$lname'
   )";

$query_address = "INSERT INTO address (
 street,town,state,zip
   ) VALUES {
   '$street', '$town', '$state', '$zip'
   )";

Try this, it should work.



$result1=mysqli_query($dbc, $query_name) or die('Error querying  
database

for name.');

$result2=mysqli_query($dbc, $query_address) or die('Error querying
database for address.');

echo "Success!";

?>

HTH,

Karl


On Apr 12, 2010, at 5:16 PM, Peter Lind wrote:


$dbc=mysqli_connect('localhost','root','','test')or die('Error
connecting to
MySQL server');

$query="INSERT INTO name(fname, lname)"."VALUES('$fname','$lname')";

$result=mysqli_query($dbc, $query)
or die('Error querying database.');

mysqli_close($dbc);
?>




Karl DeSaulniers
Design Drumm
http://designdrumm.com





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


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP] Solution

2010-04-13 Thread tedd

At 3:09 PM -0400 4/13/10, Andrew Ballard wrote:

On Tue, Apr 13, 2010 at 2:50 PM, tedd  wrote:

 For example, a user has name, address, height, weight, color, language, etc.
 Those things can be listed in a single table.


And now for the universal DBA answer - it depends. There are cases
where that information needs to be normalized to another table. A
person could have a billing address, a shipping address, a vacation
address, etc. Or the application may need to store multiple addresses
over time. The same person could have a home phone, office phone, fax,
mobile phone, pager, etc.

Andrew



Andrew:

Of course.

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

2010-04-13 Thread Jim Lucas
Andrew Ballard wrote:
> On Tue, Apr 13, 2010 at 2:50 PM, tedd  wrote:
>> For example, a user has name, address, height, weight, color, language, etc.
>> Those things can be listed in a single table.
> 
> And now for the universal DBA answer - it depends. There are cases
> where that information needs to be normalized to another table. A
> person could have a billing address, a shipping address, a vacation
> address, etc. Or the application may need to store multiple addresses
> over time. The same person could have a home phone, office phone, fax,
> mobile phone, pager, etc.
> 
> Andrew
> 

My business related example is our billing system in my office.

For each customer account we have a single Billing address but allow multiple
service, technical, administrative, etc... contact entries.  We must keep past
entries for historical purposes too.  This is achieved by having two separate
tables to hold the data.  It is a 1 to nth relationship.

PS: Gary, fix your mail server.  It is telling me that you don't exist.

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

2010-04-13 Thread Jim Lucas
Karl DeSaulniers wrote:
> Hey Gary, instead try something like this maybe?
> 
> 
> $dbc=mysqli_connect('localhost','root','','test') or die('Error
> connecting to MySQL server');
> 
> $query_name="INSERT INTO name(fname='$fname', lname='$lname')";
> $query_address="INSERT INTO address (street='$street', town='$town',
> state='$state', zip='$zip')";

Their are a few syntax variations available, but the one that they used is not a
valid format.  The following are the insert statements written in a valid 
format.

$query_name = "INSERT INTO name (
 fname,lname
   ) VALUES (
   '$fname', '$lname'
   )";

$query_address = "INSERT INTO address (
 street,town,state,zip
   ) VALUES {
   '$street', '$town', '$state', '$zip'
   )";

Try this, it should work.

> 
> $result1=mysqli_query($dbc, $query_name) or die('Error querying database
> for name.');
> 
> $result2=mysqli_query($dbc, $query_address) or die('Error querying
> database for address.');
> 
> echo "Success!";
> 
> ?>
> 
> HTH,
> 
> Karl
> 
> 
> On Apr 12, 2010, at 5:16 PM, Peter Lind wrote:
> 
>> $dbc=mysqli_connect('localhost','root','','test')or die('Error
>> connecting to
>> MySQL server');
>>
>> $query="INSERT INTO name(fname, lname)"."VALUES('$fname','$lname')";
>>
>> $result=mysqli_query($dbc, $query)
>> or die('Error querying database.');
>>
>> mysqli_close($dbc);
>> ?>
>>
>> >
>> $dbc=mysqli_connect('localhost','root','','test')or die('Error
>> connecting to
>> MySQL server');
>> $query="INSERT INTO address (street, town, state,
>> zip)"."VALUES('$street','$town','$state','$zip')";
>>
>> $result=mysqli_query($dbc, $query)
>> or die('Error querying database.');
>>
>> mysqli_close($dbc);
>>
>> ?>
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
> 
> 


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

2010-04-13 Thread Andrew Ballard
On Tue, Apr 13, 2010 at 2:50 PM, tedd  wrote:
> For example, a user has name, address, height, weight, color, language, etc.
> Those things can be listed in a single table.

And now for the universal DBA answer - it depends. There are cases
where that information needs to be normalized to another table. A
person could have a billing address, a shipping address, a vacation
address, etc. Or the application may need to store multiple addresses
over time. The same person could have a home phone, office phone, fax,
mobile phone, pager, etc.

Andrew

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



Re: [PHP] Solution

2010-04-13 Thread Gary
Karl

Thanks for the reply, I copied your code and it did not work, tried a few 
variations and same result.

Gary
"Karl DeSaulniers"  wrote in message 
news:e56be001-63f6-4df1-8c72-ad468c23e...@designdrumm.com...
> Hey Gary, instead try something like this maybe?
>
>
> $dbc=mysqli_connect('localhost','root','','test') or die('Error 
> connecting to MySQL server');
>
> $query_name="INSERT INTO name(fname='$fname', lname='$lname')";
> $query_address="INSERT INTO address (street='$street', town='$town', 
> state='$state', zip='$zip')";
>
> $result1=mysqli_query($dbc, $query_name) or die('Error querying  database 
> for name.');
>
> $result2=mysqli_query($dbc, $query_address) or die('Error querying 
> database for address.');
>
> echo "Success!";
>
> ?>
>
> HTH,
>
> Karl
>
>
> On Apr 12, 2010, at 5:16 PM, Peter Lind wrote:
>
>> $dbc=mysqli_connect('localhost','root','','test')or die('Error 
>> connecting to
>> MySQL server');
>>
>> $query="INSERT INTO name(fname, lname)"."VALUES('$fname','$lname')";
>>
>> $result=mysqli_query($dbc, $query)
>> or die('Error querying database.');
>>
>> mysqli_close($dbc);
>> ?>
>>
>> >
>> $dbc=mysqli_connect('localhost','root','','test')or die('Error 
>> connecting to
>> MySQL server');
>> $query="INSERT INTO address (street, town, state,
>> zip)"."VALUES('$street','$town','$state','$zip')";
>>
>> $result=mysqli_query($dbc, $query)
>> or die('Error querying database.');
>>
>> mysqli_close($dbc);
>>
>> ?>
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
> __ Information from ESET Smart Security, version of virus 
> signature database 5023 (20100412) __
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__ Information from ESET Smart Security, version of virus signature 
database 5026 (20100413) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Solution

2010-04-13 Thread tedd

At 12:26 PM -0400 4/13/10, Gary wrote:

Tedd

I had four tables.  name, (fname, lname) address(street, town, state, zip),
contact(phone, fax, email), comments (comments).

It was done this way because it is strictly a learning exercise.  I had
never created a DB with multiple tables, so I wanted to be able to contruct
one using foreign keys, and be able to insert and retrieve from it.

But the experiment continues.  For whatever reason, scripts to query a DB
that I have used for years are not working.  I am thinking it has something
to do with that I switched engines to innodb.

So the lesson continues.

Gary


Gary:

One of the concepts in OOP is identifying an object in terms of it's 
attributes and functions. The concept of defining tables is very 
similar.


If you want to learn about foreign keys, then think of them as things 
that are foreign and not things that are similar.


For example, a user has name, address, height, weight, color, 
language, etc. Those things can be listed in a single table.


A item that can be purchased, like a chair has a title, description, 
weight, color, cost and such. Those things can also be listed in a 
single table.


If a person buys a chair and the seller wants to create a record of 
the purchase, then all the seller needs to do is to record the 
buyer's and the chair's attributes. Now, the seller can either write 
down all the attributes for each buyer/chair sale OR reference them 
using foreign keys.


User Table
id = 123
name = tedd
address = whatever

Item Table
id = 456
name = chair
color = whatever

Sales Table
item sold = 456
buyer = 123

Done!

Get the idea?

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] Saving form data into session before leaving a page

2010-04-13 Thread Dan Joseph
On Tue, Apr 13, 2010 at 1:46 PM, Robert Cummings wrote:

>
> Toilets flush themselves so that we don't need to touch what someone else
> touched... very likely after *cough* wiping up.
>
>

They have a cure for having to life a finger and wipe also  but I won't
continue lol

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code "NEWTHINGS" for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Solution

2010-04-13 Thread Jim Lucas
tedd wrote:
> 
> I don't see any reason to separate the attributes of the person into two
> different tables. Why do that?
> 

tedd,

Funny you ask this.  I have always thought the same thing.  Then just last week
I started listing to the Zend Dev Zone podcasts.  I came across this one and
thought it was very informative.

http://devzone.zend.com/article/4497-The-ZendCon-Sessions-Episode-17-SQL-Query-Tuning-The-Legend-of-Drunken-Query-Master

It is pretty long, but it contains a lot of good information.

Listen the part about how many records you can contain in memory.

-- 
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] Saving form data into session before leaving a page

2010-04-13 Thread Robert Cummings



tedd wrote:

At 12:40 PM -0400 4/13/10, Robert Cummings wrote:

Dan Joseph wrote:

On Tue, Apr 13, 2010 at 12:19 PM, tedd  wrote:


So, OP explain what you are trying to do?

Cheers,

tedd


Sorta looks to me like he's in a situation where users are fleeing the form,
and wondering why its not filled in when they go back.  The natural reaction
for this would be to call it abnormal, and tell them to learn how to use a
web page, but we all know how the real world is.

I like the original ideas from Peter and Ashley.  Store a session or cookie,
use ajax to periodically update a database table with the information, then
re-populate it if/when they come back.

I kinda like that word Paradigm.  Rolls off the tongue nicely.  I'm going to
use it 3 times today before I leave the office.
I had a pair-a-dimes one time. Unfortunately I was a nickel short of 
a quarter to put in the slot.


:)

Cheers,
Rob.


Rob:

I had a pair-a-ducks -- but they were afoul fowl.

I had a pair-a-dice -- but crapped out.

I had a pair-a-chute -- but one was shorter.

I had a pair-of-pants -- but could only find one.


So to paraphrase...

You had a pair-a-ducks that lived in pair-a-dice but when pair-a-chuting 
 only one could find a pair-a-pants because the other one was shorter?


Gotcha... clear as tar!

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] Saving form data into session before leaving a page

2010-04-13 Thread Robert Cummings

Kevin Kinsey wrote:

Dan Joseph wrote:

On Tue, Apr 13, 2010 at 12:40 PM, Robert Cummings wrote


I had a pair-a-dimes one time. Unfortunately I was a nickel short of a
quarter to put in the slot.

But the question is... were they outside the box?


Nah, the question is, since the slot was intended to accept a quarter,
why the heck didn't it take two dimes and a nickel ... or just two dimes,
and throw a nickel in gratis?


I've never known an arcade machine to accept nickels and dimes :)


I must be getting old.  We have toilets that flush themselves now.
WTF happened to "grown up" being equal to taking responsibility
for things?


Toilets flush themselves so that we don't need to touch what someone 
else touched... very likely after *cough* wiping up.


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] Saving form data into session before leaving a page

2010-04-13 Thread Robert Cummings

Dan Joseph wrote:

On Tue, Apr 13, 2010 at 12:40 PM, Robert Cummings wrote


I had a pair-a-dimes one time. Unfortunately I was a nickel short of a
quarter to put in the slot.


>

But the question is... were they outside the box?


They were in my pocket... so yes!

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] Saving form data into session before leaving a page

2010-04-13 Thread tedd

At 12:40 PM -0400 4/13/10, Robert Cummings wrote:

Dan Joseph wrote:

On Tue, Apr 13, 2010 at 12:19 PM, tedd  wrote:


So, OP explain what you are trying to do?

Cheers,

tedd



Sorta looks to me like he's in a situation where users are fleeing the form,
and wondering why its not filled in when they go back.  The natural reaction
for this would be to call it abnormal, and tell them to learn how to use a
web page, but we all know how the real world is.

I like the original ideas from Peter and Ashley.  Store a session or cookie,
use ajax to periodically update a database table with the information, then
re-populate it if/when they come back.

I kinda like that word Paradigm.  Rolls off the tongue nicely.  I'm going to
use it 3 times today before I leave the office.


I had a pair-a-dimes one time. Unfortunately I was a nickel short of 
a quarter to put in the slot.


:)

Cheers,
Rob.


Rob:

I had a pair-a-ducks -- but they were afoul fowl.

I had a pair-a-dice -- but crapped out.

I had a pair-a-chute -- but one was shorter.

I had a pair-of-pants -- but could only find one.

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] Saving form data into session before leaving a page

2010-04-13 Thread Paul M Foster
On Tue, Apr 13, 2010 at 12:36:02PM -0400, Dan Joseph wrote:



> I kinda like that word Paradigm.  Rolls off the tongue nicely.  I'm going to
> use it 3 times today before I leave the office. 

ROTFL!

Paul

-- 
Paul M. Foster

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



Re: [PHP] Basic switch statement

2010-04-13 Thread tedd

At 12:04 PM -0400 4/13/10, steve_r wrote:

I'm new to programming, drive a truck in the day, now taking night courses
to get a better job for my family.  Please bear with me if this is a dumb
question, I don't have much experience.

-snip-

Sorry for the basic question.

Steve Reilly



Steve:

Please review:

http://php1.net/c/switch/

Note:

1. The value of the switch statement in this case is "true" (it could 
also be '1'). This is different than what's found in most other 
case/switch control structures in other languages.


2. Generally you should use functions to process and return values 
and then decide as to what to do with the results, such as print(). 
Putting print in functions is fine if the function is supposed to 
print something.


3. Try to make your variables and function names simple and 
syntactical -- it will help you later when your code becomes more 
complex.


Good luck with trying to make a better living programming than driving a truck.

If you want to say thanks for my effort, please answer me this -- 
with regard to the class you are talking: What is the name of the 
class? How many credits is it? What's the name of the textbook you 
are using? And, if there is a syllabus, can I have a copy?


Thanks,

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] Saving form data into session before leaving a page

2010-04-13 Thread Dan Joseph
On Tue, Apr 13, 2010 at 12:48 PM, Kevin Kinsey  wrote:

> Nah, the question is, since the slot was intended to accept a quarter,
> why the heck didn't it take two dimes and a nickel ... or just two dimes,
> and throw a nickel in gratis?
>
> I must be getting old.  We have toilets that flush themselves now.
> WTF happened to "grown up" being equal to taking responsibility
> for things?
>

I think you've found the answer to the great question of why people don't
take responsibility anymore...  it all started with the toilet!

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code "NEWTHINGS" for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Kevin Kinsey

Dan Joseph wrote:

On Tue, Apr 13, 2010 at 12:40 PM, Robert Cummings wrote


I had a pair-a-dimes one time. Unfortunately I was a nickel short of a
quarter to put in the slot.

But the question is... were they outside the box?




Nah, the question is, since the slot was intended to accept a quarter,
why the heck didn't it take two dimes and a nickel ... or just two dimes,
and throw a nickel in gratis?

I must be getting old.  We have toilets that flush themselves now.
WTF happened to "grown up" being equal to taking responsibility
for things?

KDK

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



Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Dan Joseph
On Tue, Apr 13, 2010 at 12:40 PM, Robert Cummings wrote

> I had a pair-a-dimes one time. Unfortunately I was a nickel short of a
> quarter to put in the slot.
>
> But the question is... were they outside the box?

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code "NEWTHINGS" for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Robert Cummings

Dan Joseph wrote:

On Tue, Apr 13, 2010 at 12:19 PM, tedd  wrote:


So, OP explain what you are trying to do?

Cheers,

tedd



Sorta looks to me like he's in a situation where users are fleeing the form,
and wondering why its not filled in when they go back.  The natural reaction
for this would be to call it abnormal, and tell them to learn how to use a
web page, but we all know how the real world is.

I like the original ideas from Peter and Ashley.  Store a session or cookie,
use ajax to periodically update a database table with the information, then
re-populate it if/when they come back.

I kinda like that word Paradigm.  Rolls off the tongue nicely.  I'm going to
use it 3 times today before I leave the office.


I had a pair-a-dimes one time. Unfortunately I was a nickel short of a 
quarter to put in the slot.


:)

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] Saving form data into session before leaving a page

2010-04-13 Thread Dan Joseph
On Tue, Apr 13, 2010 at 12:19 PM, tedd  wrote:

> So, OP explain what you are trying to do?
>
> Cheers,
>
> tedd


Sorta looks to me like he's in a situation where users are fleeing the form,
and wondering why its not filled in when they go back.  The natural reaction
for this would be to call it abnormal, and tell them to learn how to use a
web page, but we all know how the real world is.

I like the original ideas from Peter and Ashley.  Store a session or cookie,
use ajax to periodically update a database table with the information, then
re-populate it if/when they come back.

I kinda like that word Paradigm.  Rolls off the tongue nicely.  I'm going to
use it 3 times today before I leave the office.

-- 
-Dan Joseph

www.canishosting.com - Unlimited Hosting Plans start @ $3.95/month.  Promo
Code "NEWTHINGS" for 10% off initial order

http://www.facebook.com/canishosting
http://www.facebook.com/originalpoetry


Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Kevin Kinsey

Paul M Foster wrote:


Sorry, I just get cranky with people who won't follow the rules.





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



Re: [PHP] Solution

2010-04-13 Thread Gary
Tedd

I had four tables.  name, (fname, lname) address(street, town, state, zip), 
contact(phone, fax, email), comments (comments).

It was done this way because it is strictly a learning exercise.  I had 
never created a DB with multiple tables, so I wanted to be able to contruct 
one using foreign keys, and be able to insert and retrieve from it.

But the experiment continues.  For whatever reason, scripts to query a DB 
that I have used for years are not working.  I am thinking it has something 
to do with that I switched engines to innodb.

So the lesson continues.

Gary

"tedd"  wrote in message 
news:p06240804c7ea44eb9...@[192.168.1.102]...
> At 6:04 PM -0400 4/12/10, Gary wrote:
>>For those that were looking to see a solution, this is what I have come up
>>with.  It was pointed out on another board (MySQL) that inserting multiple
>>in one script is probably prohibited because of security reasons.
>>
>>What I did was open the connection, insert into the table, close the
>>connection, close the php script, then start over again.  This is the 
>>code:
>>
>>$dbc=mysqli_connect('localhost','root','','test')or die('Error connecting 
>>to
>>MySQL server');
>>
>>$query="INSERT INTO name(fname, lname)"."VALUES('$fname','$lname')";
>>
>>$result=mysqli_query($dbc, $query)
>>or die('Error querying database.');
>>
>>mysqli_close($dbc);
>>?>
>>
>>>
>>$dbc=mysqli_connect('localhost','root','','test')or die('Error connecting 
>>to
>>MySQL server');
>>$query="INSERT INTO address (street, town, state,
>>zip)"."VALUES('$street','$town','$state','$zip')";
>>
>>$result=mysqli_query($dbc, $query)
>>or die('Error querying database.');
>>
>>mysqli_close($dbc);
>>
>>?>
>>
>>It seems a little redundant for PHP, however it seems to work.
>>
>>Thank you to everyone that responded.  If by the way someone sees an issue
>>with this solution, I would love to read it.
>>
>>Gary
>
> Gary :
>
> It not only looks redundant, but why two tables?
>
> Why not "customers" or "users" or "subscribers" like so:
>
> include(opendb.php);
>
> $query="INSERT INTO users (first_name, last_name, street, town, state, 
> zip)
> VALUES('$first_name', '$last_name', $street', '$town', '$state', '$zip')";
>
> $result=mysqli_query($dbc, $query) or die('Error querying database.');
>
> include(closedb.php);
>
> I don't see any reason to separate the attributes of the person into two 
> different tables. Why do that?
>
> Cheers,
>
> tedd
>
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> __ Information from ESET Smart Security, version of virus 
> signature database 5025 (20100413) __
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__ Information from ESET Smart Security, version of virus signature 
database 5025 (20100413) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Re: how to overload accessible methods

2010-04-13 Thread Ryan Sun
this is a class for corntab job, and the validation is very simple,
just check if the status of user is active when cron job runs, if not,
throws an exception, other developers won't want to overwrite this
validation.
which method of user class will be called is configurable via website
backed page(we write the name of methods directly in to  schedule
table).
Using private methods will solve the problem but since we write public
methods for all the other cron classes, I just want to keep the style
to make less confusion.

On Tue, Apr 13, 2010 at 12:11 PM, Nathan Rixham  wrote:
> Ryan Sun wrote:
>> I'm writing an abstract parent class which only contain a validate
>> method, other developers will extend this class and add many new
>> public methods, every new methods will need to perform a validate
>> first.  Won't it be good if validate get called automatically before
>> every method call so that they don't have to write more code and they
>> won't miss this validate?
>
> This may call for a back to roots approach, what exactly are you trying
> to accomplish, as in: what is the validation doing?
>
> perhaps if we see the full picture, we can recommend another perhaps
> more suited approach to the full thing, feel free to post the full code
> if you want / can, the more info the better!
>
> Regards,
>
> Nathan
>

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



Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread tedd

At 11:27 AM -0400 4/13/10, Paul M Foster wrote:

On Tue, Apr 13, 2010 at 03:20:23PM +0200, Merlin Morgenstern wrote:


 Hello everybody,

 I have form where users enter data to be saved in a db.

 How can I make php save the form data into a session before the user
 leaves the page without pressing the submit button? Some members leave
 the page and return afterwards wondering where their already entered
 data is.


I hate to be a contrarian (not really), but there is a paradigm for
using web forms. If you want the internet to save your data, you have to
press the little button. If you don't, then it won't be saved. Not hard
to figure out, not hard to do. If you have to go do something else while
you're in the middle of a form, open a new tab/window and do it. When
you come back to your original form, the data will still be there (but
again, not *saved* until you hit the little button).

Sorry, I just get cranky with people who won't follow the rules.

Paul


Paul:

What rules? I didn't see any rules. There are simply easy ways to do 
things and those not so easy -- like jumping out the window or using 
the stairs. You arrive at the same place, but at what cost?


In this case, I don't think the OP has provided us with enough 
information about his problem.


If he is concerned that his users may return to a page and wants the 
fields filled with what the user previously entered, then that 
depends upon several different things, such as has the user shut down 
his browser, or has the user simply clicked the submit button and the 
page has been refreshed. IOW, how has the user left the page?


So, OP explain what you are trying to do?

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] Basic switch statement

2010-04-13 Thread steve_r
Okay, I understand now, true/false is better, now it makes sense why it's
always hitting the case it hits.  Thank you Ashley.


Re: [PHP] Basic switch statement

2010-04-13 Thread Robert Cummings

steve_r wrote:

I'm new to programming, drive a truck in the day, now taking night courses
to get a better job for my family.  Please bear with me if this is a dumb
question, I don't have much experience.

I'm taking a night class in HTML and PHP and can't figure out a problem and
can't find the answer in the book for the course ("Beginning PHP5" by Wrox
Press), on the switch manual page on php.net, or in any postings to this
mailing list.

I'm trying to pass a value to a simple integer to a function, and then use
that value in a switch statement.  The problem I'm having is that regardless
of the value of 'val', the first case statement always executes.  Even if I
put '$val = 0' right before the case statement, the first case statement
executes.  The syntax looks correct based on the php.net man page for switch
and from the user examples.  It also matches the example in the book.

function check_it2($val) {
echo gettype($val);
switch($val) {
case($val > 0 ):
echo "Switch greater than 0";
$diff_obj = 1;
break;
case($val < 0 ):
echo "Less than 0";
$diff_obj = -1;
break;
default:
echo "Equal to 0";
$diff_obj = 0;
}
print("Here's \$diff_obj2 in the function: " . $diff_obj);
return $diff_obj;
}


You're a tad confused :)

Q: What is the result of $val > 0?
A: false.

Q: What is the value of $val?
A: 0

Q: Is 0 equivalent to false?
A: Yes!

Use an if statement for this kind of logic.

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] Basic switch statement

2010-04-13 Thread Ashley Sheridan
On Tue, 2010-04-13 at 12:04 -0400, steve_r wrote:

> I'm new to programming, drive a truck in the day, now taking night courses
> to get a better job for my family.  Please bear with me if this is a dumb
> question, I don't have much experience.
> 
> I'm taking a night class in HTML and PHP and can't figure out a problem and
> can't find the answer in the book for the course ("Beginning PHP5" by Wrox
> Press), on the switch manual page on php.net, or in any postings to this
> mailing list.
> 
> I'm trying to pass a value to a simple integer to a function, and then use
> that value in a switch statement.  The problem I'm having is that regardless
> of the value of 'val', the first case statement always executes.  Even if I
> put '$val = 0' right before the case statement, the first case statement
> executes.  The syntax looks correct based on the php.net man page for switch
> and from the user examples.  It also matches the example in the book.
> 
> function check_it2($val) {
> echo gettype($val);
> switch($val) {
> case($val > 0 ):
> echo "Switch greater than 0";
> $diff_obj = 1;
> break;
> case($val < 0 ):
> echo "Less than 0";
> $diff_obj = -1;
> break;
> default:
> echo "Equal to 0";
> $diff_obj = 0;
> }
> print("Here's \$diff_obj2 in the function: " . $diff_obj);
> return $diff_obj;
> }
> 
> I even put the following code before the switch statement just to make sure
> I'm not crazy:
> 
> $val = 0;
> if($val > 0) {
> echo "If greater than 0";
> }
> else {
> echo "If not greater than 0";
> }
> 
> and it falls through to the else as it should.
> 
> I've tried putting single and double quotes around the case variables but it
> always prints out the first value.  I've recoded to use a series of if
> statements but why isn't the switch working?   I've read through the 'loose
> comparison' section, but nothing appears to apply there.
> 
> Sorry for the basic question.
> 
> Steve Reilly


Change the first line of the switch to

switch(true)

and it will be functioning as you want. Normally, a switch has this
form:

switch($val)
{
case 1:
{
// statements
break;
}
case 10:
{
// statements
break;
}
default:
{
// statements
}
}

But PHP does allow you to use variable cases (as you have in your
example) if the value in the switch is a boolean (true or false). It can
be a little confusing if you're new to PHP (or programming in general)
but you'll get used to it after using it a few times.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Re: how to overload accessible methods

2010-04-13 Thread Nathan Rixham
Ryan Sun wrote:
> I'm writing an abstract parent class which only contain a validate
> method, other developers will extend this class and add many new
> public methods, every new methods will need to perform a validate
> first.  Won't it be good if validate get called automatically before
> every method call so that they don't have to write more code and they
> won't miss this validate?

This may call for a back to roots approach, what exactly are you trying
to accomplish, as in: what is the validation doing?

perhaps if we see the full picture, we can recommend another perhaps
more suited approach to the full thing, feel free to post the full code
if you want / can, the more info the better!

Regards,

Nathan

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



Re: [PHP] Solution

2010-04-13 Thread tedd

At 6:04 PM -0400 4/12/10, Gary wrote:

For those that were looking to see a solution, this is what I have come up
with.  It was pointed out on another board (MySQL) that inserting multiple
in one script is probably prohibited because of security reasons.

What I did was open the connection, insert into the table, close the
connection, close the php script, then start over again.  This is the code:

$dbc=mysqli_connect('localhost','root','','test')or die('Error connecting to
MySQL server');

$query="INSERT INTO name(fname, lname)"."VALUES('$fname','$lname')";

$result=mysqli_query($dbc, $query)
or die('Error querying database.');

mysqli_close($dbc);
?>



It seems a little redundant for PHP, however it seems to work.

Thank you to everyone that responded.  If by the way someone sees an issue
with this solution, I would love to read it.

Gary


Gary :

It not only looks redundant, but why two tables?

Why not "customers" or "users" or "subscribers" like so:

include(opendb.php);

$query="INSERT INTO users (first_name, last_name, street, town, state, zip)
VALUES('$first_name', '$last_name', $street', '$town', '$state', '$zip')";

$result=mysqli_query($dbc, $query) or die('Error querying database.');

include(closedb.php);

I don't see any reason to separate the attributes of the person into 
two different tables. Why do that?


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] Re: how to overload accessible methods

2010-04-13 Thread Ashley Sheridan
On Tue, 2010-04-13 at 12:03 -0400, Ryan Sun wrote:

> I'm writing an abstract parent class which only contain a validate
> method, other developers will extend this class and add many new
> public methods, every new methods will need to perform a validate
> first.  Won't it be good if validate get called automatically before
> every method call so that they don't have to write more code and they
> won't miss this validate?
> 
> On Tue, Apr 13, 2010 at 11:46 AM, Nathan Rixham  wrote:
> > Ryan Sun wrote:
> >> As we all know, __call() can overload non-accessible methods,
> >> eg.
> >> Class User
> >> {
> >> public function __call($name, $args)
> >> {
> >> //validate user
> >> $this->_validate();
> >>
> >> $this->_{$name}($args);
> >> }
> >> private function _validate()
> >> {
> >> //
> >> }
> >> private function _update($args)
> >> {
> >> //
> >> }
> >> }
> >>
> >> $user = new User();
> >> $user->update() // will call _validate before _update automatically
> >>
> >> BUT, if I want to make this update a public function, how can I call
> >> the validate without call it inside update function explicitly?
> >
> >
> > why would you want to, is there a technical reason for wanting magic
> > functionality instead of "normal" functionality (+ wouldn't it make the
> > code much easier to maintain and debug if developers can see what is
> > called where, instead of just magic).
> >
> > to answer though, you're best bet is probably to make an abstract class
> > with magic functionality and then extend with an implementing public class.
> >
> > abstract class MagicUser
> > {
> >public function __call($name, $args)
> >{
> >//validate user
> >$this->_validate();
> >$this->_{$name}($args);
> >}
> >
> >private function _validate()
> >{
> >//
> >}
> >private function _update($args)
> >{
> >//
> >}
> > }
> >
> > class User extends MagicUser
> > {
> >public function update($args)
> >{
> >parent::update($args);
> >}
> > }
> >
> >
> 


That would mean that the class can only be extended as far as your
validation code allows, and the developers extending your class will
have little control over how anything is validated.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Basic switch statement

2010-04-13 Thread steve_r
I'm new to programming, drive a truck in the day, now taking night courses
to get a better job for my family.  Please bear with me if this is a dumb
question, I don't have much experience.

I'm taking a night class in HTML and PHP and can't figure out a problem and
can't find the answer in the book for the course ("Beginning PHP5" by Wrox
Press), on the switch manual page on php.net, or in any postings to this
mailing list.

I'm trying to pass a value to a simple integer to a function, and then use
that value in a switch statement.  The problem I'm having is that regardless
of the value of 'val', the first case statement always executes.  Even if I
put '$val = 0' right before the case statement, the first case statement
executes.  The syntax looks correct based on the php.net man page for switch
and from the user examples.  It also matches the example in the book.

function check_it2($val) {
echo gettype($val);
switch($val) {
case($val > 0 ):
echo "Switch greater than 0";
$diff_obj = 1;
break;
case($val < 0 ):
echo "Less than 0";
$diff_obj = -1;
break;
default:
echo "Equal to 0";
$diff_obj = 0;
}
print("Here's \$diff_obj2 in the function: " . $diff_obj);
return $diff_obj;
}

I even put the following code before the switch statement just to make sure
I'm not crazy:

$val = 0;
if($val > 0) {
echo "If greater than 0";
}
else {
echo "If not greater than 0";
}

and it falls through to the else as it should.

I've tried putting single and double quotes around the case variables but it
always prints out the first value.  I've recoded to use a series of if
statements but why isn't the switch working?   I've read through the 'loose
comparison' section, but nothing appears to apply there.

Sorry for the basic question.

Steve Reilly


[PHP] Re: how to overload accessible methods

2010-04-13 Thread Ryan Sun
I'm writing an abstract parent class which only contain a validate
method, other developers will extend this class and add many new
public methods, every new methods will need to perform a validate
first.  Won't it be good if validate get called automatically before
every method call so that they don't have to write more code and they
won't miss this validate?

On Tue, Apr 13, 2010 at 11:46 AM, Nathan Rixham  wrote:
> Ryan Sun wrote:
>> As we all know, __call() can overload non-accessible methods,
>> eg.
>> Class User
>> {
>>     public function __call($name, $args)
>>     {
>>         //validate user
>>         $this->_validate();
>>
>>         $this->_{$name}($args);
>>     }
>>     private function _validate()
>>     {
>>         //
>>     }
>>     private function _update($args)
>>     {
>>         //
>>     }
>> }
>>
>> $user = new User();
>> $user->update() // will call _validate before _update automatically
>>
>> BUT, if I want to make this update a public function, how can I call
>> the validate without call it inside update function explicitly?
>
>
> why would you want to, is there a technical reason for wanting magic
> functionality instead of "normal" functionality (+ wouldn't it make the
> code much easier to maintain and debug if developers can see what is
> called where, instead of just magic).
>
> to answer though, you're best bet is probably to make an abstract class
> with magic functionality and then extend with an implementing public class.
>
> abstract class MagicUser
> {
>    public function __call($name, $args)
>    {
>        //validate user
>        $this->_validate();
>        $this->_{$name}($args);
>    }
>
>    private function _validate()
>    {
>        //
>    }
>    private function _update($args)
>    {
>        //
>    }
> }
>
> class User extends MagicUser
> {
>    public function update($args)
>    {
>        parent::update($args);
>    }
> }
>
>

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



[PHP] Re: how to overload accessible methods

2010-04-13 Thread Nathan Rixham
Ryan Sun wrote:
> As we all know, __call() can overload non-accessible methods,
> eg.
> Class User
> {
> public function __call($name, $args)
> {
> //validate user
> $this->_validate();
> 
> $this->_{$name}($args);
> }
> private function _validate()
> {
> //
> }
> private function _update($args)
> {
> //
> }
> }
> 
> $user = new User();
> $user->update() // will call _validate before _update automatically
> 
> BUT, if I want to make this update a public function, how can I call
> the validate without call it inside update function explicitly?


why would you want to, is there a technical reason for wanting magic
functionality instead of "normal" functionality (+ wouldn't it make the
code much easier to maintain and debug if developers can see what is
called where, instead of just magic).

to answer though, you're best bet is probably to make an abstract class
with magic functionality and then extend with an implementing public class.

abstract class MagicUser
{
public function __call($name, $args)
{
//validate user
$this->_validate();
$this->_{$name}($args);
}

private function _validate()
{
//
}
private function _update($args)
{
//
}
}

class User extends MagicUser
{
public function update($args)
{
parent::update($args);
}
}


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



[PHP] how to overload accessible methods

2010-04-13 Thread Ryan Sun
As we all know, __call() can overload non-accessible methods,
eg.
Class User
{
public function __call($name, $args)
{
//validate user
$this->_validate();

$this->_{$name}($args);
}
private function _validate()
{
//
}
private function _update($args)
{
//
}
}

$user = new User();
$user->update() // will call _validate before _update automatically

BUT, if I want to make this update a public function, how can I call
the validate without call it inside update function explicitly?

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



Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Paul M Foster
On Tue, Apr 13, 2010 at 03:20:23PM +0200, Merlin Morgenstern wrote:

> Hello everybody,
>
> I have form where users enter data to be saved in a db.
>
> How can I make php save the form data into a session before the user
> leaves the page without pressing the submit button? Some members leave
> the page and return afterwards wondering where their already entered
> data is.

I hate to be a contrarian (not really), but there is a paradigm for
using web forms. If you want the internet to save your data, you have to
press the little button. If you don't, then it won't be saved. Not hard
to figure out, not hard to do. If you have to go do something else while
you're in the middle of a form, open a new tab/window and do it. When
you come back to your original form, the data will still be there (but
again, not *saved* until you hit the little button).

Sorry, I just get cranky with people who won't follow the rules.

Paul

-- 
Paul M. Foster

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



Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Ashley Sheridan
On Tue, 2010-04-13 at 15:20 +0200, Merlin Morgenstern wrote:

> Hello everybody,
> 
> I have form where users enter data to be saved in a db.
> 
> How can I make php save the form data into a session before the user 
> leaves the page without pressing the submit button? Some members leave 
> the page and return afterwards wondering where their already entered 
> data is.
> 
> Any ideas how to save into php session data before someone leaves the page?
> 
> Thank you for any hint,
> 
> Merlin
> 


Session data is all stored on the server, so it requires a submit in
order for the server to actually get the data.

You could use Ajax to grab the form data and send it to the server if
you need though.

However, I'm not really sure what your question is. Are people visiting
your site, filling in a form, then pressing the back button to go
somewhere else? If so, maybe they intended to not submit the form.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Saving form data into session before leaving a page

2010-04-13 Thread Peter Lind
On 13 April 2010 15:20, Merlin Morgenstern  wrote:
> Hello everybody,
>
> I have form where users enter data to be saved in a db.
>
> How can I make php save the form data into a session before the user leaves
> the page without pressing the submit button? Some members leave the page and
> return afterwards wondering where their already entered data is.
>
> Any ideas how to save into php session data before someone leaves the page?

Use ajax: send a query to the server a couple of seconds after the
user has last updated the form.

> Thank you for any hint,
>
> Merlin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


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



[PHP] Saving form data into session before leaving a page

2010-04-13 Thread Merlin Morgenstern

Hello everybody,

I have form where users enter data to be saved in a db.

How can I make php save the form data into a session before the user 
leaves the page without pressing the submit button? Some members leave 
the page and return afterwards wondering where their already entered 
data is.


Any ideas how to save into php session data before someone leaves the page?

Thank you for any hint,

Merlin

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



RE: [PHP] Mail Function Problem

2010-04-13 Thread Ashley Sheridan
On Tue, 2010-04-13 at 08:59 -0400, Alice Wei wrote:

> 
> Subject: RE: [PHP] Mail Function Problem
> From: a...@ashleysheridan.co.uk
> To: aj...@alumni.iu.edu
> CC: k...@daleco.biz; a.bovane...@gmail.com; php-general@lists.php.net
> Date: Tue, 13 Apr 2010 13:19:15 +0100
> 
> 
> 
> 
> 
> 
>   
>   
> 
> 
> On Mon, 2010-04-12 at 12:25 -0400, Alice Wei wrote:
> 
> 
> 
> 
> 
> 
> > Date: Mon, 12 Apr 2010 11:09:42 -0500
> > From: k...@daleco.biz
> > To: aj...@alumni.iu.edu
> > CC: a.bovane...@gmail.com; php-general@lists.php.net
> > Subject: Re: [PHP] Mail Function Problem
> > 
> > Alice Wei wrote:
> > >> Hi!
> > >> You have the following php.ini params:SMTP = smtp.live.com
> > >> 
> > >> smtp_port = 587
> > >> live.com not support relay and it requires authentication.
> > > 
> > > Is there an email account that I could try? I thought 
> >  > most email accounts requires authentication anyway.
> > 
> > Well, "therein lies the rub," as the Bard said (maybe).
> > PHP's mail() was built on a general assumption that
> > there would be a local SMTP server.  It supports remote
> > SMTP, but I'm not aware of any ability to do SMTP auth,
> > even in the PEAR packages.
> > 
> > You might just wanna read up on mail in general.  The
> > php.net/mail page lists several relevant RFC's, and
> > has links to most of the PEAR mail classes, etc.
> > 
> > You should definitely read up on live.com's email
> > configuration.  If they use SMTP auth, I'm not sure
> > you can do this (per above).  If it uses, say, "POP
> > before SMTP" for authorization, you might be able to
> > hack something together with the PHP IMAP functions, or
> > even sockets, but you're getting into a big lotta work
> > for what seems a small thing.
> > 
> 
> This is what I am talking about. 
> Two years ago when I first set up my own server with Linux and not Windows, I 
> never had to deal with this. 
> Perhaps the authentication has since then got stricter, but it should not be 
> so much of a heck of a deal. 
> 
> I found this doc from ATT's website, 
> http://helpme.att.net/pdf/uverse/uverse_hsi_qsg_english.pdf, so obviously the 
> smtp server I provided earlier is probably not up to date. 
> 
> I think I will fiddle around with the php.ini file and see what else is 
> there. 
> Thanks.
> 
> Alice
> 
> _
> Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1
> 
> 
> 
> 
> Linux installations come with sendmail which allows you to send email 
> directly. Windows doesn't have this as part of the base setup, but I believe 
> if you can install a local mail server then this should fix the issue.
> 
> Something like http://www.hmailserver.com/? I use AT&T, why is it that I use 
> their SMTP server and my From address in PHP.ini file didn't work?
> 
> Thanks. 
> 
> Alice
> 
> 
> 
> 
> 
> 
> Thanks,sh
> 
> http://www.ashleysheridan.co.uk
> 
> 
> 
> 
> 
> 
> 
> 
> _
> Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1


That looks to do what you need. I don't really know of any specific
other examples as it's been a while since I've used Windows for anything
now. The link you gave did say it was free though, so you don't really
have anything to lose by installing it.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Mail Function Problem

2010-04-13 Thread Alice Wei


Subject: RE: [PHP] Mail Function Problem
From: a...@ashleysheridan.co.uk
To: aj...@alumni.iu.edu
CC: k...@daleco.biz; a.bovane...@gmail.com; php-general@lists.php.net
Date: Tue, 13 Apr 2010 13:19:15 +0100






  
  


On Mon, 2010-04-12 at 12:25 -0400, Alice Wei wrote:






> Date: Mon, 12 Apr 2010 11:09:42 -0500
> From: k...@daleco.biz
> To: aj...@alumni.iu.edu
> CC: a.bovane...@gmail.com; php-general@lists.php.net
> Subject: Re: [PHP] Mail Function Problem
> 
> Alice Wei wrote:
> >> Hi!
> >> You have the following php.ini params:SMTP = smtp.live.com
> >> 
> >> smtp_port = 587
> >> live.com not support relay and it requires authentication.
> > 
> > Is there an email account that I could try? I thought 
>  > most email accounts requires authentication anyway.
> 
> Well, "therein lies the rub," as the Bard said (maybe).
> PHP's mail() was built on a general assumption that
> there would be a local SMTP server.  It supports remote
> SMTP, but I'm not aware of any ability to do SMTP auth,
> even in the PEAR packages.
> 
> You might just wanna read up on mail in general.  The
> php.net/mail page lists several relevant RFC's, and
> has links to most of the PEAR mail classes, etc.
> 
> You should definitely read up on live.com's email
> configuration.  If they use SMTP auth, I'm not sure
> you can do this (per above).  If it uses, say, "POP
> before SMTP" for authorization, you might be able to
> hack something together with the PHP IMAP functions, or
> even sockets, but you're getting into a big lotta work
> for what seems a small thing.
> 

This is what I am talking about. 
Two years ago when I first set up my own server with Linux and not Windows, I 
never had to deal with this. 
Perhaps the authentication has since then got stricter, but it should not be so 
much of a heck of a deal. 

I found this doc from ATT's website, 
http://helpme.att.net/pdf/uverse/uverse_hsi_qsg_english.pdf, so obviously the 
smtp server I provided earlier is probably not up to date. 

I think I will fiddle around with the php.ini file and see what else is there. 
Thanks.

Alice
  
_
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1




Linux installations come with sendmail which allows you to send email directly. 
Windows doesn't have this as part of the base setup, but I believe if you can 
install a local mail server then this should fix the issue.

Something like http://www.hmailserver.com/? I use AT&T, why is it that I use 
their SMTP server and my From address in PHP.ini file didn't work?

Thanks. 

Alice






Thanks,sh

http://www.ashleysheridan.co.uk







  
_
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1

RE: [PHP] Mail Function Problem

2010-04-13 Thread Ashley Sheridan
On Mon, 2010-04-12 at 12:25 -0400, Alice Wei wrote:

> 
> 
> 
> 
> 
> > Date: Mon, 12 Apr 2010 11:09:42 -0500
> > From: k...@daleco.biz
> > To: aj...@alumni.iu.edu
> > CC: a.bovane...@gmail.com; php-general@lists.php.net
> > Subject: Re: [PHP] Mail Function Problem
> > 
> > Alice Wei wrote:
> > >> Hi!
> > >> You have the following php.ini params:SMTP = smtp.live.com
> > >> 
> > >> smtp_port = 587
> > >> live.com not support relay and it requires authentication.
> > > 
> > > Is there an email account that I could try? I thought 
> >  > most email accounts requires authentication anyway.
> > 
> > Well, "therein lies the rub," as the Bard said (maybe).
> > PHP's mail() was built on a general assumption that
> > there would be a local SMTP server.  It supports remote
> > SMTP, but I'm not aware of any ability to do SMTP auth,
> > even in the PEAR packages.
> > 
> > You might just wanna read up on mail in general.  The
> > php.net/mail page lists several relevant RFC's, and
> > has links to most of the PEAR mail classes, etc.
> > 
> > You should definitely read up on live.com's email
> > configuration.  If they use SMTP auth, I'm not sure
> > you can do this (per above).  If it uses, say, "POP
> > before SMTP" for authorization, you might be able to
> > hack something together with the PHP IMAP functions, or
> > even sockets, but you're getting into a big lotta work
> > for what seems a small thing.
> > 
> 
> This is what I am talking about. 
> Two years ago when I first set up my own server with Linux and not Windows, I 
> never had to deal with this. 
> Perhaps the authentication has since then got stricter, but it should not be 
> so much of a heck of a deal. 
> 
> I found this doc from ATT's website, 
> http://helpme.att.net/pdf/uverse/uverse_hsi_qsg_english.pdf, so obviously the 
> smtp server I provided earlier is probably not up to date. 
> 
> I think I will fiddle around with the php.ini file and see what else is 
> there. 
> Thanks.
> 
> Alice
> 
> _
> Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1


Linux installations come with sendmail which allows you to send email
directly. Windows doesn't have this as part of the base setup, but I
believe if you can install a local mail server then this should fix the
issue.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Re: Solution

2010-04-13 Thread Nathan Rixham
Gary wrote:
> For those that were looking to see a solution

[snip]

If anybody really wants to know how to handle this, (it's not officially
supported by PHP, but is in MySQL 5.1+, and I'm not condoning it) here's
how you do it:




Probably worth somebody investigating this further and seeing how it
works with mysqli etc (unsure if mysqli users mysql_connect or
mysql_real_connect at the C API level.)

Regards,

Nathan

http://dev.mysql.com/doc/refman/5.1/en/c-api-multiple-queries.html


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