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 3 Aug 2005 04:55:19 -0000 Issue 3603

php-general-digest-helplists.php.net
Date: Tue Aug 02 2005 - 23:55:19 CDT


php-general Digest 3 Aug 2005 04:55:19 -0000 Issue 3603

Topics (messages 219844 through 219880):

Re: varibles defination
        219844 by: Rory Browne

Re: Sessions Issue
        219845 by: Rory Browne
        219849 by: Jason Motes

Re: Running a PHP script everyday
        219846 by: Rory Browne

Re: encrypting urls
        219847 by: Rory Browne
        219856 by: Rory Browne

Regular expression help
        219848 by: David Christensen
        219850 by: John Nichel

Sorting in PHP
        219851 by: Mathieu Dumoulin
        219853 by: Mathieu Dumoulin

Forming an SQL query
        219852 by: Jack Jackson
        219870 by: Jack Jackson

Error Suppression with ''
        219854 by: Justin Burger
        219858 by: Torgny Bjers
        219859 by: Rory Browne
        219860 by: Matt Darby
        219864 by: John Nichel
        219865 by: John Nichel
        219866 by: Justin Burger
        219868 by: Kristen G. Thorson
        219871 by: Richard Davey
        219875 by: Jochem Maas

how to mix two arrays into one and sort it by date/time?
        219855 by: afan.afan.net
        219862 by: afan.afan.net

Re: AJAX & PHP
        219857 by: Graham Anderson

Re: Java - toString() <-> php - ?
        219861 by: Adi Zebic

Re: array()
        219863 by: Rory Browne
        219876 by: Jochem Maas

Re: Regex help
        219867 by: Dotan Cohen

Re: editor in WEB PAGE
        219869 by: Graham Cossey
        219874 by: Graham Cossey

Re: cannot find the parse error
        219872 by: Jochem Maas

Re: parent::construct not reliable working on php5.1 b2/b3
        219873 by: Jochem Maas

help with a bucle
        219877 by: Jesús Alain Rodríguez Santos
        219878 by: sonu gill
        219879 by: sonu gill

Converting integer type to long
        219880 by: Wee Keat

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:


There are two ways of accomplishing what I think you're trying to acomplish.

These ways are known as the right way and the wrong way.

the right way results in an array like

$func = array(0 => 0, 1 => 1, 2 => 2 ...)

The wrong way results in a set of variables like you described

$func1 = 0
$func2 = 1
$func3 = 2
$func4 = 3
$func5 = 4

If you want to do it the wrong way, you can

for($i = 1; $i < 5 ++$i){
  $varname = "func" . $i;
  $$varname = $i;
}

Personally I reckon you should do it the right way as Jim outlines.

On 8/2/05, Jim Moseby <JMosebynrbindustries.com> wrote:
> > If I want to define and display a set of varibles, for example :
> > $func1 = 0
> > $func2 = 1
> > $func3 = 2
> > $func4 = 3
> > $func5 = 4
> >
> > How can we define and display the varibles by using for loop
> > function ?
>
> <?php
> for ($x=0;$x<10;$x++){
> $func[$x]=$x;
> }
> print_r($func);
> ?>
>
> This uses an array, so, in this case, your variables would be referenced as
> $func[0]..$func[9].
>
> JM
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


On 7/29/05, Tom Ray [Lists] <listsblazestudios.com> wrote:
> We built a box about 7 months or so ago using the SuSE 9.1 cd's,
> straight install from the CDs. While I've read that sessions are turned
> on by default, when we try to call on the sessions functions (like with
> phpOpenChat or start_session()) we get calls to undefined function
> errors. This is leading me to belive that sessions are disabled for some
> reason. I need to enable the sessions so I have a few questions
>
> 1) Can I do this without recompiling?

Don't know - Don't have SuSE

> 2) If I can't, how do I recompile this since I used the SuSE cds?

Head to www.php.net and hit the downloads section.

unArchive the source, and type ./configure --help to get a list of the
compilabel extensions. Once you're done, you can ./configure
--with-this --without-that --enable this-thing --disable-that-thing

The compile instructions(a file called INSTALL AFAIR) and the PHP
manual are among the best docs I've ever seen.

>
> It's SuSE 9.1 running Php 4.3.4 with APache 2.0.49
>
> any help would be great!
>
> Thanks!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


>>We built a box about 7 months or so ago using the SuSE 9.1 cd's,
>>straight install from the CDs. While I've read that sessions are turned
>>on by default, when we try to call on the sessions functions (like with
>>phpOpenChat or start_session()) we get calls to undefined function
>>errors. This is leading me to belive that sessions are disabled for some
>>reason. I need to enable the sessions so I have a few questions
>>
>>1) Can I do this without recompiling?
>
>
> Don't know - Don't have SuSE
>
>

In YaST, goto install/remove software and do a search on php.
Is php4-session installed??

I am running SuSE 9.1 and sessions work fine for me.

attached mail follows:


On 8/1/05, Jay Blanchard <jay.blanchardniicommunications.com> wrote:
> [snip]
> What is the "-q" for? I can't find any documentation on it. If I do
> a "php -h" or "man php", it is not listed. I am running php 5.0.3 on
> RHEL ES 4
> [/snip]
>
> It means 'quiet'...in other words do not send anything to standard out.

I'm open to correction but I think that normal output will still
appear. It's only headers like Content-type, or Location, etc that the
-q suppresses.

echo's printf's and ?> this <?php will still be outputted - I think

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

attached mail follows:


serialize/unserialize accompanied by some compression/decompression
should do the trick. Your output probably won't be any smaller with
compresson overhead, but it would be non-obvious. It is also extremely
easy to circumvent.

On 8/2/05, Sebastian <sebastianbroadbandgaming.net> wrote:
> i need to mask (hide) some vars in a url so they arent visible to the
> user. example, i want a url like this:
>
> page?id=3&something=12&more=12
>
> to turn into:
>
> page?id=3;LyFU;MLFxvy
>
> so from "LyFU" i can access $something and from "MLFxvy" $more
> any ideas how i can do this?
>
> doesn't have to be 100% secure, just a simple way hide it from the user.
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


On 8/2/05, Torgny Bjers <torgnyxorcode.com> wrote:
> Another idea would be to Base64 encode/decode the parameters.

I'm not sure why you sent this to me(and me only). It's not me, but
rather the OP who wants to "encrypt" the url.

>
> Rory Browne wrote:
>
> >serialize/unserialize accompanied by some compression/decompression
> >should do the trick. Your output probably won't be any smaller with
> >compresson overhead, but it would be non-obvious. It is also extremely
> >easy to circumvent.
> >
> >On 8/2/05, Sebastian <sebastianbroadbandgaming.net> wrote:
> >
> >
> >>i need to mask (hide) some vars in a url so they arent visible to the
> >>user. example, i want a url like this:
> >>
> >>page?id=3&something=12&more=12
> >>
> >>to turn into:
> >>
> >>page?id=3;LyFU;MLFxvy
> >>
> >>so from "LyFU" i can access $something and from "MLFxvy" $more
> >>any ideas how i can do this?
> >>
> >>doesn't have to be 100% secure, just a simple way hide it from the user.
> >>
> >>
> >
>
>

attached mail follows:


I just plain suck at regex, so I was hoping to get some hints from you
regex experts out there. I'm sure it's been done a thousand times, but
I can't seem to find what I'm looking for with a simple google search:

$phone could be "1234567890" OR
$phone could be "123-456-7890" OR
$phone could be "(123) 456 7890 OR
$phone could have other unexpected characters in it, even control
characters.

So what I'm desiring to do is run some type of regex on $phone and only
return the integers and assign the cleaned string back to $phone. I
thought I knew how to do this, but it's not working.

Thanks for your guidance.

attached mail follows:


David Christensen wrote:
> I just plain suck at regex, so I was hoping to get some hints from you
> regex experts out there. I'm sure it's been done a thousand times, but
> I can't seem to find what I'm looking for with a simple google search:
>
> $phone could be "1234567890" OR
> $phone could be "123-456-7890" OR
> $phone could be "(123) 456 7890 OR
> $phone could have other unexpected characters in it, even control
> characters.
>
> So what I'm desiring to do is run some type of regex on $phone and only
> return the integers and assign the cleaned string back to $phone. I
> thought I knew how to do this, but it's not working.
>
> Thanks for your guidance.
>

If all you want is the digits....

$phone = preg_replace ( "/\D/", "", $phone );

Same as....

/[^0-9]/

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


Hi, i need to sort data using ksort. Its complex data out from a
database (and no i can't sort it using the database sadly). I can change
my code to reflect a new way of sorting but only to some extent, im limited.

Now from the data i build an array of the things i need to display,
using the names of the hockey players i create a list that is supposed
to be sorted, look at the result, you'll see that accents are not sorted
althought my var_dump(setlocale(...)) returns that the french locale
(string(5) "fr_CA") has been chosen. Is there anything wrong? can i
change my code to fix this problem and how, cause all my tries point to
nothing.

(Btw i tried all the installed locales to no avail.)

Balodis Devon 1985-06-11 Baie-Comeau AF * Joueur
Balogh Sébastien 1987-01-17 Baie-Comeau AF Joueur
Blais Alexandre 1986-06-23 Baie-Comeau AF Joueur
Blouin Sébastien 1987-03-04 Baie-Comeau MAJ Joueur
Bossé Simon 1900-01-01 Baie-Comeau AF * Joueur
Bouchard François 1988-04-26 Baie-Comeau MAJ Joueur
Boudreault Stéphane 1986-01-16 Baie-Comeau AF Joueur
Boulianne Yannick 1987-10-19 Baie-Comeau AF Joueur
Bradley Adam 1985-09-18 Baie-Comeau AF * Joueur
Breault Benjamin 1988-02-21 Baie-Comeau MAJ Joueur
Brodeur Benoît 1987-03-07 Baie-Comeau AF Joueur
Bédard Mikaël 1987-12-13 Baie-Comeau AF Joueur
Bélanger Maxime 1986-03-03 Baie-Comeau MAJ Joueur
Bérubé Mathieu 1986-10-01 Baie-Comeau AF Joueur

(In case you didn't notice, the last 3 lines are the problem, they
should be right after the 3 first lines (after the a's))

########################################

//$teamdata gathered higher up in the code
$tmp_players = list_get_players($mysql_link, $_SESSION['team_list'],
                                $_GET['sys_date'],
                                $_SESSION['histo_directdata']);

//Sort it alpha cause its not done right now
foreach($tmp_players as $player){
        $players[0][$player['register_file']['info_lname'].'-'.$player['register_file']['info_fname'].'-'.$player['register_file']['info_mname'].'-'.$player['register_file']['info_datenais']]
= $player;
}

unset($tmpplayers, $player);
var_dump(setlocale(LC_ALL, array('fr_CA', 'fr_CA.iso88591',
                                'fr_CA.utf8')));
ksort($players[0], SORT_LOCALE_STRING);

attached mail follows:


Found my problem, i'm runnig php 4.3.11, will update first then i will
try again.

attached mail follows:


Hi,
Thanks to everyone's help, that multipage monster of a form is now
working properly (yay!).

One problem I have though is that I stick the answers as each page is
completed into a table. If the user hits the back button, rather than
adding a new row to the table I'd rather update it if it's there. That's
fairly straightforward when it's 1:1 questions to answers:

   $q_a_sql='INSERT INTO $userAnswerTable
                   ( q_id, a_id )
                   VALUES ' . (implode(",",$qanda))
                   . ' on duplicate key UPDATE a_id = VALUES(a_id);';

But when it's 1:n, such as with checkboxes, this neat little plan of
mine is thwarted.

So if I change the userAnswerTable to three columns, u_id, q_id and
a_id, is there a way I can do all the 1:1 and 1:n in the manner I wish?

TIA,
JJ

attached mail follows:


Ah, I had left out the third column the first time! Thanks.

Now I can insert and not create dupes but for some reason it is not
updating.

Here's the code:

       if ( ($_POST['action'] == 'process') && (!sizeof($message) ) )
       {
           foreach($_POST as $key=>$val)
                {
                    //find key/val sets within posts which are both numeric
                    if(is_numeric($key) && is_numeric($val))
                    {
                       $nkey=$key;
                       //add these values ( q_id, a_id ) to sql statement
                       $qanda[] .= "('1' , '" . $nkey . "' , '" . $val .
"')";
                    }
                    //find key/val sets within sub-arrays of $_POST
which are numeric
                    if(is_array($val))
                    {
                        foreach ($val as $akey=>$aval)
                            {
                            //add these values ( q_id, a_id ) to sql
statement
                            $qanda[] .= "('1' , '" . $key . "' , '" .
$aval . "')";
                            }
                    }
                }

             $q_a_sql="INSERT INTO" . $userTable . "(u_id, q_id, a_id )
                   VALUES " . (implode(",",$qanda)) . "on duplicate key
UPDATE a_id = VALUES(a_id);";

                   if($q_a_result = mysql_query($q_a_sql))
             {
               unset($_SESSION['required_fields']);
               $cat = $_POST['cat']+1;
               include_once(QUESTIONS . 'q.inc');
             }

?

Kristen G. Thorson wrote:
> How is it your plan "thwarted?" It looks fine to me, but maybe I'm
> missing something. The only thing I can think is that you're not
> defining your table keys correctly to correctly use ON DUPLICATE KEY.
> Do you have a key defined for all three columns *together*?
>
> mysql> create table user_answers (u_id int(11) not null, q_id int(11)
> not null, a_id int(11) not null, unique( u_id, q_id, a_id ) );
> Query OK 0 rows affected (0.22 sec)
>
> mysql> insert into user_answers (u_id,q_id,a_id) values
> (1,1,1),(1,1,2),(1,2,1),(1,1,1) on duplicate key update a_id=values(a_id);
> Query OK, 5 rows affected (0.01 sec)
> Records: 4 Duplicates: 1 Warnings: 0
>
> mysql>select * from user_answers;
> +------+------+------+
> | u_id | q_id | a_id |
> +------+------+------+
> | 1 | 1 | 1 |
> | 1 | 1 | 2 |
> | 1 | 1 | 3 |
> +------+------+------+
> 3 rows in set (0.00 sec)
>
>
>
> So, three different answers for the same user & same question. The one
> duplicate did not cause an error because of the ON DUPLICATE KEY. This
> looks like it's what you're trying to do, so then what's your error?
>
>
>
> kgt
>
>
>
>
> Jack Jackson wrote:
>
>> Hi,
>> Thanks to everyone's help, that multipage monster of a form is now
>> working properly (yay!).
>>
>> One problem I have though is that I stick the answers as each page is
>> completed into a table. If the user hits the back button, rather than
>> adding a new row to the table I'd rather update it if it's there.
>> That's fairly straightforward when it's 1:1 questions to answers:
>>
>> $q_a_sql='INSERT INTO $userAnswerTable
>> ( q_id, a_id )
>> VALUES ' . (implode(",",$qanda))
>> . ' on duplicate key UPDATE a_id = VALUES(a_id);';
>>
>> But when it's 1:n, such as with checkboxes, this neat little plan of
>> mine is thwarted.
>>
>> So if I change the userAnswerTable to three columns, u_id, q_id and
>> a_id, is there a way I can do all the 1:1 and 1:n in the manner I wish?
>>
>> TIA,
>> JJ
>>
>
>
>

attached mail follows:


Good Morning,
I was having a discussion with a fellow PHP Developer this morning and he
mentioned that he put's an '' sign in front of all function calls, and
every time he accesses an array;

I know that this is sloppy, and dangerous, but I don't know exactly what
this exposes him to, can any one give me any real world examples of why
this is bad, so I can relate it to his code?

php.net does not have much information about this. It seems like
suppressing errors, rather then catching them is problematic.

Thanks Again.

Justin.

attached mail follows:


Hello Justin,

I would guess that this is mostly performance and memory related. When,
for instance, trying to iterate an array, or a directory with files,
using on all function calls, it will attempt to go through the array,
attempting to allocate memory for each item, but when finding it
empty/broken, it leaves the loop and goes on to the next statement in
the code.

From what I can tell, PHP handles memory efficiently, although I
wouldn't hazard this when deploying a larger site using this type of
approach. Especially if the code inside a larger if..else block was
performed on an object that was created with function() call, and then
all the consecutive calls to functions operating on that object also
used . This would take up both CPU time and memory, possibly creating
leaks, based on how efficiently PHP would handle the operations on a
non-existant object.

A rule of thumb is to instead use empty() and is_array() and such
functions to discern if the object you are going to handle indeed is of
the type you wish it to be, that saves you both time and effort when
trying to debug something in the future. The empty() function goes a
long way here, unless dealing with integers, since empty() will return
true if the value is 0, which might not be desireable.

I hope this helps you in your argument against your fellow developer. :]

Regards,
Torgny

Justin Burger wrote:

>Good Morning,
>I was having a discussion with a fellow PHP Developer this morning and he
>mentioned that he put's an '' sign in front of all function calls, and
>every time he accesses an array;
>
>I know that this is sloppy, and dangerous, but I don't know exactly what
>this exposes him to, can any one give me any real world examples of why
>this is bad, so I can relate it to his code?
>
>php.net does not have much information about this. It seems like
>suppressing errors, rather then catching them is problematic.
>
>
>Thanks Again.
>
>Justin.
>
>

attached mail follows:


On 8/2/05, Justin Burger <jburgerluthresearch.com> wrote:
> Good Morning,
> I was having a discussion with a fellow PHP Developer this morning and he
> mentioned that he put's an '' sign in front of all function calls, and
> every time he accesses an array;

Any chance of revealing his identity - so that I can make sure that I
don't sub-contract him any work.

>
> I know that this is sloppy, and dangerous, but I don't know exactly what
> this exposes him to, can any one give me any real world examples of why
> this is bad, so I can relate it to his code?

It's bad in that your system normally gives you an error when you do
something wrong. Sometimes your code can recover from errors, but your
code runs better if the errors aren't there.

In production code, you don't want the errors to show up on screen,
mainly because you don't want to expose the code you are using on your
back end. You fix this by modding the correct parameter in php.ini (
display_errors IIRC )

>
> php.net does not have much information about this. It seems like
> suppressing errors, rather then catching them is problematic.

PHP displays errors for a reason. It is both egotistic, and foolish to
assume that your code will always be perfect. Errors enlighten you
when your code is not perfect, and give you the opportunity to perfect
it.

You can achieve a similar effect by setting display_errors to the
correct setting.

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

attached mail follows:


Justin Burger wrote:

>Good Morning,
>I was having a discussion with a fellow PHP Developer this morning and he
>mentioned that he put's an '' sign in front of all function calls, and
>every time he accesses an array;
>
>I know that this is sloppy, and dangerous, but I don't know exactly what
>this exposes him to, can any one give me any real world examples of why
>this is bad, so I can relate it to his code?
>
>php.net does not have much information about this. It seems like
>suppressing errors, rather then catching them is problematic.
>
>
>Thanks Again.
>
>Justin.
>
>

This is a Bad Idea. A Very Bad Idea actually. If he's just looking to
hide error output, he should at least edit php.ini
to log to an error file. Otherwise, debugging his code would be
horrible. The "" is total slop.

Matt Darby

attached mail follows:


Justin Burger wrote:
> Good Morning,
> I was having a discussion with a fellow PHP Developer this morning and he
> mentioned that he put's an '' sign in front of all function calls, and
> every time he accesses an array;
>
> I know that this is sloppy, and dangerous, but I don't know exactly what
> this exposes him to, can any one give me any real world examples of why
> this is bad, so I can relate it to his code?
>
> php.net does not have much information about this. It seems like
> suppressing errors, rather then catching them is problematic.

I'm going to partially disagree with some of the responses you get on
this by saying that it doesn't have to be sloppy or a bad idea. I use
the '' symbol on _some_ of my function calls (mainly MySQL stuff), but
only because I have my own error handling system in place. Some will
say that if you want to control what is being printed to the screen,
modify the php.ini file, but I don't fully subscribe to that. In
production, I do turn off notices, but that's about it. For me, it
boils down to my wanting to control the verbatim of the error; ie make
the error messages a bit more end user friendly. The reason I don't
like suppressing this in the ini file is it becomes a pain in the ass to
try and debug a customer's problem (with the customer on the phone), if
no error messages are showing on the screen for him/her.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


Justin Burger wrote:
> Does suppressing the error only suppress it from the screen, or does it
> ignore the error?
>
> ie: is the error still logged?

Please reply to the list.

I don't know if it still logs the error (assuming you have error logging
turned on).

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


Does suppressing the error only suppress it from the screen, or does
it ignore the error?

ie: is the error still logged?

On Aug 2, 2005, at 12:18 PM, John Nichel wrote:

> Justin Burger wrote:
>
>
>> Good Morning,
>> I was having a discussion with a fellow PHP Developer this morning
>> and he
>> mentioned that he put's an '' sign in front of all function
>> calls, and
>> every time he accesses an array;
>> I know that this is sloppy, and dangerous, but I don't know
>> exactly what
>> this exposes him to, can any one give me any real world examples
>> of why
>> this is bad, so I can relate it to his code?
>> php.net does not have much information about this. It seems like
>> suppressing errors, rather then catching them is problematic.
>>
>>
>
> I'm going to partially disagree with some of the responses you get
> on this by saying that it doesn't have to be sloppy or a bad idea.
> I use the '' symbol on _some_ of my function calls (mainly MySQL
> stuff), but only because I have my own error handling system in
> place. Some will say that if you want to control what is being
> printed to the screen, modify the php.ini file, but I don't fully
> subscribe to that. In production, I do turn off notices, but
> that's about it. For me, it boils down to my wanting to control
> the verbatim of the error; ie make the error messages a bit more
> end user friendly. The reason I don't like suppressing this in the
> ini file is it becomes a pain in the ass to try and debug a
> customer's problem (with the customer on the phone), if no error
> messages are showing on the screen for him/her.
>
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> johnkegworks.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

attached mail follows:


Example:

I was working on a HORRIBLE piece of code for a cart app. The original
programmer had a line like this:

$result = mysql_query( "SELECT * FROM user_logins WHERE
cookie='".$cookie."'" );

Where $cookie is a session id stored in a cookie (what else? ;). The
problem was, he had some faulty code that was not always properly
setting the cookie. So then he went and did the following:

$customer_id=mysql_result($result,0,"id");

Problem is, $cookie='' but there are no entries in the user_logins table
where cookie=''. So, the query is empty and trying to pull the customer
ID gave the nice little warning because E_ALL was on:

*Warning*: mysql_result(): Unable to jump to row 0 on MySQL result index
3 in *cart.php* on line *26*

So customers get confused because of the warning and on top of that they
have no items in their cart because customer_id is used to look up temp
carts (and it wasn't set). He couldn't figure out why it was happening
and he didn't have logging turned on, so all he had was Billy Bob saying
"My cart is gone. There was an error. I don't know what it was. I
didn't write it down." So then he decided to put an in front of the
offending lines. Customers no longer get an error. Excellent.

But wait! Three months down the road, we have the problem of the
vanishing carts. So third-party programmer comes in, turns on logging
so I can see the stupid errors and figure out what's going on, but
errors have been repressed! This is not helpful to anyone, I then have
to go through and figure out whether it will break something by removing
those stupid 's (there were a LOT of them).

The problem wasn't that he was using , but that he was not properly
checking for errors, and used to suppress bugs he couldn't duplicate
or couldn't figure out how to fix. In short, if you don't want the
customer to see the error, turn of reporting and turn on logging.
Anyone trying to debug your code three years later will thank you.

my 2c.

kgt

Justin Burger wrote:

>Good Morning,
>I was having a discussion with a fellow PHP Developer this morning and he
>mentioned that he put's an '' sign in front of all function calls, and
>every time he accesses an array;
>
>I know that this is sloppy, and dangerous, but I don't know exactly what
>this exposes him to, can any one give me any real world examples of why
>this is bad, so I can relate it to his code?
>
>php.net does not have much information about this. It seems like
>suppressing errors, rather then catching them is problematic.
>
>
>Thanks Again.
>
>Justin.
>
>
>

attached mail follows:


Hello Justin,

Tuesday, August 2, 2005, 8:43:09 PM, you wrote:

JB> Does suppressing the error only suppress it from the screen, or
JB> does it ignore the error?
JB> ie: is the error still logged?

It will ignore it totally, it doesn't even make it as far as the log
files - which is why in most cases it's a bad thing to use. When it
comes to the mysql/i functions however I will suppress the error and
use my own error checking to avoid blank pages / unsightly warnings.

Best regards,

Richard Davey
--
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

attached mail follows:


Justin Burger wrote:
> Good Morning,
> I was having a discussion with a fellow PHP Developer this morning and he
> mentioned that he put's an '' sign in front of all function calls, and
> every time he accesses an array;
>
> I know that this is sloppy, and dangerous, but I don't know exactly what
> this exposes him to, can any one give me any real world examples of why
> this is bad, so I can relate it to his code?
>
> php.net does not have much information about this. It seems like
> suppressing errors, rather then catching them is problematic.

in short what you monkey is doing sucks - if it was a good idea php
would be designed to output or log no errors at all... ever ... funnily
enough that's not they way it's designed.

knowing how to handle errors properly AND doing it is IMHO one of the
main differentiators between amateur and professional programmers -
of course the true wizards among us know when they can break the rules
(e.g. hack up some nasty little script that scratches an itch knowing
full well it 'breaks the rules') :-)

if I were you I would give serious weight to the words of John Nichel
on this matter - he might not admit it but he really knows where his towel
;-)

>
>
> Thanks Again.
>
> Justin.
>

attached mail follows:


I have two tables with orders of different type of articles.
order_table_1
order_table | order_transaction_no | order_date | ...
1 | 56982 | 2005-07-29 9:12:34
1 | 97163 | 2005-07-30 8:45:32
1 | 67452 | 2005-07-31 10:56:11

order_table_2
order_table | order_transaction_no | order_date | ...
2 | 36928 | 2005-07-29 11:12:54
2 | 97001 | 2005-07-29 4:45:41
2 | 54549 | 2005-07-31 6:56:28

I have to grab orders from both tables (last 24 hour), put them together
and then sort them by datetime ordered. Like this:
2 | 97001 | 2005-07-29 4:45:41
1 | 56982 | 2005-07-29 9:12:34
2 | 36928 | 2005-07-29 11:12:54
1 | 97163 | 2005-07-30 8:45:32
2 | 54549 | 2005-07-31 6:56:28
1 | 67452 | 2005-07-31 10:56:11

My idea was to grab first all orders from first table as
multi-dimensional array
$orders = array(
                            array('order_table' => 1, 'order_trans_no'
=> 56982, 'order_date' => 2005-07-29 9:12:34),
                            array('order_table' => 1, 'order_trans_no'
=> 97163, 'order_date' => 2005-07-30 8:45:32),
                            array('order_table' => 1, 'order_trans_no'
=> 67452, 'order_date' => 2005-07-31 10:56:11)
                            array('order_table' => 2, 'order_trans_no'
=> 36928, 'order_date' => 2005-07-29 11:12:54),
                            array('order_table' => 2, 'order_trans_no'
=> 97001, 'order_date' => 2005-07-29 4:45:41),
                            array('order_table' => 2, 'order_trans_no'
=> 54549, 'order_date' => 2005-07-31 6:56:28)
            )

and then sort the array after order_date - but don't know how :(

I guess the best way would be to make a sql query and sort them while
grabbing them from db but don't know how to do it either :(

Any help?

Thanks!

-afan

attached mail follows:


Problem solved by mysql query (I thought it would be more tough :) )

my_query("
        (select order_transaction_no, order_date from order_table_1
where order_date >= '". $date_yesterday ."')
        union
        (select order_transaction_no, order_date from order_table_2
where order_date >= '". $date_yesterday ."')
        order by order_transaction_no desc, order_date desc
    ", 0);

:)

afanafan.net wrote:

> I have two tables with orders of different type of articles.
> order_table_1
> order_table | order_transaction_no | order_date | ...
> 1 | 56982 | 2005-07-29 9:12:34
> 1 | 97163 | 2005-07-30 8:45:32
> 1 | 67452 | 2005-07-31 10:56:11
>
> order_table_2
> order_table | order_transaction_no | order_date | ...
> 2 | 36928 | 2005-07-29 11:12:54
> 2 | 97001 | 2005-07-29 4:45:41
> 2 | 54549 | 2005-07-31 6:56:28
>
> I have to grab orders from both tables (last 24 hour), put them
> together and then sort them by datetime ordered. Like this:
> 2 | 97001 | 2005-07-29 4:45:41
> 1 | 56982 | 2005-07-29 9:12:34
> 2 | 36928 | 2005-07-29 11:12:54
> 1 | 97163 | 2005-07-30 8:45:32
> 2 | 54549 | 2005-07-31 6:56:28
> 1 | 67452 | 2005-07-31 10:56:11
>
> My idea was to grab first all orders from first table as
> multi-dimensional array
> $orders = array(
> array('order_table' => 1, 'order_trans_no'
> => 56982, 'order_date' => 2005-07-29 9:12:34),
> array('order_table' => 1, 'order_trans_no'
> => 97163, 'order_date' => 2005-07-30 8:45:32),
> array('order_table' => 1, 'order_trans_no'
> => 67452, 'order_date' => 2005-07-31 10:56:11)
> array('order_table' => 2, 'order_trans_no'
> => 36928, 'order_date' => 2005-07-29 11:12:54),
> array('order_table' => 2, 'order_trans_no'
> => 97001, 'order_date' => 2005-07-29 4:45:41),
> array('order_table' => 2, 'order_trans_no'
> => 54549, 'order_date' => 2005-07-31 6:56:28)
> )
>
> and then sort the array after order_date - but don't know how :(
>
> I guess the best way would be to make a sql query and sort them while
> grabbing them from db but don't know how to do it either :(
>
> Any help?
>
> Thanks!
>
> -afan
>

attached mail follows:


Has anyone integrated JPGraph [or another php graph class] into a
PHP/AJAX setup ?

I would really like to integrate interactive graphs based upon user
variables.
Would be fantastic.
Are there any examples out there ?

g

attached mail follows:


Rory Browne a écrit :
> I haven't a monkies what that code(your java) does, and I don't have
> time to analyse it(in expensive cybercafe), but you may want to
> consider www.php.net/print-r www.php.net/var-dump and
> www.php.net/var-export
>
> I think they may do what you want without using the toString method,
> which for what you're describing is basicly an ugly hack.
>
> One more thing: Enlighten me: What exactly do you mean by "live
> evolution" in your php/java context.

If in php context you have class, say, A:

class A
{

  var $t1;
  var $t2;
  var $t3;

//After, you have object contructor of type A
//we have something like this

function A ($var1, $var2, $var3)
{
        $this -> t1 = $var1;
        $this -> t2 = $var2;
        $this -> t3 = $var3;
}

....some other code
}

//than in some other class we have something like this:

class someOtherClass
{
        $aConstructor = new A(1,2,3);
        //values of t1, t2 and t3 are 1,2 and 3 now
  }

Right? yes.

How you can you do something like this inside of "someOtherClass"

print ($aConstructor);

to finally have some nice output like
Value of t1 is 1;
Value of t2 is 2;
Value of T3 is 3;

or just:

1
2
3

Without creating functions like getValues()

function getValues()
{
        print ($this -> t1);
        print ($this -> t2);
        print ($this -> t3);
}

and after explicit invoke function:

  $aConstructor -> getValues();

So, what I want is
this: print ($aConstructor);

and not this:

$aContructor -> getValues();

Am I clear :-)

ADI

attached mail follows:


You're using a lot of negatives.

$data = array(); // You should initialise $data to array() for various reasons:
// 1: self_documentation - to anyone who reads your code will be obvious
// that $data should contain an empty array
// 2: security - if someone goes to
// http://yoursite.com/page.php?data[]=something_bad_here and you have
// register_globals on(which should be, but not assumed to be, off)

On 8/1/05, Sebastian <sebastianbroadbandgaming.net> wrote:
> is it always necessary to call array() when you do something like this:
>
> mysql_query("SELECT ....");
> while($rows .....)
> {
> $data[] = $rows;
> }
>
> if so, why? i have a habit of never calling array() and someone told me
> i shouldn't do this.

Someone told you you shouldn't not call array() - in other words you
should call array(). If I'm reading you correctly then the someone is
right. You should not use a variable without initialising it, unless
it comes from a form, in which case you should not use it without
"cleaning" it.

>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Rory Browne wrote:
> You're using a lot of negatives.
>

nice catch on the double neg Rory :-)

>
>
> $data = array(); // You should initialise $data to array() for various reasons:
> // 1: self_documentation - to anyone who reads your code will be obvious
> // that $data should contain an empty array
> // 2: security - if someone goes to
> // http://yoursite.com/page.php?data[]=something_bad_here and you have
> // register_globals on(which should be, but not assumed to be, off)
>
>
>
>
>
> On 8/1/05, Sebastian <sebastianbroadbandgaming.net> wrote:
>
>>is it always necessary to call array() when you do something like this:
>>
>>mysql_query("SELECT ....");
>>while($rows .....)
>>{
>> $data[] = $rows;
>>}
>>
>>if so, why? i have a habit of never calling array() and someone told me
>>i shouldn't do this.
>
>
> Someone told you you shouldn't not call array() - in other words you
> should call array(). If I'm reading you correctly then the someone is
> right. You should not use a variable without initialising it, unless
> it comes from a form, in which case you should not use it without
> "cleaning" it.
>
>
>
>
>>
>>--
>>No virus found in this outgoing message.
>>Checked by AVG Anti-Virus.
>>Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>

attached mail follows:


On 8/2/05, Robin Vickery <robinvgmail.com> wrote:
> I don't suppose this is the place for a rant about the futility of
> checking email addresses with a regexp?
>
> -robin

Let Richard Lynch tell him. He's good at regex's, and it's HIS email
address that never makes it through!

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/182/estefan_gloria.php
Estefan, Gloria Song Lyrics

attached mail follows:


Sorry to drag this up again, but I'm attempting to set up FCKeditor
and am having problems with the File Browser. Has anyone successfully
got this running with the PHP connector? If so some hints & tips would
be most appreciated.

I've set my UserFilePath in config.php (relative to doc root) but the
file (image) browser shows no files and claims to be looking at the
path '/'. Uploading a file does not give an error but the file does
not get uploaded.

thanks
--
Graham

attached mail follows:


> > -----Original Message-----
> > From: Graham Cossey [mailto:graham.cosseygmail.com]
> > Sent: Tuesday, August 02, 2005 1:12 PM
> > To: php-generallists.php.net
> > Subject: Re: [PHP] Re: editor in WEB PAGE
> >
> > Sorry to drag this up again, but I'm attempting to set up FCKeditor
> > and am having problems with the File Browser. Has anyone successfully
> > got this running with the PHP connector? If so some hints & tips would
> > be most appreciated.
> >
> > I've set my UserFilePath in config.php (relative to doc root) but the
> > file (image) browser shows no files and claims to be looking at the
> > path '/'. Uploading a file does not give an error but the file does
> > not get uploaded.
> >
> > thanks
> > --
> > Graham
> >

I've been fiddling and found a typo in the config.php's UserFilesPath.
This now allows me to upload files (to the expected directory) but I
still cannot view the files in this directory in the file browser.

--
Graham

attached mail follows:


Miles Thompson wrote:
> At 11:45 AM 8/2/2005, John Nichel wrote:
>
>> Jochem Maas wrote:
>>
>>> John Nichel wrote:
>>>
>>>> Jochem Maas wrote:
>>>> <snip>
>>>>
>>>>> did you look at line 44??? (actually I found the problem on line 69
>>>>> when I cut and pasted into a editor - the editor also gave that
>>>>> line as the
>>>>> one with the error in it:
>>>>
>>>>
>>>>
>>>> </snip>
>>>>
>>>> And to think that I used to hate editors that did this at one time.
>>>
>>>
>>> :-) not sure I follow you completely.
>>> actually the editor (TextPad in this case) didn't do anything nasty -
>>> it was my mail
>>> app had already done a nice job with wordwrapping :-/
>>
>>
>> About 6 or so years ago, I couldn't stand things like syntax
>> highlighting, and editors that error checked (don't know why, I'm just
>> weird that way I guess). Now, I don't know how I lived without it.
>> Guess I've just be assimilated. ;)
>>
>> --
>
>
> John,
>
> Which editor does syntax checking?
> (In VB I find it a mixed blessing.)

I have Textpad set up with syntax highlighting and I've added an
item to the 'tools' menu that allows me to perform a 'php -l' on the current
file (1 item for php5, and 1 for php4) - but the best integrated syntax checking
(and code analysis) I have found is in the Zend Studio v4 (aka ZDE) - really
a superb tool (although I feel some work could still be done on the general/non-php-specifc
  editor functionality to bring up to par with some of the longer-standing/more traditional
editors that I have used)

>
> Cheers - Miles
>

attached mail follows:


Meno Abels wrote:
> it is only a typo in my email i use __construct

ok - I would recommend cut-n-paste for this kind of output
to prevent idiots like me pointing out you typos and to avoid confusion
in general.

the next questions would be:

a, how many parents does the problem class (Link or Links?) have?
b, is Rank the base class?
c, does Rank::__construct() actually exist?
d, does the error also occur with php5.0.x? (as apposed to php5.1beta)

given these questions may seem silly - but I can't see your code from
here :-) so I figured I'd ask anyway!

>
> Meno
>
> 2005/8/2, Jochem Maas <jochemiamjochem.com>:
>
>>Pawel Bernat wrote:
>>
>>>On Tue, Aug 02, 2005 at 03:42:00PM +0100, Meno Abels wrote:
>>>
>>>
>>>>Hello,
>>>>
>>>>With my application that uses heavily inherent classes, sometimes I
>>
>>deeeeep class heirarchies can lead to brainfreeze - beware of going to deep :-)
>>
>>
>>>>get the following message:
>>>>PHP Fatal error: Call to undefined method Rank::_construtor() in
>>>>.../inc/Links.class.php. It works with php
>>>>4.x when I use the old style of constructor calling
>>>>$this->(CLASSNAME) . But when working with php 5.2 b2 or b3 in the old
>>>>OR the new style, I get the PHP Fatal error from above.
>>>>Is there any hints to look at this problem?
>>>
>>>Why do you call _construct instead of __construct? And how do you do it?
>>
>>he seems to be calling _construtor() which although not wrong is not the
>>method he is looking for (cue voice of Alex Guiness for the second time this week :-)
>>
>>try __construct()
>>
>>PS - this kind of thing belongs on generals until you are _sure_ it's an
>>internals problem. IMHO.
>>
>>
>>>Did you read everything at http://php.net/construct (including Note)?
>>>What about php 5.0?
>>>
>>
>>
>

attached mail follows:


Hi, i have in my mysql db one table columm, some think like this:

day reporte
--- -------
1 45
2 56
4 78
6 89
7 90
etc...

How can i print all the value from 'reporte' columm depending the 'day'
columm, and if there is not exist a day print 0 value, for example:

day 1 ----- reporte 45
day 2 ----- reporte 56
day 3 ----- 0
day 4 ----- reporte 78
day 5 ----- 0
etc...

Sorry for my english

--
Este mensaje ha sido analizado por MailScanner
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.

attached mail follows:


From what I gathered you simply want to print all days and the "reporte"
field info and if there isn't any then 0.

Assuming you used SQL and retrieved your information from the db into an
associated Array

$arr //the results from the DB...

$y = 31; //Assuming you are working with 31 days...

for($x=0; $x<$y; $x++)
{
echo "day ". ($x+1) ." ----- report " . ((isset($arr[$x+1]))?
$arr[$x+1]:"0") . "<br />"; //$x+1 is required because you can never have
day 0
}

hope this helps...

-sonu

""Jesús Alain Rodríguez Santos"" <wmastercfg.jovenclub.cu> wrote in message
news:1974.192.168.6.61.1123038296.squirrelcorreo.cfg.jovenclub.cu...
> Hi, i have in my mysql db one table columm, some think like this:
>
> day reporte
> --- -------
> 1 45
> 2 56
> 4 78
> 6 89
> 7 90
> etc...
>
> How can i print all the value from 'reporte' columm depending the 'day'
> columm, and if there is not exist a day print 0 value, for example:
>
> day 1 ----- reporte 45
> day 2 ----- reporte 56
> day 3 ----- 0
> day 4 ----- reporte 78
> day 5 ----- 0
> etc...
>
> Sorry for my english
>
>
> --
> Este mensaje ha sido analizado por MailScanner
> en busca de virus y otros contenidos peligrosos,
> y se considera que está limpio.

attached mail follows:


Sorry clarification required to my previous answer...

I sort of answered you in a hurry, and I made another assumption that I
didn't define.

I wanted to clarify that I'm assuming the array is setup as follows
arr[day]=>report.

arr[1]=>45
arr[2]=>56
arr[4]=>78
etc...

$y = 31;

for($x=0; $x < $y; $x++)
{
echo "day ". ($x+1) ." ----- report " . ((isset($arr[$x+1]))?
$arr[$x+1]:"0") . "<br />"; //$x+1 is required because you can never have
day 0
}

""sonu gill"" <sonugillsonugill.com> wrote in message
news:AE.A3.04646.34330F24pb1.pair.com...
> From what I gathered you simply want to print all days and the "reporte"
> field info and if there isn't any then 0.
>
> Assuming you used SQL and retrieved your information from the db into an
> associated Array
>
> $arr //the results from the DB...
>
> $y = 31; //Assuming you are working with 31 days...
>
> for($x=0; $x<$y; $x++)
> {
> echo "day ". ($x+1) ." ----- report " . ((isset($arr[$x+1]))?
> $arr[$x+1]:"0") . "<br />"; //$x+1 is required because you can never have
> day 0
> }
>
> hope this helps...
>
> -sonu
>
>
> ""Jesús Alain Rodríguez Santos"" <wmastercfg.jovenclub.cu> wrote in
> message
> news:1974.192.168.6.61.1123038296.squirrelcorreo.cfg.jovenclub.cu...
>> Hi, i have in my mysql db one table columm, some think like this:
>>
>> day reporte
>> --- -------
>> 1 45
>> 2 56
>> 4 78
>> 6 89
>> 7 90
>> etc...
>>
>> How can i print all the value from 'reporte' columm depending the 'day'
>> columm, and if there is not exist a day print 0 value, for example:
>>
>> day 1 ----- reporte 45
>> day 2 ----- reporte 56
>> day 3 ----- 0
>> day 4 ----- reporte 78
>> day 5 ----- 0
>> etc...
>>
>> Sorry for my english
>>
>>
>> --
>> Este mensaje ha sido analizado por MailScanner
>> en busca de virus y otros contenidos peligrosos,
>> y se considera que está limpio.

attached mail follows:


Hi All,

I'm facing a little problem here. I'm making a few query using SOAP
protocol (NuSOAP class), that involves sending out an amount (e.g.
0.01), which is accepted in type of [long] in its WSDL, for recording
purpose. Typical call:

[code]
$param = array('rewardSchemeId'=> $tnt_rewardSchemeId,
                'accountNumber' => $acountNumber,
                'amount' => $amountIgnoringDecimalPoint) );

$result = $soap->call('recordBooking', $param);
[/code]

The problem is, I have not been able to convert PHP's integer/float type
to long because there is no function that does it. Or is there?

I've tried using settype() and (type) casting, but to no avail. I've
read a user's contribution note in PHP Manual for settype(), and he said:

"It's worth noting that one can neither <I>settype()</i> nor type-cast a
variable as a long. The workaround for this seems to be to use
<I>pack()</i>."

I've looked at pack() function and tried it but I don't think I'm
getting it right because the instruction is not clear to me ( I don't
have programming background). I've done the following:

$amount = pack('L', $amount);

Please assist. Thanks.

--
Wee Keat Chin

Protocol Networks
p: 1300 131 932
e: weekeatpn.com.au
h: www.pn.com.au