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 4 Sep 2007 23:51:59 -0000 Issue 5000

php-general-digest-helplists.php.net
Date: Tue Sep 04 2007 - 18:51:59 CDT


php-general Digest 4 Sep 2007 23:51:59 -0000 Issue 5000

Topics (messages 261678 through 261704):

Re: Dealing with auto-increment in MySQL
        261678 by: Satyam
        261679 by: Jay Blanchard
        261686 by: tedd
        261687 by: Bastien Koert
        261688 by: Jason Pruim
        261691 by: brian
        261696 by: Jason Pruim
        261698 by: brian
        261704 by: tedd

Security Issue
        261680 by: Karl-Heinz Schulz
        261681 by: Wouter van Vliet / Interpotential

Re: Generating foldout menus in php
        261682 by: zerof

Re: Create a matrix gallery
        261683 by: Simon

Re: Pragmatically changing a "Record Number"
        261684 by: tedd
        261685 by: Graham Cossey
        261690 by: brian

Command line socket server and SSL
        261689 by: Paul

Bind function parameters with create_function ('currying')
        261692 by: Rob Desbois
        261693 by: Richard Heyes

Re: PHP Developer Required]
        261694 by: Greg Gay
        261700 by: Robert Cummings

MySQL, PHPMyAdmin, GRANT, headaches
        261695 by: brian
        261697 by: Janet Valade
        261699 by: brian

PHP Debugger
        261701 by: shiplu
        261702 by: Eric Gorr
        261703 by: Nathan Nobbe

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:


I was wondering if people is asking this in the belief that the
autoincrement field is the record position in the database table and that by
not reusing those positions, the space of the deleted records is wasted.
Perhaps when they say renumbering what they are meaning is compacting the
database reusing the empty slots they assume those autoincrement fields
point to. Someone remembers dBaseIII .dbf files? Well, perhaps that is the
picture they have in mind.

Satyam

----- Original Message -----
From: "Jay Blanchard" <jblanchardpocket.com>
To: "Steve Finkelstein" <sfstevefink.net>; "php-general"
<php-generallists.php.net>
Sent: Tuesday, September 04, 2007 12:53 PM
Subject: RE: [PHP] Dealing with auto-increment in MySQL

> [snip]
> Do you use logic in your code to find a missing ID and insert new
> records
> based on that? Or do you just ignore it, let mysql handle the numbering
> and
> go on with your lives?
> [/snip]
>
> The answer is B. There is a long standing discussion on this right now.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
> 9:31
>
>

attached mail follows:


[snip]
I was wondering if people is asking this in the belief that the
autoincrement field is the record position in the database table and
that by
not reusing those positions, the space of the deleted records is
wasted.
Perhaps when they say renumbering what they are meaning is compacting
the
database reusing the empty slots they assume those autoincrement fields
point to. Someone remembers dBaseIII .dbf files? Well, perhaps that is
the
picture they have in mind.
[/snip]

Maybe, but it seems as if more of this is about keeping a contiguous
'index' of the records contained in the database.

attached mail follows:


At 1:15 PM +0200 9/4/07, Satyam wrote:
>I was wondering if people is asking this in the belief that the
>autoincrement field is the record position in the database table and
>that by not reusing those positions, the space of the deleted
>records is wasted. Perhaps when they say renumbering what they are
>meaning is compacting the database reusing the empty slots they
>assume those autoincrement fields point to. Someone remembers
>dBaseIII .dbf files? Well, perhaps that is the picture they have in
>mind.
>
>Satyam

Satyam:

I'm sure that's the reasoning and the misconception that some people
have, but there are all sorts of schemes to manage "slots" (gaps in
memory or storage). I do not know how MySQL specifically handles
storage fragmentation, but I am sure it does.

The best scheme I've seen (granted I'm limited) was how the older
Macs worked with their memory manager. When programming and you asked
for memory, you didn't receive a pointer to a block of available
memory, but rather a handle which was a pointer to a pointer to a
block of memory.

Then at times when the memory manager thought it was opportune (I
haven't a clue as to how that was determined), it would go in and
rearrange all memory to optimize the amount of free memory blocks.
While the address the handles would point to would change, your
pointer to the handle would remain the same as before. It was cool
they way it did that and that's one of the reasons why the older Macs
seldom crashed.

The newer Macs are based upon Unix and I haven't a clue as to how it
handles memory, but it does a pretty good job from my experience.

I can't help but think that MySQL has had some of the best minds in
the world working on it and this problem was resolved long ago.

Cheers,

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

attached mail follows:


I just let it go...there is no need to manage that process or you'll just screw up the mysql...
it shouldn't be relied on for anything other that uniqueness any way
 
bastien
 
 
 
 
 
> Date: Mon, 3 Sep 2007 23:53:22 -0400> From: sfstevefink.net> To: php-generallists.php.net> Subject: [PHP] Dealing with auto-increment in MySQL> > How're you folks dealing with records that are auto incremented in MySQL> after a delete is made? I've noticed the only way to get a sequential order> back is to truncate the table completely.> > Do you use logic in your code to find a missing ID and insert new records> based on that? Or do you just ignore it, let mysql handle the numbering and> go on with your lives?> > Just curious.> > Thanks!> > - sf
_________________________________________________________________
Connect to the next generation of MSN Messenger 
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline

attached mail follows:


On Sep 4, 2007, at 7:15 AM, Satyam wrote:

> I was wondering if people is asking this in the belief that the
> autoincrement field is the record position in the database table
> and that by not reusing those positions, the space of the deleted
> records is wasted. Perhaps when they say renumbering what they are
> meaning is compacting the database reusing the empty slots they
> assume those autoincrement fields point to. Someone remembers
> dBaseIII .dbf files? Well, perhaps that is the picture they have
> in mind.

As the person who started the other thread about this, my big thing
was having a continuous record number that I could display to the
customer much the way excel displays record numbers.

But after discussing it, I see where my thinking was wrong in how I
wanted to achieve it, and also my misunderstanding of the way
databases worked. I'm pretty new working with databases, and PHP.
HTML and CSS I've done for awhile, just never needed a database or
programming language until recently :)

so to put my 2¢ in on this, I would say to leave alone the auto
increment field especially if it's included in an index. If you need
a record number, either store it in the database in a separate field
as tedd suggested, and leave the main auto increment field alone. OR
use PHP (Or your favorite programming language) to add a "Record
number" to the display.

Okay I'm done now :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruimraoset.com

attached mail follows:


Jason Pruim wrote:
>
> As the person who started the other thread about this ...

As one of the people responsible for dragging that thread out ...

> But after discussing it, I see where my thinking was wrong in how I
> wanted to achieve it, and also my misunderstanding of the way databases
> worked. I'm pretty new working with databases, and PHP. HTML and CSS
> I've done for awhile, just never needed a database or programming
> language until recently :)

Which is why i think it's important to discuss this. Given that yet
another thread has already begun on this topic, it seems worthy of
dscussion.

> so to put my 2¢ in on this, I would say to leave alone the auto
> increment field especially if it's included in an index. If you need a
> record number, either store it in the database in a separate field as
> tedd suggested, and leave the main auto increment field alone. OR use
> PHP (Or your favorite programming language) to add a "Record number" to
> the display.

Except that, should this seperate field be used, as soon as some row in
the table is deleted, *that* index column value will *also* suddenly
have a gap and you're back to re-ordering.

id PLU index
1 foo-324 1
2 foo-894 2 <- delete this row
3 foo-929 3
4 foo-653 4

> Okay I'm done now :)

me too, i think

brian

attached mail follows:


On Sep 4, 2007, at 12:20 PM, brian wrote:

> Jason Pruim wrote:
>>
>> As the person who started the other thread about this ...
>
> As one of the people responsible for dragging that thread out ...
>
>> But after discussing it, I see where my thinking was wrong in how
>> I wanted to achieve it, and also my misunderstanding of the way
>> databases worked. I'm pretty new working with databases, and PHP.
>> HTML and CSS I've done for awhile, just never needed a database
>> or programming language until recently :)
>
>
> Which is why i think it's important to discuss this. Given that yet
> another thread has already begun on this topic, it seems worthy of
> dscussion.
>
>> so to put my 2¢ in on this, I would say to leave alone the auto
>> increment field especially if it's included in an index. If you
>> need a record number, either store it in the database in a
>> separate field as tedd suggested, and leave the main auto
>> increment field alone. OR use PHP (Or your favorite programming
>> language) to add a "Record number" to the display.
>
> Except that, should this seperate field be used, as soon as some
> row in the table is deleted, *that* index column value will *also*
> suddenly have a gap and you're back to re-ordering.
>
> id PLU index
> 1 foo-324 1
> 2 foo-894 2 <- delete this row
> 3 foo-929 3
> 4 foo-653 4
>

I see what you're getting at, but if PHP is controlling a "Record
Number" you could have it loop through the results find the gaps and
truncate the table to provide a record number. No idea how to do it,
just that I'm sure it can be done :)

>> Okay I'm done now :)
>
> me too, i think
>
> brian
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruimraoset.com

attached mail follows:


Jason Pruim wrote:
>
> On Sep 4, 2007, at 12:20 PM, brian wrote:
>
>> Jason Pruim wrote:
>>
>>> so to put my 2¢ in on this, I would say to leave alone the auto
>>> increment field especially if it's included in an index. If you
>>> need a record number, either store it in the database in a separate
>>> field as tedd suggested, and leave the main auto increment field
>>> alone. OR use PHP (Or your favorite programming language) to add a
>>> "Record number" to the display.
>>
>>
>> Except that, should this seperate field be used, as soon as some row
>> in the table is deleted, *that* index column value will *also*
>> suddenly have a gap and you're back to re-ordering.
>>
>> id PLU index
>> 1 foo-324 1
>> 2 foo-894 2 <- delete this row
>> 3 foo-929 3
>> 4 foo-653 4
>>
>
> I see what you're getting at, but if PHP is controlling a "Record
> Number" you could have it loop through the results find the gaps and
> truncate the table to provide a record number. No idea how to do it,
> just that I'm sure it can be done :)

I assume you mean truncate the resultset. But there's no need to do
that, either. One only needs to set up a counter variable when
displaying the results.

Given the simple table above (with an extra 'name' column, the second
row deleted, and no 'index' column):

<?php
$result = mdb2->query('SELECT id, name, PLU FROM my_table');

/* this is the counter used in place of the 'index' column
  */
$count = 0;

/* We want to display a list of product names along with the
  * PLU. We also want to have a running count. Each product
  * PLU will be a link to some other script, passing the row's id
  * (the AUTO_INCREMENT Primary Key).
  * Pretend the HTML table has already been opened.
  */
while (++$count && $row = $result->fetchRow())
{
?>
   <tr>
     <th><?= $count ?></th>
     <td><a href="my_other_script.php?id=<?= $row['id'] "?>">
       <?= $row['PLU'] ?>
     </td>
     <td><?= $row['name'] ?></td>
   </tr>
<?php
}
?>

Thus, we have a set of rows, indexed without any gaps, and the primary
key is not shown at all (unless someone looks at the URL). It doesn't
matter what the id is, as long as it always points to the correct row.

brian

attached mail follows:


At 12:08 PM -0400 9/4/07, Jason Pruim wrote:
>On Sep 4, 2007, at 7:15 AM, Satyam wrote:
>
>>I was wondering if people is asking this in the
>>belief that the autoincrement field is the
>>record position in the database table and that
>>by not reusing those positions, the space of
>>the deleted records is wasted. Perhaps when
>>they say renumbering what they are meaning is
>>compacting the database reusing the empty slots
>>they assume those autoincrement fields point
>>to. Someone remembers dBaseIII .dbf files?
>>Well, perhaps that is the picture they have in
>>mind.
>
>As the person who started the other thread about
>this, my big thing was having a continuous
>record number that I could display to the
>customer much the way excel displays record
>numbers.
>
>But after discussing it, I see where my thinking
>was wrong in how I wanted to achieve it, and
>also my misunderstanding of the way databases
>worked. I'm pretty new working with databases,
>and PHP. HTML and CSS I've done for awhile, just
>never needed a database or programming language
>until recently :)
>
>so to put my 2¢ in on this, I would say to leave
>alone the auto increment field especially if
>it's included in an index. If you need a record
>number, either store it in the database in a
>separate field as tedd suggested, and leave the
>main auto increment field alone. OR use PHP (Or
>your favorite programming language) to add a
>"Record number" to the display.
>
>Okay I'm done now :)

Jason:

Well, at least you read and comprehended what was
said -- that's better than some.

Cheers,

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

attached mail follows:


It was able to call up external includes using the below code which resulted
that the server was used to send out spam.
How can I protect the code?

TIA

<?php
session_start();
//--------------------------------------------------------------------------
---------------------
// index.php
//--------------------------------------------------------------------------
---------------------
include("../inc/const.php");
include("../inc/mysql.php");
 $menu=2;
include("../inc/static.php");
//include("../inc/prolog.php");
$base = getenv("SERVER_NAME").getenv("SCRIPT_NAME");
//$menu = $HTTP_GET_VARS['menu'];
$submenu_list = $HTTP_GET_VARS['submenu_list'];
$contfile = $HTTP_GET_VARS['contfile'];
$id = $HTTP_GET_VARS['id'];
$stk = $HTTP_GET_VARS['stk'];
$contpath = $HTTP_GET_VARS['contpath'];
if ($contpath=="")
{ $contpath="./"; }
?>
<html>
<head>
        <title>Neuer Wissenschaftlicher Verlag - <?php print
$typ_subnav[$menu]?></title>
        <script language="javascript" SRC="../js/rollover.js"></script>
        <link rel="stylesheet" href="../css/bor.css">
</head>

<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0"
marginwidth="0" link="#006666" vlink="#006666" alink="#006666">

<table height="100%" width="100%" topmargin="0" cellspacing="0"
cellpadding="0" border="0">

<tr valign="top" height="105">
    <td colspan="3" valign="top">
        <? include("../inc/prolog.php");?>
    </td>
</tr>
<tr valign="top" height="30">
    <td valign="top" height="30"
background="../../img_pool/bg_left_right.gif"><?
include("../inc/leftmenu.php");?></td>
    <td width="100%">&nbsp;</td>
    <!-- hier ist die rechte spalte mit dem background -->
    <!-- <td height="30" background="../../img_pool/bg_left_right.gif"><img
src="../img/trans.gif" width="180" height="1"></td> -->
</tr>
<tr valign="top">
        <td valign="top" background="../../img_pool/bg_left_right.gif"><?php
nav_menupic($menu);?>
            <?php
 
//--------------------------------------------------------------------------
--------------
          // Subnavigation
 
//--------------------------------------------------------------------------
--------------
                include("../inc/subnav.php");
                ?>
         </td>

<!-- END LEFT-NAV -->
     <td valign="top">
     <?php include($contpath . "/content.php");?>
<!-- END CONTENT -->
     </td>
     
     <?//php include("../inc/epilog.php");
     ?>

  </tr>
 </table>
 
 </body>
 
</html>

attached mail follows:


Karl,

Some simple checks on $contpath could solve your problem. Make sure that:

 - it doesn't start with a /
 - doesn't contain /../
 - it doesn't contain a double slash //, or make sure the URL Fopen wrapper
is disabled:
http://nl3.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen

Usually $contpath = str_replace('/', '', $contpath); takes care of
everything.

On 04/09/07, Karl-Heinz Schulz <karlheinzkhschulz.com> wrote:
>
> It was able to call up external includes using the below code which
> resulted that the server was used to send out spam.
>
> How can I protect the code?
>
> TIA
>
> <?php
>
> session_start();
>
>
> //-----------------------------------------------------------------------------------------------
>
> // index.php
>
>
> //-----------------------------------------------------------------------------------------------
>
> include("../inc/const.php");
>
> include("../inc/mysql.php");
>
> $menu=2;
>
> include("../inc/static.php");
>
> //include("../inc/prolog.php");
>
> $base = getenv("SERVER_NAME").getenv("SCRIPT_NAME");
>
> //$menu = $HTTP_GET_VARS['menu'];
>
> $submenu_list = $HTTP_GET_VARS['submenu_list'];
>
> $contfile = $HTTP_GET_VARS['contfile'];
>
> $id = $HTTP_GET_VARS['id'];
>
> $stk = $HTTP_GET_VARS['stk'];
>
> $contpath = $HTTP_GET_VARS['contpath'];
>
> if ($contpath=="")
>
> { $contpath="./"; }
>
> ?>
>
> <html>
>
> <head>
>
> <title>Neuer Wissenschaftlicher Verlag - <?php print
> $typ_subnav[$menu]?></title>
>
> <script language="javascript" SRC="../js/rollover.js"></script>
>
> <link rel="stylesheet" href="../css/bor.css">
>
> </head>
>
> <body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0"
> marginwidth="0" link="#006666" vlink="#006666" alink="#006666">
>
> <table height="100%" width="100%" topmargin="0" cellspacing="0"
> cellpadding="0" border="0">
>
> <tr valign="top" height="105">
>
> <td colspan="3" valign="top">
>
> <? include("../inc/prolog.php");?>
>
> </td>
>
> </tr>
>
> <tr valign="top" height="30">
>
> <td valign="top" height="30"
> background="../../img_pool/bg_left_right.gif"><?
> include("../inc/leftmenu.php");?></td>
>
> <td width="100%">&nbsp;</td>
>
> <!-- hier ist die rechte spalte mit dem background -->
>
> <!-- <td height="30"
> background="../../img_pool/bg_left_right.gif"><img src="../img/trans.gif"
> width="180" height="1"></td> -->
>
> </tr>
>
> <tr valign="top">
>
> <td valign="top"
> background="../../img_pool/bg_left_right.gif"><?php nav_menupic($menu);?>
>
> <?php
>
>
> //----------------------------------------------------------------------------------------
>
> // Subnavigation
>
>
> //----------------------------------------------------------------------------------------
>
> include("../inc/subnav.php");
>
> ?>
>
> </td>
>
> <!-- END LEFT-NAV -->
>
> <td valign="top">
>
> <?php include($contpath . "/content.php");?>
>
> <!-- END CONTENT -->
>
> </td>
>
>
>
> <?//php include("../inc/epilog.php");
>
> ?>
>
> </tr>
>
> </table>
>
>
>
> </body>
>
>
>
> </html>
>
>

--
Interpotential.com
Phone: +31615397471

attached mail follows:


Message-ID: <EC.21.21414.2885DD64pb1.pair.com>
To: php-generallists.php.net
Date: Tue, 04 Sep 2007 10:07:26 -0300
From: zerof <zerofterra.com.br>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Subject: Re: Generating foldout menus in php

Arno Kuhl escreveu:
> This may not be directly php related but I'm hoping that generating the code
> with PHP will keep it on topic.
>
> I'm looking for a way to generate dropdown/foldout menus (horizontal and
> vertical) on the fly, but all the javascript solutions I've seen use
> absolute or relative pixel positioning, which means I can't use them because
> I don't know at the time of generating a specific menu item how many pixels
> across or down the preceding items have already used. I'm currently using a
> javascript menu that works really well, but all the top-level menu items
> have to be preset with specific x-y pixel coordinates, and all the
> subsequent items are then relative to the top-level items. So I can generate
> the second-level and subsequent items on the fly but not the top-level
> items. Is there a way to use css or dhtml or something else (maybe something
> in javascript that I missed) to do this?
>
> Thanks
> Arno
--------------------
http://phplayersmenu.sourceforge.net/

http://labs.adobe.com/technologies/spry/
--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
----------------------------------------------------------
You must hear, always, one second opinion! In all cases.
----------------------------------------------------------
Let the people know if this info was useful for you!
----------------------------------------------------------

attached mail follows:


> What I want to to do is insert a new <td> after showing 5 thumb images, and
> continue with the next picture on the next row.
> something like this
> __________________________
> |pic1 | pic2 | pic3 | pic4 | pic5 |
> __________________________
> |pic6 | pic7 | pic8 | pic9 | pic10 |
> __________________________
> |pic11 | pic12 | pic13 |
> __________________

You need to use the math function: modulo.

$MaxRows = 5;
for(.......){
  $m = fmod($ImageNumber, $MaxRows);
  if($m == 0){ echo "<tr>"; }
  echo "<td>";
  // [...] content of cell here
  echo "</td>";
  if($m == ($MaxRows-1)){ echo "</tr>"; }
}

Have fun!
Simon

attached mail follows:


At 6:18 PM -0400 9/3/07, brian wrote:
>>Renumbering anything is pretty quick these days. To me, things that
>>are "horribly inefficient" are also slow. So, I don't agree. If I
>>remember correctly, I can even renumber a 100K item dB
>>auto_increment index in less than one second -- but I wouldn't
>>recommend it. I think that's pretty quick.
>>
>
>It may be just fine in your case, but from a DB design standpoint it
>most certainly is not efficient. Why re-order the entire table for
>something like this? Altering an entire table because one row has
>been deleted suggests to me that the schema needs to revisited.

 From a technical standpoint, I agree with you. It's far better to let
the records fall as they may according to the sort, whatever that may
be.

However, we (or at least I) often work with clients who don't see
that. Instead they see records that they place into their database
that hold information about their widgets and they like to see a
record number associated with their widget. And, when they add a new
widget record, they want to see that count increased and when they
delete a widget record they want to see it gone and a gap, where they
can renumber at their will.

This makes no difference to me, I can do anything they want. But the
point is that customers usually not don't know the finer points to
what "should" or "should-not" be done, but rather they way they think
things should be done. Understand? After all, it's their business --
not ours.

Our charge is to provide them with as much correct information as
they can absorb and then do just what they want beyond that.

Believe me, arguing with clients about how things should be done has
it's limits. At some point, you just have to listen and do what they
want in spite of what is optimal.

>>Presentation is made during presentation, obviously, by using css
>>and proper html and pulling data from your dB to assemble
>>presentation. If the client wants Roman notation, it's a simple
>>process to provide that.
>
>So now you want to rewrite your triggers to use Roman notation? I
>wasn't aware that MySQL had such terrific Roman numeral math support.

I rewrite stuff all the time to make the presentation exactly what
the client expects. Roman numeral math support is really a no brainer
to create -- that's comp 101 sruff.

>>There is no "separating data and presentation" in this issue.
>
>I don't buy that. Doing it that way is attaching unnecessary
>presentation-specific baggage to your data. The column is only as
>relational as it was the last time it changed. That is, it was
>pointing to a completely different record then. This isn't a
>"separating data and presentation" issue?

We are disagreeing if having a record number is necessary or not?
 From my perspective, if it is left up to me -- it's unnecessary and
my dB's don't have any. However, if the client wants it, then the
client get's it and it then becomes necessary.

As for relational, I'm not talking about a relational dB field, but
rather a simple record that the client can imagine. Relational fields
are used to present the record, they certainly would not be involved
in any renumbering schemes -- don't you see what I am talking about?

Cheers,

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

attached mail follows:


Surely we're into basic database design. If you have an auto_increment
record key that needs changing from time to time then you've designed
the database incorrectly. Use a 'normal' key field such as
"Product_Id" and have your application generate the number.

Simple.

No?

On 9/4/07, tedd <teddsperling.com> wrote:
> At 6:18 PM -0400 9/3/07, brian wrote:
> >>Renumbering anything is pretty quick these days. To me, things that
> >>are "horribly inefficient" are also slow. So, I don't agree. If I
> >>remember correctly, I can even renumber a 100K item dB
> >>auto_increment index in less than one second -- but I wouldn't
> >>recommend it. I think that's pretty quick.
> >>
> >
> >It may be just fine in your case, but from a DB design standpoint it
> >most certainly is not efficient. Why re-order the entire table for
> >something like this? Altering an entire table because one row has
> >been deleted suggests to me that the schema needs to revisited.
>
> From a technical standpoint, I agree with you. It's far better to let
> the records fall as they may according to the sort, whatever that may
> be.
>
> However, we (or at least I) often work with clients who don't see
> that. Instead they see records that they place into their database
> that hold information about their widgets and they like to see a
> record number associated with their widget. And, when they add a new
> widget record, they want to see that count increased and when they
> delete a widget record they want to see it gone and a gap, where they
> can renumber at their will.
>
> This makes no difference to me, I can do anything they want. But the
> point is that customers usually not don't know the finer points to
> what "should" or "should-not" be done, but rather they way they think
> things should be done. Understand? After all, it's their business --
> not ours.
>
> Our charge is to provide them with as much correct information as
> they can absorb and then do just what they want beyond that.
>
> Believe me, arguing with clients about how things should be done has
> it's limits. At some point, you just have to listen and do what they
> want in spite of what is optimal.
>
>
> >>Presentation is made during presentation, obviously, by using css
> >>and proper html and pulling data from your dB to assemble
> >>presentation. If the client wants Roman notation, it's a simple
> >>process to provide that.
> >
> >So now you want to rewrite your triggers to use Roman notation? I
> >wasn't aware that MySQL had such terrific Roman numeral math support.
>
> I rewrite stuff all the time to make the presentation exactly what
> the client expects. Roman numeral math support is really a no brainer
> to create -- that's comp 101 sruff.
>
> >>There is no "separating data and presentation" in this issue.
> >
> >I don't buy that. Doing it that way is attaching unnecessary
> >presentation-specific baggage to your data. The column is only as
> >relational as it was the last time it changed. That is, it was
> >pointing to a completely different record then. This isn't a
> >"separating data and presentation" issue?
>
> We are disagreeing if having a record number is necessary or not?
> From my perspective, if it is left up to me -- it's unnecessary and
> my dB's don't have any. However, if the client wants it, then the
> client get's it and it then becomes necessary.
>
> As for relational, I'm not talking about a relational dB field, but
> rather a simple record that the client can imagine. Relational fields
> are used to present the record, they certainly would not be involved
> in any renumbering schemes -- don't you see what I am talking about?
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Graham

attached mail follows:


tedd wrote:
> At 6:18 PM -0400 9/3/07, brian wrote:
>
>> It may be just fine in your case, but from a DB design standpoint it
>> most certainly is not efficient. Why re-order the entire table for
>> something like this? Altering an entire table because one row has been
>> deleted suggests to me that the schema needs to revisited.
>
> ...
>
> However, we (or at least I) often work with clients who don't see that.
> Instead they see records that they place into their database that hold
> information about their widgets and they like to see a record number
> associated with their widget. And, when they add a new widget record,
> they want to see that count increased and when they delete a widget
> record they want to see it gone and a gap, where they can renumber at
> their will.

You are confusing a product ID with this index number. They are very
much not the same thing. A product ID (PLU, serial #, whatever) should
not change. This index does change, any time a row is removed from the
database. How can you suggest that this index can be "associated with
their widget" if the value can change at any time? There's no one-to-one
relationship between the widget and this index. At least, not over the
life of the widget's record in the database.

If your client wants a widget number, then, by all means, provide one.
But if you're going to rely on a figure that is liable to change at the
drop of a hat your database career will soon be over.

Again: the only relation this index contributes is destroyed just as
soon as row is removed. So why bother? An entire table should not need
to be re-ordered every time a row is removed in order to satisfy an
ill-conceived schema.

> This makes no difference to me, I can do anything they want. But the
> point is that customers usually not don't know the finer points to what
> "should" or "should-not" be done, but rather they way they think things
> should be done. Understand? After all, it's their business -- not ours.
>
> Our charge is to provide them with as much correct information as they
> can absorb and then do just what they want beyond that.
>
> Believe me, arguing with clients about how things should be done has
> it's limits. At some point, you just have to listen and do what they
> want in spite of what is optimal.

This is utterly beside the point. So, give your widgets a product ID.
That's obvious. But, why would you want all of your widgets to assume a
new product ID just because one widget has been taken out of production?
Try to explain that to the client when absolutely nothing operates
correctly because none of the widgets has the correct ID.

Again: this index you are proposing cannot be a product ID because it
changes all the time.

>> I don't buy that. Doing it that way is attaching unnecessary
>> presentation-specific baggage to your data. The column is only as
>> relational as it was the last time it changed. That is, it was
>> pointing to a completely different record then. This isn't a
>> "separating data and presentation" issue?
>
> We are disagreeing if having a record number is necessary or not? From
> my perspective, if it is left up to me -- it's unnecessary and my dB's
> don't have any. However, if the client wants it, then the client get's
> it and it then becomes necessary.

I think we are disagreeing with fundamental tenets of database schema
design. But whatever ...

> As for relational, I'm not talking about a relational dB field, but
> rather a simple record that the client can imagine. Relational fields
> are used to present the record, they certainly would not be involved in
> any renumbering schemes -- don't you see what I am talking about?

No

brian

attached mail follows:


I need to program a socket server in PHP that can use a
certificate and communicate over SSL. I'm doing fine without
SSL. Can't use port 443 or the web server for this, so it
needs to be a command line app. Can't seem to find any
documentation about how to set that up. Can anyone help or
point me in the right direction?

TIA,
Paul W

attached mail follows:


Hi all,

I have a function which is my callback for preg_replace_callback - and it
needs to be able to access a string and an object outside of itself.
When I call create_function I can insert the string, but without serializing
the object I can't figure out how to make it available to the function
without making it global, which seems nasty.

I've tried 'currying' the function - creating a new function out of it with
the string and object parameters bound, but have the same problem - I can't
get the object into the function.
Can anyone point me towards a good solution? I guess I could also create a
class with the one function, but that seems a wee bit messy to me.

Any ideas?

--
Rob Desbois
Eml: rob.desboisgmail.com

attached mail follows:


Message-ID: <46DD9E86.5090501phpguru.org>
Date: Tue, 04 Sep 2007 19:05:58 +0100
From: Richard Heyes <richardhphpguru.org>
Reply-To: richardhphpguru.org
MIME-Version: 1.0
To: Rob Desbois <rob.desboisgmail.com>
CC: PHP List <php-generallists.php.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Subject: Re: [PHP] Bind function parameters with create_function ('currying')

> I have a function which is my callback for preg_replace_callback - and it
> needs to be able to access a string and an object outside of itself.
> When I call create_function I can insert the string, but without serializing
> the object I can't figure out how to make it available to the function
> without making it global, which seems nasty.
>
> I've tried 'currying' the function - creating a new function out of it with
> the string and object parameters bound, but have the same problem - I can't
> get the object into the function.
> Can anyone point me towards a good solution? I guess I could also create a
> class with the one function, but that seems a wee bit messy to me.

It would be helpful if you could post a bare-bones example.

--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

attached mail follows:


Rob/mlists

You're certainly not encouraging PHP programmers to get involved with
paid open source projects. That's a guaranteed $50,000 a yr, a little
low perhaps by industry standards, but it is a reasonable starting rate,
and gets your foot in the door.

You should have a look at who the employer is, and what they do. They
(we) are
looking for a person who has done their research. This is more than
just a job. It has the potential to introduce applicants to a world of
experience, not just code crunching, but getting involved with the
groups who introduce new technologies and working on leading edge
projects (groups like the W3C, IMS, ISO, AICC, and many others) .
Experiences you won't get as a programmer for your average software
developer. The ATRC is involved with most standards bodies around the
world, and has dozen of open source projects on the go.

Becoming university staff takes a couple years, after which salaries are
competivitive with the going rates. Not to mention a full set of
benefits, pension, excellent working environment, including flexible
working hours, travel benefits, free university course (get a masters or
phd for nothing) etc. Most staff start on a casual/contract basis before
being moved into the main stream. Our established programmers do earn in
the 90-100G per year, with benefits on top of that. All included, that's
somewhere in the $60/hr range, with $0 expenses.

You're auto machanic btw, has overhead included in that rate, so that's
a rather poor comparison. How much do you think he really makes an hour,
after paying expenses out of that $99? And of course 4% isn't a bonus.
Contract workers are paid that weekly, while staff accumulate it so they
can take holidays and get paid.

greg

Robert Cummings wrote:
> On Mon, 2007-09-03 at 13:47 -0400, mlists wrote:
>
>>Wow!
>>
>>Spend $100K on a university degree in computer science, work
>>successfully for five years with all the major technologies, and then
>>get paid $25 per hour?
>
>
> The poster didn't mention anything about being competent.
>
>
>>My auto mechanic charges an average of $99 per hour.
>>
>>Sounds like a great deal for the university. Maybe the successful
>>candidate can work off his student loans.
>
>
> Well 100k is a bit high for a 4 year program. And then again it depends
> on whether you had to move away from your parents to attend university.
> If you live within commute range of your university then you can get
> away with 20 to 30k expenses in Canada (depending on University). If you
> have to cover rent then it's a different story :) That said, Toronto is
> one of the most expensive cities in Canada in which to live. IMHO he
> still thinks the tech sector is in a depression and developers with 5
> years experience can be had for a pittance. What made me laugh was the
> "4%" vacation pay. That's a legal requirement in Canada for full time
> employment. Not a bonus.
>
> Cheers,
> Rob.

attached mail follows:


On Tue, 2007-09-04 at 14:28 -0400, Greg Gay wrote:
> Rob/mlists
>
> You're certainly not encouraging PHP programmers to get involved with
> paid open source projects. That's a guaranteed $50,000 a yr, a little
> low perhaps by industry standards, but it is a reasonable starting rate,
> and gets your foot in the door.
>
> You should have a look at who the employer is, and what they do. They
> (we) are
> looking for a person who has done their research. This is more than
> just a job. It has the potential to introduce applicants to a world of
> experience, not just code crunching, but getting involved with the
> groups who introduce new technologies and working on leading edge
> projects (groups like the W3C, IMS, ISO, AICC, and many others) .
> Experiences you won't get as a programmer for your average software
> developer. The ATRC is involved with most standards bodies around the
> world, and has dozen of open source projects on the go.
>
> Becoming university staff takes a couple years, after which salaries are
> competivitive with the going rates. Not to mention a full set of
> benefits, pension, excellent working environment, including flexible
> working hours, travel benefits, free university course (get a masters or
> phd for nothing) etc. Most staff start on a casual/contract basis before
> being moved into the main stream. Our established programmers do earn in
> the 90-100G per year, with benefits on top of that. All included, that's
> somewhere in the $60/hr range, with $0 expenses.
>
> You're auto machanic btw, has overhead included in that rate, so that's
> a rather poor comparison. How much do you think he really makes an hour,
> after paying expenses out of that $99? And of course 4% isn't a bonus.
> Contract workers are paid that weekly, while staff accumulate it so they
> can take holidays and get paid.

See, now that's a much better job post. Although it's still $25/hr after
5 years of experience on a contract basis with no guarantee of future
contracts with good performance. As a contractor one generally charges
more to cover the dry times, self-development, dental, prescriptions,
retirement, etc, etc. It's not about being greedy, well not for me
anyways, it's about covering one's ass in the present and in the future.
Have you ever seen the way it usually works in government and any other
large businesses... contractors earn more per hour than the regular
employees, that's because they need to. Contractors often can't just
jump onto any job with stars in their eyes hoping to get a hold of a
"maybe" brass ring several years down the road.

Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

attached mail follows:


I'm setting up a site and am having loads of problems with MySQL (which
i don't use much, being a Postgres fan). The server is not controlled by
myself and I'm waiting on a reply from the admin. In the meantime:

PHP 4.3.9
Mysql 4.1.10a (server) 3.23.49 (client)

The database has been set up along with PHPMyAdmin (i also rarely use
this). I have been provided with a user & pass for PHPMyAdmin, as well
as a user & pass for the DB. Using the former, i have created the tables
and copied in my data. Within that interface, i can make any query i'd like.

However, from within a PHP script (and using the second user & pass), i
seem to be SOL. Even the most basic queries return empty results.
Debugging has been a royal pain because interfaces such as MDB2, DB,
etc. are also not available. That means relying on mysql_error() which
is frustrating.

After much dicking around, i've come to the conclusion that the problem
must be that the user does not have permission to select from the DB. A
comment on the mysql_error() manual page [1] says that, in the case of
"Access denied ..." mysql_error() returns the empty string.

I feel like i've taken crazy pills! Please, someone tell me this isn't
true! How does one debug a problem like this? How can i know if i have
SELECT rights to the table?

[1] http://ca3.php.net/manual/en/function.mysql-error.php#44168

brian

attached mail follows:


brian wrote:
> I'm setting up a site and am having loads of problems with MySQL (which
> i don't use much, being a Postgres fan). The server is not controlled by
> myself and I'm waiting on a reply from the admin. In the meantime:
>
> PHP 4.3.9
> Mysql 4.1.10a (server) 3.23.49 (client)
>
> The database has been set up along with PHPMyAdmin (i also rarely use
> this). I have been provided with a user & pass for PHPMyAdmin, as well
> as a user & pass for the DB. Using the former, i have created the tables
> and copied in my data. Within that interface, i can make any query i'd
> like.
>
> However, from within a PHP script (and using the second user & pass), i
> seem to be SOL. Even the most basic queries return empty results.
> Debugging has been a royal pain because interfaces such as MDB2, DB,
> etc. are also not available. That means relying on mysql_error() which
> is frustrating.
>
> After much dicking around, i've come to the conclusion that the problem
> must be that the user does not have permission to select from the DB. A
> comment on the mysql_error() manual page [1] says that, in the case of
> "Access denied ..." mysql_error() returns the empty string.
>
> I feel like i've taken crazy pills! Please, someone tell me this isn't
> true! How does one debug a problem like this? How can i know if i have
> SELECT rights to the table?
>
> [1] http://ca3.php.net/manual/en/function.mysql-error.php#44168

First, if you are having an access denied problem, you will get a PHP
error message. Perhaps you have errors turned off in your PHP script.
Turn them on until you get it working.

Second, you should be able to use phpMyAdmin to see what the permissions
are for the account you are using.

Janet

>
> brian
>

--
Janet Valade -- janet.valade.com

attached mail follows:


Janet Valade wrote:
>
> First, if you are having an access denied problem, you will get a PHP
> error message. Perhaps you have errors turned off in your PHP script.
> Turn them on until you get it working.

I forgot to mention that i've temporarily set:

ini_set('track_errors', TRUE); // to access $php_errormsg
error_reporting(E_ALL);

I've determined that i can, indeed, connect to the DB. It's selecting
from a table that *seems* to be the problem.

> Second, you should be able to use phpMyAdmin to see what the
> permissions are for the account you are using.

I poked around for that. Apparently, phpMyAdmin has a "Privileges" page
but i can't locate it. On the "operations" page, i find this at the bottom:

Error
The additional features for working with linked tables have been
deactivated. To find out why click here.

When i follow the link i get:

PMA Database ... not OK[ Documentation ]
General relation features Disabled

David Giragosian wrote:
> use your phpmyadmin account to get the permissions for the second
> username/password login.
>
> Show grants for usernameyourhostname;
>

Argh! It's always the simple things one forgets to do, isn't it?

GRANT USAGE ON *.* TO ...
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP...

So, i'm back to square one, i see.

brian

attached mail follows:


Hello,
 i need a good php debugger. It should provide the facility of step by step
execution in real time.
Is there any?
Do any of you know about this?
I am having a bug. I can't trace where it is.

--
shout at http://shiplu.awardspace.com/

Available for Hire/Contract/Full Time

attached mail follows:


Mime-Version: 1.0 (Apple Message framework v752.3)
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
Message-Id: <082DBE65-1CF4-476B-A199-0667C6D6DC79ericgorr.net>
Cc: "PHP General" <php-generallists.php.net>
Content-Transfer-Encoding: 7bit
From: Eric Gorr <mailistericgorr.net>
Date: Tue, 4 Sep 2007 17:35:32 -0400
To: shiplu <shiplu.netgmail.com>
Subject: Re: [PHP] PHP Debugger

I would suggest taking a look at Zend Studio.

http://www.zend.com/products/zend_studio

On Sep 4, 2007, at 5:28 PM, shiplu wrote:

> Hello,
> i need a good php debugger. It should provide the facility of step
> by step
> execution in real time.
> Is there any?
> Do any of you know about this?
> I am having a bug. I can't trace where it is.
>
> --
> shout at http://shiplu.awardspace.com/
>
> Available for Hire/Contract/Full Time

attached mail follows:


ive been working with xdebug <http://xdebug.org/>lately.
you wont find me paying for zend studio;
im on the open source tip :)

i must admit though, the experience has been anything but painless.
however, if you work w/ legacy spaghetti code, or youre just sick
of writing echo statements on the server,
xdebug is definitely worth trying.

so far ive worked w/ protoeditor and eclipse pdt. they both have pros / and
cons
but im already used to the eclipse environment, so ill probly settle on pdt.

-nathan
On 9/4/07, Eric Gorr <mailistericgorr.net> wrote:
>
> I would suggest taking a look at Zend Studio.
>
>
> http://www.zend.com/products/zend_studio
>
>
> On Sep 4, 2007, at 5:28 PM, shiplu wrote:
>
> > Hello,
> > i need a good php debugger. It should provide the facility of step
> > by step
> > execution in real time.
> > Is there any?
> > Do any of you know about this?
> > I am having a bug. I can't trace where it is.
> >
> > --
> > shout at http://shiplu.awardspace.com/
> >
> > Available for Hire/Contract/Full Time
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


  • application/x-pkcs7-signature attachment: smime.p7s