OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 19 Dec 2005 02:32:59 -0000 Issue 3858

php-general-digest-helplists.php.net
Date: Sun Dec 18 2005 - 20:32:59 CST


php-general Digest 19 Dec 2005 02:32:59 -0000 Issue 3858

Topics (messages 227600 through 227640):

Re: Someone please help me with this PHP script.
        227600 by: Zareef Ahmed
        227601 by: Erik Johnson
        227602 by: Erik Johnson
        227603 by: £ukasz Hejnak
        227605 by: Zareef Ahmed
        227606 by: Oli Howson
        227607 by: Erik Johnson
        227608 by: Erik Johnson
        227612 by: Zareef Ahmed
        227613 by: Erik Johnson
        227614 by: Zareef Ahmed
        227615 by: Erik Johnson
        227616 by: £ukasz Hejnak
        227617 by: Erik Johnson
        227619 by: M. Sokolewicz

Re: insert to DB
        227604 by: Zareef Ahmed
        227609 by: David Hall
        227610 by: David Hall

Re: Need help with modifying values
        227611 by: David Hall

Looking for a photo gallery
        227618 by: Brian Dunning

Load from db into <select>-list
        227620 by: Gustav Wiberg
        227621 by: Curt Zirzow
        227624 by: Gustav Wiberg
        227626 by: David Hall
        227627 by: joshua may
        227629 by: Brian V Bonini
        227630 by: Curt Zirzow

spaces in directory names
        227622 by: matt VanDeWalle

asked too soon, nevermind
        227623 by: matt VanDeWalle

Re: PHP/MySQL noob rides again.. into trouble
        227625 by: Paul Jinks

Re: Function Overloading
        227628 by: joshua may
        227634 by: David Tulloh

Re: Callbacks in XML Parser
        227631 by: Norbert Wenzel
        227636 by: Amol Hatwar

duplicate filenames but different .extention
        227632 by: matt VanDeWalle
        227633 by: Curt Zirzow
        227635 by: Philip Hallstrom

PHP programmers from hyderabad
        227637 by: Vikram Kumar
        227638 by: Curt Zirzow
        227639 by: Michael Hulse

Re: PHP 4.4.1 "array_set_current" bug?
        227640 by: Curt Zirzow

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Hi Johnson,

what is not working in this code?
what is the problem? It will always execute the first part of if condition,
i.e.
It will print

<html><head><title>Page One</title></head><body>It works!!<br><a
href="http://lom.game-host.org/uploads/erik/index.php?page=two">Nice...</a><
/body></html>

What you are expecting from this script?

One recommendation, it is better to use isset function to check if variable
has been set or not.

Zareef Ahmed

----- Original Message -----
From: "Erik Johnson" <budduhgmail.com>
To: <php-generallists.php.net>
Sent: Saturday, December 17, 2005 11:05 PM
Subject: [PHP] Someone please help me with this PHP script.

I do not know why this isn't working, but it would be very helpful if
someone looked over it.

<?
$defaultpage = "http://lom.game-host.org/uploads/erik/";

If($page == NULL) {
    $page = "one";
}

if($page == "one") {
    Echo "<html><head><title>Page One</title></head><body>It works!!<br><a
href=\"" . $defaultpage . "index.php?page=two\">Nice...</a></body></html>";
}

elseif($page == "two") {
    Echo "<html><head><title>Page Two</title></head><body>This is page " .
$page . " -- <a href=\"" . $defaultpage . "index.php
?page=\">;D</a></body></html>";
}

elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
    Echo "<html><head><title>Undefined!</title></head><body>page isn't
defined correctly!</body></html>";
}

if($page == "") {
    Echo "<br><br><br><br><br><br><br><br><a href=" . $defaultpage . ">Main
Page..</a>";
}
?>

Thank you,

Erik Johnson

====================================================
PHP Expert Consultancy in Development http://www.indiaphp.com
Yahoo! : consultant_php MSN : consultancyindiaphp.com

attached mail follows:


Well. Here's an example of the page --
http://lom.game-host.org/uploads/erik/

It is just loading the second page, no matter what. I haven't added the
isset thing yet, but I'll try it. BTW: I'm only 14, so I have yet to use an
older version, and upgrade to a newer PHP. ;-)

Thanks,

Erik Johnson

On 12/18/05, Zareef Ahmed <consultancyindiaphp.com> wrote:
>
> Hi Johnson,
>
> what is not working in this code?
> what is the problem? It will always execute the first part of if
> condition,
> i.e.
> It will print
>
> <html><head><title>Page One</title></head><body>It works!!<br><a
> href="http://lom.game-host.org/uploads/erik/index.php?page=two"
> >Nice...</a><
> /body></html>
>
> What you are expecting from this script?
>
>
> One recommendation, it is better to use isset function to check if
> variable
> has been set or not.
>
> Zareef Ahmed
>
> ----- Original Message -----
> From: "Erik Johnson" <budduhgmail.com>
> To: <php-generallists.php.net>
> Sent: Saturday, December 17, 2005 11:05 PM
> Subject: [PHP] Someone please help me with this PHP script.
>
>
> I do not know why this isn't working, but it would be very helpful if
> someone looked over it.
>
> <?
> $defaultpage = "http://lom.game-host.org/uploads/erik/";
>
> If($page == NULL) {
> $page = "one";
> }
>
> if($page == "one") {
> Echo "<html><head><title>Page One</title></head><body>It works!!<br><a
> href=\"" . $defaultpage . "index.php
> ?page=two\">Nice...</a></body></html>";
> }
>
> elseif($page == "two") {
> Echo "<html><head><title>Page Two</title></head><body>This is page " .
> $page . " -- <a href=\"" . $defaultpage . "index.php
> ?page=\">;D</a></body></html>";
> }
>
> elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
> Echo "<html><head><title>Undefined!</title></head><body>page isn't
> defined correctly!</body></html>";
> }
>
> if($page == "") {
> Echo "<br><br><br><br><br><br><br><br><a href=" . $defaultpage . ">Main
> Page..</a>";
> }
> ?>
>
> Thank you,
>
> Erik Johnson
>
>
>
> ====================================================
> PHP Expert Consultancy in Development http://www.indiaphp.com
> Yahoo! : consultant_php MSN : consultancyindiaphp.com
>
>
>

attached mail follows:


I was wondering.. how exactly does the isset function work? I saw that
Robert Cummings wrote:

$page = isset( $_GET['page'] ) ? $_GET['page'] : null;

What exactly does that mean?

attached mail follows:


Zareef Ahmed napisa³(a):
> Hi,
Hi
> what is not working in this code?
That's how I see it
<?
$defaultpage = "http://lom.game-host.org/uploads/erik/";
// yes the isset is ok here
If(!isset($page)) {
     $page = "one";
}

if($page == "one") {
// as far as I know echo is all low case written but maybe it's not a
must in all instalations
     echo "<html><head><title>Page One</title></head><body>It
works!!<br><a href=\"" . $defaultpage .
"index.php?page=two\">Nice...</a></body></html>";
}

// else space_here if, not elseif !
else if($page == "two") {
     echo "<html><head><title>Page Two</title></head><body>This is page
".$page." -- <a
href=\"".$defaultpage."index.php?page=\">;D</a></body></html>";
}

// && instead of || (and instead of or) here to have the opposite!
else if( ($page != "one") && ($page != "two") && ($page != NULL) ) {
     echo "<html><head><title>Undefined!</title></head><body>page isn't
defined correctly!</body></html>";
}

if($page == "") {
     Echo "<br><br><br><br><br><br><br><br><a href=".$defaultpage.">Main
Page..</a>";
}
?>
> Thank you,
You're welcome :)

--
Best wishes
£ukasz 'Szift' Hejnak

attached mail follows:


----- Original Message -----
From: "Erik Johnson" <budduhgmail.com>
To: <php-generallists.php.net>
Sent: Sunday, December 18, 2005 10:41 AM
Subject: Re: [PHP] Someone please help me with this PHP script.

I was wondering.. how exactly does the isset function work? I saw that
Robert Cummings wrote:

$page = isset( $_GET['page'] ) ? $_GET['page'] : null;

What exactly does that mean?

isset function checks if a given variable is set or not, in above line of
code you are seeing its use with operator (?).

What it will do:
It will check if there is any variable with named $_GET['page'], it is true
then it will assign the value of $_GET['page'] to $page variable, otherwise
it will be set to null value.

You are 14?? Welcome to the wonderfull world of PHP programming.

Zareef Ahmed

====================================================
PHP Expert Consultancy in Development http://www.indiaphp.com
Yahoo! : consultant_php MSN : consultancyindiaphp.com

attached mail follows:


The ? And : are a shortcut for ifelse, that could also be written

If (isset($_GET['page'])
{
 $page = $_GET['page'];
}
else
{
 $page = null;
}

The shortcut is a lot quicker to write (if you understand it) but not as
readable.

isset just returns true if a variable has been set, false if not :)

hth

-----Original Message-----
From: Erik Johnson [mailto:budduhgmail.com]
Sent: 18 December 2005 15:42
To: php-generallists.php.net
Subject: Re: [PHP] Someone please help me with this PHP script.

I was wondering.. how exactly does the isset function work? I saw that
Robert Cummings wrote:

$page = isset( $_GET['page'] ) ? $_GET['page'] : null;

What exactly does that mean?

attached mail follows:


Thank you very much. My dad is in college, but I have been teaching myself
HTML, Java, VB6, and PHP. I've been learning to do graphical artwork with
Adobe Illustrator, and Photoshop. I actually started programming before my
dad was in school, and I got him started I guess! Anyway; I've learnt a
lot, and I hope to learn more, as I'm trying to make an online MMORPG /
ORPG.

Back on topic: I looked IsSet() on PHP.net, but it didn't give that fluent
of an explanation. Thanks! I'll be sure to try it out. If someone tries
my php script, and wants to make any changes, please just upload it to
ftp://lom.game-host.org/ .

Thanks again,

Erik Johnson

attached mail follows:


I still can't seem to get it to work. If you want to see my phpinfo(), then
go to http://lom.game-host.org/uploads/erik/info.php .

I'll keep trying, and hope for the best! It may be my php.ini file, but I
have no clue.

attached mail follows:


----- Original Message -----
From: "M. Sokolewicz" <tularisphp.net>
To: <budduhgmail.com>
Cc: "PHP LIST" <php-generallists.php.net>
Sent: Sunday, December 18, 2005 4:34 AM
Subject: Re: [PHP] Someone please help me with this PHP script.

> Aside from the 20 suggestions you've already got, let me add this one:
> elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
>
> Echo "<html><head><title>Undefined!</title></head><body>page isn't
> defined correctly!</body></html>";
> }
>
> is useless code. Why?
> $page = null; never happens (you made sure of that further up the page).
> $page = "one"; never happens (you already pulled that one out earlier).
> $page = "two"; never happens (you already pulled that one out earlier).
>

Johnson, make a note of it.

you can also read about "switch" statement.

Zareef Ahmed

> So... if *any* of those returns true you show an error... may I suggest
> just changing it to an else instead? a lot more logical(!).
> Besides that, were you to move this to its own if() you'd notice it
> would always display because if the page is "one" it *can not* be "two"
> or null, and will thus be displayed. Which means that you'd have an
> error which would always display...
>
> oh well, ignore my rant and first make sure to follow the suggestions
> provided by others
>
> - tul
> Wolf wrote:
> > What is it doing, or not doing?
> >
> > Try changing the <? to <?php and see if that works.
> >
> > Robert
> >
> > Erik Johnson wrote:
> >
> >>I do not know why this isn't working, but it would be very helpful if
> >>someone looked over it.
> >>
> >><?
> >>$defaultpage = "http://lom.game-host.org/uploads/erik/";
> >>
> >>If($page == NULL) {
> >> $page = "one";
> >>}
> >>
> >>if($page == "one") {
> >> Echo "<html><head><title>Page One</title></head><body>It
works!!<br><a
> >>href=\"" . $defaultpage .
"index.php?page=two\">Nice...</a></body></html>";
> >>}
> >>
> >>elseif($page == "two") {
> >> Echo "<html><head><title>Page Two</title></head><body>This is page "
.
> >>$page . " -- <a href=\"" . $defaultpage . "index.php
> >>?page=\">;D</a></body></html>";
> >>}
> >>
> >>elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
> >> Echo "<html><head><title>Undefined!</title></head><body>page isn't
> >>defined correctly!</body></html>";
> >>}
> >>
> >>if($page == "") {
> >> Echo "<br><br><br><br><br><br><br><br><a href=" . $defaultpage .
">Main
> >>Page..</a>";
> >>}
> >>?>
> >>
> >>Thank you,
> >>
> >>Erik Johnson
> >>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

====================================================
PHP Expert Consultancy in Development http://www.indiaphp.com
Yahoo! : consultant_php MSN : consultancyindiaphp.com

>

attached mail follows:


Okay.. I was just wondering; What's the difference between = and ==? Would
it matter if I changed them? It seems as though if I put = instead of the
=='s, it comes up ONLY page two no matter what $page equals, and if it's ='s
instead of =='s, then it comes up with only page one no matter what $page
equals.

On 12/18/05, Zareef Ahmed <consultancyindiaphp.com> wrote:
>
>
> ----- Original Message -----
> From: "M. Sokolewicz" <tularisphp.net>
> To: <budduhgmail.com>
> Cc: "PHP LIST" <php-generallists.php.net>
> Sent: Sunday, December 18, 2005 4:34 AM
> Subject: Re: [PHP] Someone please help me with this PHP script.
>
>
> > Aside from the 20 suggestions you've already got, let me add this one:
> > elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
> >
> > Echo "<html><head><title>Undefined!</title></head><body>page isn't
> > defined correctly!</body></html>";
> > }
> >
> > is useless code. Why?
> > $page = null; never happens (you made sure of that further up the page).
> > $page = "one"; never happens (you already pulled that one out earlier).
> > $page = "two"; never happens (you already pulled that one out earlier).
> >
>
> Johnson, make a note of it.
>
> you can also read about "switch" statement.
>
> Zareef Ahmed
>
> > So... if *any* of those returns true you show an error... may I suggest
> > just changing it to an else instead? a lot more logical(!).
> > Besides that, were you to move this to its own if() you'd notice it
> > would always display because if the page is "one" it *can not* be "two"
> > or null, and will thus be displayed. Which means that you'd have an
> > error which would always display...
> >
> > oh well, ignore my rant and first make sure to follow the suggestions
> > provided by others
> >
> > - tul
> > Wolf wrote:
> > > What is it doing, or not doing?
> > >
> > > Try changing the <? to <?php and see if that works.
> > >
> > > Robert
> > >
> > > Erik Johnson wrote:
> > >
> > >>I do not know why this isn't working, but it would be very helpful if
> > >>someone looked over it.
> > >>
> > >><?
> > >>$defaultpage = "http://lom.game-host.org/uploads/erik/";
> > >>
> > >>If($page == NULL) {
> > >> $page = "one";
> > >>}
> > >>
> > >>if($page == "one") {
> > >> Echo "<html><head><title>Page One</title></head><body>It
> works!!<br><a
> > >>href=\"" . $defaultpage .
> "index.php?page=two\">Nice...</a></body></html>";
> > >>}
> > >>
> > >>elseif($page == "two") {
> > >> Echo "<html><head><title>Page Two</title></head><body>This is page
> "
> .
> > >>$page . " -- <a href=\"" . $defaultpage . "index.php
> > >>?page=\">;D</a></body></html>";
> > >>}
> > >>
> > >>elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) {
> > >> Echo "<html><head><title>Undefined!</title></head><body>page isn't
> > >>defined correctly!</body></html>";
> > >>}
> > >>
> > >>if($page == "") {
> > >> Echo "<br><br><br><br><br><br><br><br><a href=" . $defaultpage .
> ">Main
> > >>Page..</a>";
> > >>}
> > >>?>
> > >>
> > >>Thank you,
> > >>
> > >>Erik Johnson
> > >>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> ====================================================
> PHP Expert Consultancy in Development http://www.indiaphp.com
> Yahoo! : consultant_php MSN : consultancyindiaphp.com
>
>
> >
>
>

attached mail follows:


Hi Johnson,

       I am glad to know about you. In my view, PHP is one of easiest
language of world. Only one problem for beginners is the numbers of
functions in it , PHP has more than 4500 functions, ( infact, it is the
strength of PHP), so they face problems when every other person tell them
about a new function to do the same thing, but it is the part of learning.
You just need to read something more about PHP on sites like php.net or
w3schools.

One suggestion, first try to find out the solution of your problems, by
yourself through searching on the internet and old archive of discussion
lists, because some time you may get very bad (!) response from the group
members if you are asking very easy or normal questions.

Zareef Ahmed

----- Original Message -----
From: "Erik Johnson" <budduhgmail.com>
To: <php-generallists.php.net>
Sent: Sunday, December 18, 2005 10:59 AM
Subject: Re: [PHP] Someone please help me with this PHP script.

Thank you very much. My dad is in college, but I have been teaching myself
HTML, Java, VB6, and PHP. I've been learning to do graphical artwork with
Adobe Illustrator, and Photoshop. I actually started programming before my
dad was in school, and I got him started I guess! Anyway; I've learnt a
lot, and I hope to learn more, as I'm trying to make an online MMORPG /
ORPG.

Back on topic: I looked IsSet() on PHP.net, but it didn't give that fluent
of an explanation. Thanks! I'll be sure to try it out. If someone tries
my php script, and wants to make any changes, please just upload it to
ftp://lom.game-host.org/ .

Thanks again,

Erik Johnson

====================================================
PHP Expert Consultancy in Development http://www.indiaphp.com
Yahoo! : consultant_php MSN : consultancyindiaphp.com

attached mail follows:


 I understand that some people aren't nice to newer people that try their
hardest to figure out a problem. Older, more experienced people see this
and they think that it's an easy fix, and that they just aren't trying, but
in essence.. they are trying just as hard as someone much more experienced.
Since they are new, they can have just as much trouble as another person, so
they deserve just as much respect in my eyes.

Anyway, I have been trying to figure out this problem, and it's just stumped
me. It doesn't look as if anything's wrong, and other people've tested it
and it works fine. I think I just need someone to make sure my PHP.ini file
is normal.. hence the reason I made the phpinfo() file to give much of the
information that may help. If anyone needs it (e-mail a yes/no), and I'll
send it as an attachment.

Thanks,

Erik Johnson

(I think I just sent it to Zareef on accident. =x)

On 12/18/05, Zareef Ahmed <consultancyindiaphp.com> wrote:
>
> Hi Johnson,
>
> I am glad to know about you. In my view, PHP is one of easiest
> language of world. Only one problem for beginners is the numbers of
> functions in it , PHP has more than 4500 functions, ( infact, it is the
> strength of PHP), so they face problems when every other person tell them
> about a new function to do the same thing, but it is the part
> of learning.
> You just need to read something more about PHP on sites like php.net or
> w3schools.
>
> One suggestion, first try to find out the solution of your problems, by
> yourself through searching on the internet and old archive
> of discussion
> lists, because some time you may get very bad (!) response from the group
> members if you are asking very easy or normal questions.
>
> Zareef Ahmed
>
>
> ----- Original Message -----
> From: "Erik Johnson" < budduhgmail.com>
> To: <php-generallists.php.net>
> Sent: Sunday, December 18, 2005 10:59 AM
> Subject: Re: [PHP] Someone please help me with this PHP script.
>
>
> Thank you very much. My dad is in college, but I have been teaching
> myself
> HTML, Java, VB6, and PHP. I've been learning to do graphical artwork with
> Adobe Illustrator, and Photoshop. I actually started programming before
> my
> dad was in school, and I got him started I guess! Anyway; I've learnt a
> lot, and I hope to learn more, as I'm trying to make an online MMORPG /
> ORPG.
>
> Back on topic: I looked IsSet() on PHP.net, but it didn't give that
> fluent
> of an explanation. Thanks! I'll be sure to try it out. If someone tries
> my php script, and wants to make any changes, please just upload it to
> ftp://lom.game-host.org/ .
>
> Thanks again,
>
> Erik Johnson
>
>
> ====================================================
> PHP Expert Consultancy in Development http://www.indiaphp.com
> Yahoo! : consultant_php MSN : consultancyindiaphp.com
>
>
>

attached mail follows:


Erik Johnson napisa³(a):
> Okay.. I was just wondering; What's the difference between = and ==? Would
> it matter if I changed them? It seems as though if I put = instead of the
> =='s, it comes up ONLY page two no matter what $page equals, and if it's ='s
> instead of =='s, then it comes up with only page one no matter what $page
> equals.
It's a *BIG* difference!
Because single '=' means that whatever stands at the right side of the
'=' should be assigned to whatever stands at the left side,
ie.
$a=5
doesn't compare if a is equal 5, only assignes the variable 'a' it's
value which will be 5 after this code
so if You write
if ($a=5) {...}
it will always be executed (therefore else isn't executed), as
assignment always returns true :]
so when using 'if' You always need to do
if ($a==5) {...}
unless of course Youd want to do an assingment and some code, but then
why not do
$a=5;
...
? :)

--
Best wishes
£ukasz 'Szift' Hejnak

attached mail follows:


Woohoo! I got it to work. Thanks everyone! This is exactly what I needed:
making multiple-page files in one file. It saves me the hassle of trying to
know what file is what, and where. Instead.. one big file!

On 12/18/05, £ukasz Hejnak <grupyszift.org> wrote:
>
> Erik Johnson napisa³(a):
> > Okay.. I was just wondering; What's the difference between = and ==?
> Would
> > it matter if I changed them? It seems as though if I put = instead of
> the
> > =='s, it comes up ONLY page two no matter what $page equals, and if it's
> ='s
> > instead of =='s, then it comes up with only page one no matter what
> $page
> > equals.
> It's a *BIG* difference!
> Because single '=' means that whatever stands at the right side of the
> '=' should be assigned to whatever stands at the left side,
> ie.
> $a=5
> doesn't compare if a is equal 5, only assignes the variable 'a' it's
> value which will be 5 after this code
> so if You write
> if ($a=5) {...}
> it will always be executed (therefore else isn't executed), as
> assignment always returns true :]
> so when using 'if' You always need to do
> if ($a==5) {...}
> unless of course Youd want to do an assingment and some code, but then
> why not do
> $a=5;
> ...
> ? :)
>
> --
> Best wishes
> £ukasz 'Szift' Hejnak
>

attached mail follows:


Actually, I disagree with the explenation here. The reasoning behind it
is correct, but the explenation contains a number of incorrect statements.

The = (a single '=') is the so-called assignment operator. This operator
assigns the right-hand value to the left-hand variable. So, when you
write $a = 5; you'll assign the right-hand value (5) to the left-hand
variable ($a).

The == (a double '=') is the comparation operator. This operator
compares the right-hand value to the left-hand value, and returns the
boolean true if it is the same, or false if it is not.

The === (a triple '=') is also a comparation operator, however this one
is more strict. This means (in most cases) that where '==' doesn't care
about if the left-hand value and right-hand value are of different types
(eg. integer vs. string), this one does. So, you could say that when ===
returns true, == would also return true. However, when === returns
false, == doesn't necesserily need to return false aswell.

Now, the assignment operator, as each operator, has a return value. And
the return value of the assignment operator is what probably confused
you. Basically, what happens is that the assignment operator "returns"
the value it just assigned. So, if you do $a = 5; the return value will
be 5. This is why you can do $a = $b = 5. This will be interpreted as
being $a = ($b = 5); which means: $b = 5 returns 5, which is then
assigned to $a, which makes $a have the value 5.
In most cases, the return value of the thing is ignored. eg. if you do
$a = 5; 5 will be assigned to $a, and the result (5) will be "returned".
But since we don't do anything with the return value, it's silently ignored.

So, how do if() and such constructs work with this, you wonder?
if(), and most other language constructs (while(), elseif(), etc) take
an expression as its argument, compare it to true (lazy comparing), and
will continue if it returns true, or stop/skip if it's false.
if() could also be written as if(expression == true), where expression
is anything with a return value (including operators!).
So, if you write if(2 == 2), the return value will be true, which equals
true, and thus the if() will be executed. However, if you have if(3 ==
2) it'll return false (2 is NOT the same as 3), which is obviously not
true, and thus the if() will be skipped.

When we said before, assignment operators return the value they just
assigned, you'll see that: if($a = true) will return true, which is
equal to true, and which will cause the if() to be executed. On the
other side, doing if($a = false) will return false, which is not equal
to true, and which will make PHP skip the if().
Because php uses "lazy" comparing in the if(), it will not check the
type of the variable/value! This means that for the if, this is true:
if(2 == '2'). And also if($a = 2) (all values are true, except NULL,
false, an empty string, or zero. There is a full table showing these in
the manual). So, doing if($a = 0) will return false, and will skip the
if(). Of course, doing if('2' === 2) will also return false (due to the
use of ===) and will skip the if aswell.

Hope that clears up any misunderstandings that might have been left.
Also, I urgently recommend you to have a look at the wonderful PHP
manual (one of THE best programming/scripting language manuals, if I may
be so bold). A few pages which will surely help you (and also explain
the above):
http://www.php.net/manual/en/language.operators.assignment.php
http://www.php.net/manual/en/language.operators.comparison.php
http://www.php.net/manual/en/types.comparisons.php
http://www.php.net/manual/en/language.control-structures.php
etc.

Please read the manual first, it will answer a lot of your questions.

- tul

£ukasz Hejnak wrote:
> Erik Johnson napisa³(a):
>
>> Okay.. I was just wondering; What's the difference between = and ==?
>> Would
>> it matter if I changed them? It seems as though if I put = instead of
>> the
>> =='s, it comes up ONLY page two no matter what $page equals, and if
>> it's ='s
>> instead of =='s, then it comes up with only page one no matter what $page
>> equals.
>
> It's a *BIG* difference!
> Because single '=' means that whatever stands at the right side of the
> '=' should be assigned to whatever stands at the left side,
> ie.
> $a=5
> doesn't compare if a is equal 5, only assignes the variable 'a' it's
> value which will be 5 after this code
> so if You write
> if ($a=5) {...}
> it will always be executed (therefore else isn't executed), as
> assignment always returns true :]
> so when using 'if' You always need to do
> if ($a==5) {...}
> unless of course Youd want to do an assingment and some code, but then
> why not do
> $a=5;
> ...
> ? :)
>
> --
> Best wishes
> £ukasz 'Szift' Hejnak

attached mail follows:


Hi,

       I think you should read a beginner tutorial about SQL. there are just
four things Insert, Delete, Update and select, that need to be known for
working with database in normal conditions, after that you can move to
create, drop, alter or much more like joins etc.

http://www.lmpx.com/mysql_ref.php

Zareef Ahmed

----- Original Message -----
From: "Anasta" <neretliswestnet.com.au>
To: <php-generallists.php.net>
Sent: Sunday, December 18, 2005 7:41 AM
Subject: [PHP] insert to DB

> It just wont insert new data into DB--any ideas as i have gone over and
> over.
>
>
>
> <?
> mysql_connect("localhost","anasta","silteren");
>
> mysql_select_db("mytipperv1");
>
> if(!isset($cmd))
> {
> $result = mysql_query("select * from leaderboard order by ID");
>
> while($r=mysql_fetch_array($result))
>
> {
> //grab the title and the rating of the entry
> $id=$r["ID"];//take out the id
> $Name=$r["Name"];//take out the Name
> $Rating=$r["Rating"];//take out the Rating
>
>
> echo "$Name <a href='edit.php?cmd=edit&ID=$id'> Edit</a><br>";
>
>
> }
> }
> ?>
> <?
> if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
> {
> if (!isset($_POST["submit"]))
> {
> $id = $_GET["ID"];
> $sql = "SELECT * FROM leaderboard WHERE ID=$id";
> $result = mysql_query($sql);
> $myrow = mysql_fetch_array($result);
> ?>
>
> <form action="../craigs_DB/edit.php" method="post">
> <input type=hidden name="ID" value="<?php echo $myrow["ID"] ?>">
>
> Name: <INPUT TYPE="TEXT" NAME="Name" VALUE="<?php echo
$myrow["Name"]
> ?>" SIZE=15 maxlength="15"><br><br>
> Rating: <INPUT TYPE="TEXT" NAME="Rating" VALUE="<?php echo
> $myrow["Rating"] ?>" SIZE=3 maxlength="3"><br><br>
> <input type="hidden" name="cmd" value="edit">
> <input type="submit" name="submit" value="submit">
> </form>
>
> <? } ?>
> <?
> if ($_POST["$submit"])
> {
> $Name = $_POST["Name"];
> $Rating = $_POST["Rating"];
>
> $sql = "UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE
> ID=$id";
> //replace news with your table name above
> $result = mysql_query($sql);
> echo "Thank you! Information updated.";
> }
> }
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

====================================================
PHP Expert Consultancy in Development http://www.indiaphp.com
Yahoo! : consultant_php MSN : consultancyindiaphp.com

attached mail follows:


> <?
> if ($_POST["$submit"])
> {
> $Name = $_POST["Name"];
> $Rating = $_POST["Rating"];
>
> $sql = "UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE
> ID=$id";
> //replace news with your table name above
> $result = mysql_query($sql);
> echo "Thank you! Information updated.";
> }
> }
> ?>

You don't set id in this case. Of course, from some of your other
code, it looks like you're relying on register_globals to be on, so
maybe it is and that's not why.

David Hall

attached mail follows:


> <?
> if ($_POST["$submit"])
> {
> $Name = $_POST["Name"];
> $Rating = $_POST["Rating"];
>
> $sql = "UPDATE leaderboard SET Name='$Name', Rating='$Rating' WHERE
> ID=$id";
> //replace news with your table name above
> $result = mysql_query($sql);
> echo "Thank you! Information updated.";
> }
> }
> ?>

You don't set id in this case. Of course, from some of your other
code, it looks like you're relying on register_globals to be on, so
maybe it is and that's not why.

David Hall

attached mail follows:


> modify_values2.php
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
> <?php
> include("connect.php");
>
>
>
> $sql = "Select * from leaderboard ";
> $result = mysql_query($sql);
>
You'll want to do something like:
$id = mysql_real_escape_string($_GET['id']);
$sql = "Select * from leaderboard WHERE ID='$id'";

David Hall

attached mail follows:


Has anyone seen a photo gallery that will do the following:

- Allow several people to upload images to various subdirectories via
FTP, and then a cron script or something periodically scans the
directories and creates any needed thumbnails and creates new pages
for all new images;

- Is template based so I can easily globally add content and apply
changes to all thumbnail pages, all detail pages, etc.?

Thanks for any recommendations. I've seen so many online but can't
find any that do both of the above.

- Brian

attached mail follows:


Hi there!

Is it possible to load a <select>-list with databasinfo without reloading a
page???

/G
http://www.varupiraten.se/
 

attached mail follows:


On Sun, Dec 18, 2005 at 08:28:22PM +0100, Gustav Wiberg wrote:
> Hi there!
>
> Is it possible to load a <select>-list with databasinfo without reloading a
> page???

With AJAX, yeah.

Curt.
--
cat .signature: No such file or directory

attached mail follows:


----- Original Message -----
From: "Gustav Wiberg" <gustavvarupiraten.se>
To: "Curt Zirzow" <czirzowgmail.com>
Sent: Sunday, December 18, 2005 8:46 PM
Subject: Re: [PHP] Load from db into <select>-list

> Ajax? What is that?
>
> /G
>
> ----- Original Message -----
> From: "Curt Zirzow" <czirzowgmail.com>
> To: <php-generallists.php.net>
> Sent: Sunday, December 18, 2005 8:53 PM
> Subject: Re: [PHP] Load from db into <select>-list
>
>
>> On Sun, Dec 18, 2005 at 08:28:22PM +0100, Gustav Wiberg wrote:
>>> Hi there!
>>>
>>> Is it possible to load a <select>-list with databasinfo without
>>> reloading a
>>> page???
>>
>> With AJAX, yeah.
>>
>> Curt.
>> --
>> cat .signature: No such file or directory
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>

attached mail follows:


Gustav Wiberg wrote:
>
>
>
>> Ajax? What is that?

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

php is a server side language, so you must refresh the page to have php
do it directly, so using AJAX, you can talk to the server from the page.

D. Hall

attached mail follows:


Curt Zirzow wrote:
> On Sun, Dec 18, 2005 at 08:28:22PM +0100, Gustav Wiberg wrote:
>> Hi there!
>>
>> Is it possible to load a <select>-list with databasinfo without reloading a
>> page???
>
> With AJAX, yeah.
>
> Curt.

call it 'remote scripting', dammit! it rarely seems to get used as
'ajax' strictly.. unless you're using some kinda of framework, i
suppose, but far too often xml isn't returned!

(never mind me, it's just a pet hate of mine, aha)

attached mail follows:


On Sun, 2005-12-18 at 15:22, Gustav Wiberg wrote:

> > Ajax? What is that?

Asynchronous JavaScript and XML, or Ajax, is a web development technique
for creating interactive web applications using a combination of:

- XHTML (or HTML) and CSS for marking up and styling information
- The Document Object Model manipulated through JavaScript to
dynamically display and interact with the information presented
- The XMLHttpRequest object to exchange data asynchronously with the web
server. (XML is commonly used, although any format will work, including
preformatted HTML, plain text, JSON and even EBML). In some Ajax
frameworks and in some situations, an IFrame object is used instead of
the XMLHttpRequest object to exchange data with the web server.

--

s/:-[(/]/:-)/g

Brian GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
======================================================================
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

attached mail follows:


On Mon, Dec 19, 2005 at 08:24:15AM +1100, joshua may wrote:
> Curt Zirzow wrote:
> >On Sun, Dec 18, 2005 at 08:28:22PM +0100, Gustav Wiberg wrote:
> >>Hi there!
> >>
> >>Is it possible to load a <select>-list with databasinfo without reloading
> >>a page???
> >
> >With AJAX, yeah.
> >
> >Curt.
>
> call it 'remote scripting', dammit! it rarely seems to get used as
> 'ajax' strictly.. unless you're using some kinda of framework, i
> suppose, but far too often xml isn't returned!

I think of it more as in ajaX where X is the variable representing
any sort of structured data.

>
> (never mind me, it's just a pet hate of mine, aha)

I wouldn't call it much of a pet hate, but a pet (this isn't a new
thing and has been around since javascript was able to talk to an
object (aka a frameset) that can fetch data for you) thing of mine.

Curt.
--
cat .signature: No such file or directory

attached mail follows:


hello,
I have encountered this on several cds and well when i went to a friend's
ftp site in windows, using linux and php(i think its a linux mainly
question) but i have run accross files and directory names like this:
they appear like this in linux, path\ of\ the\ windows\ file.txt
i am trying to read a directory from a cd made in windows with a 3-word or
longer directory name like the one shown above, but how do i deal with a
oddly named directory like that in linux/php?
I know spaces don't work when changing directories so would i have to
escape the space or what?
matt
simple question again

attached mail follows:


I just figured out my own answer to the previous post so i guess just
ignore the question :p
i'll learn to try things first one of these days lol
matt

attached mail follows:


Richard Davey wrote:

>> <?
>> $connect = mysql_connect("", "", "")
>> or die("could not connect");
>> $db = mysql_select_db("")
>> or die("could not select db");
>> if (isset($HTTP_GET_VARS['projTitle']))
>> {
>> $SQLQuery = "SELECT * FROM project WHERE
>> projTitle = ".$HTTP_GET_VARS['projTitle']
>> or die("SQLQuery 1 failed");
>> }
>> else
>> {
>> $SQLQuery = "SELECT*FROM project ORDER BY projTitle"
>> or die("SQLQuery 2 failed");
>> }
>> $result = mysql_query($SQLQuery,$connect)
>> or die("couldn't set value of result");
>>

> There are various issues re: SQL injection and lack of filtering going
> on here, but perhaps not best to dwell on those -just yet-, as long as
> you are aware that your script is lacking in all forms of security?
> Then you can address that once you've got it working.
>

Hi Richard

Think I've got everything more or less working now and need to look at
security issues. Thanks for the tip about SQL injection - had no idea
what this was, but googling it proved very interesting - scary stuff!

Could you direct me towards any good resources on general security with
php/mysql?

Thanks again

Paul.

attached mail follows:


Labunski wrote:
> "PHP does not support function overloading."
> So, is there any other way of getting a number of parameters(variables)
> passed to a function?
>
> aka.
> function fruits($apple, $banana, $kiwi, $grape){
>
> #should (somehow) output 4
>
> }
>
> OK. if it was an array, than I could use count($array), but now I'm stuck!
>
> Thanks in advance!

func_num_args() will do the trick.

and then you use func_get_arg() or func_get_args() to use them.

http://au2.php.net/func_num_args

--josh

attached mail follows:


PHP doesn't natively support function redefining.

Functions with variable length arguments are a different ballgame in
PHP. Have a look at func_num_args[1] and the other functions in the
"Function handling" section of the manual.

1: http://php.net/func_num_args

Labunski wrote:
> "PHP does not support function overloading."
> So, is there any other way of getting a number of parameters(variables)
> passed to a function?
>
> aka.
> function fruits($apple, $banana, $kiwi, $grape){
>
> #should (somehow) output 4
>
> }
>
> OK. if it was an array, than I could use count($array), but now I'm stuck!
>
> Thanks in advance!
>

attached mail follows:


comex wrote:
>>xml_set_element_handler($this->xmlParser, "$this->startTag",
>>"$this->endTag");
>
> xml_set_element_handler($this->xmlParser, array(&$this, 'startTag'),
> array(&$this, 'endTag'));

i copied this from a posting about two weeks ago by Jochem Maas:

in this case there is an alterntive:

http://php.net/manual/en/function.xml-set-object.php

Norbert Wenzel wrote:

> Robert Cummings wrote:
>
>> On Sat, 2005-12-10 at 11:25, mail wrote:
>>
>>> xml_set_element_handler($parser, "xml_start_element",
"xml_stop_element"); //can't find function
>>
>>
>>
>>
>> use array notation for object method handlers:
>>
>> xml_set_element_handler
>> (
>> $parser,
>> array( $this, 'xml_start_element' ),
>> array( $this, 'xml_stop_element' )
>> );
>>
>> Cheers,
>> Rob.
>
>
>
> Thanks,
>
> Norbert

attached mail follows:


> >> xml_set_element_handler
> >> (
> >> $parser,
> >> array( $this, 'xml_start_element' ),
> >> array( $this, 'xml_stop_element' )
> >> );
> >>

Thanks for helping me out :).

Warm regards,

ah

attached mail follows:


hello again
I am trying to figure out how i can read the list of files in a directory
using the opendir() and readdir() functions. Normally this goes fine but
within the loop, what i am wanting to do is echo the filename if it is a
jpg file, but if its a .gif, just continue.
I have several files i wish to seperate based on the basename of the file.
i read the basename help file and know how to use it even to exclude the
.3letterextention. I am however wanting to skip if it happens to be a
.gif, is there some sort of way to i guess, do the basename function in
reverse, e.g if it comes across "xxxxxx.gif" it would skip it but not skip
over the xxx.jpg files?
that is my latest problem, it skips everything when i have a line like
this in my loop

if($file = basename('.gif',$file))
continue;
else go on with code

this not only skips over .gif files, but everything is ignored
any ideas?
matt

attached mail follows:


On Sun, Dec 18, 2005 at 05:12:33PM -0600, matt VanDeWalle wrote:
> hello again
> I am trying to figure out how i can read the list of files in a directory
> using the opendir() and readdir() functions. Normally this goes fine but
> within the loop, what i am wanting to do is echo the filename if it is a
> jpg file, but if its a .gif, just continue.

One option, is to use glob():

foreach(glob('/path/tofiles/*.jpg') as $image ) {
  echo $image;
}

Curt.
--
cat .signature: No such file or directory

attached mail follows:


> hello again
> I am trying to figure out how i can read the list of files in a directory
> using the opendir() and readdir() functions. Normally this goes fine but
> within the loop, what i am wanting to do is echo the filename if it is a jpg
> file, but if its a .gif, just continue.
> I have several files i wish to seperate based on the basename of the file.
> i read the basename help file and know how to use it even to exclude the
> .3letterextention. I am however wanting to skip if it happens to be a .gif,
> is there some sort of way to i guess, do the basename function in reverse,
> e.g if it comes across "xxxxxx.gif" it would skip it but not skip over the
> xxx.jpg files?
> that is my latest problem, it skips everything when i have a line like this
> in my loop
>
> if($file = basename('.gif',$file))
> continue;
> else go on with code
>

if ( ereg("\.gif$", $file) ) {
         continue;
}

would do it.. so would

if ( substr($file, -4) == ".gif" ) {
         continue;
}

Don't forget about ".GIF" though if that might be an issue for you...

attached mail follows:


hi!

We are looking for PHP programmers from hyderabd.

If you are an experienced PHP programmer, and have experience of developing
calendar or dairy , message board application, please send your CV to
infowebbdesignpunkt.se

All PHP programmers are welcome to apply!.

Best regards,
Vikram.

attached mail follows:


On Mon, Dec 19, 2005 at 02:58:00AM +0100, Vikram Kumar wrote:
> hi!
>
> We are looking for PHP programmers from hyderabd.
>
> If you are an experienced PHP programmer, and have experience of developing
> calendar or dairy , message board application, please send your CV to
> infowebbdesignpunkt.se
>
> All PHP programmers are welcome to apply!.

You can stop sending these messages to the list. As I said in
another thread.

  Consider if everyone posted their resume on the list.

So ok, this isn't a resume, but a request for people to apply for a
job..:
 
  What if everyone who needs someone to work for them sends a
  message here.
 
Bottom line, this news/mailinglist/forum is not a place to post
your resume or job listing.

Please stop.

I'm open to flames, if you so desire.

Curt.
--
cat .signature: No such file or directory

attached mail follows:


On Dec 18, 2005, at 6:19 PM, Curt Zirzow wrote:
> On Mon, Dec 19, 2005 at 02:58:00AM +0100, Vikram Kumar wrote:
>> We are looking for PHP programmers from hyderabd.
> You can stop sending these messages to the list.

I am with Curt on this one. I get enough spam as it is already.

WhTF is Hyderabd anyway?

<M>
--
¸.·´¯`·.¸¸><(((º>`·.¸¸.·´¯`·.¸¸><((((º>
·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸><((((º>
`·.¸¸><((((º>¸.·´¯`·.¸¸><((((º>

attached mail follows:


On Fri, Dec 16, 2005 at 09:09:08AM -0500, Eric Butera wrote:
> Hello all,
>
> I have an image gallery script I created and I seem to be having some
> difficulties with it. I am using this script on many different platforms
> and different PHP versions. I have tried it on 4.4.0 (linux) and
> 4.3.11(entrophy osx). The problem is with PHP version
> 4.4.1 from what I can tell. That is what I am emailing for, to verify. =)
>
> The problem is this function:
> function array_set_current(&$array, $key) {
>
> reset($array);
>
> while(current($array)) {
>
> if (key($array) == $key) {
> break;
> } // if
>
> next($array);
> } // while
>
> } // function
>
>
> On 4.4.0 and 4.3.11 I can pass an array and key and it will match the key
> and break perfectly. Recently one of our servers upgraded to 4.4.1. This
> script was working previously and now does not. I ended up echoing out the
> value of key(). On 4.4.1 the key is always 0. Next() does not goto the next
> key. On 4.4.0 and 4.3.11 the next() works fine.

well, this works perfectly fine on php 4.4.1:

<?php

$a = array('a' => 'a', 'b' => 'b', 'c' => 'c');

array_set_current($a, 'b');

var_dump(current($a));
// prints string(1) "b"

Curt.
--
cat .signature: No such file or directory