php-general Digest 21 Sep 2007 20:41:14 -0000 Issue 5031

Topics (messages 262331 through 262352):

[SOLVED] Re: [PHP] disappearing array?
        262331 by: Jas

Font size of text that will be written using php pack function
        262332 by: rdpweb

Upgrade
        262333 by: Ed Curtis
        262335 by: Zoltán Németh
        262340 by: Ben
        262341 by: Ed Curtis
        262342 by: Robert Cummings
        262344 by: Nathan Nobbe

Re: Working with XML: DomDocument or SimpleXML?
        262334 by: Rob
        262336 by: Colin Guthrie
        262337 by: Rob
        262338 by: Colin Guthrie

Re: php personal project
        262339 by: Philip Thompson

Limiting connection to mysql using old mysql module (not mysqli)
        262343 by: Stefano Esposito
        262352 by: Stut

Working with sessions
        262345 by: Jason Pruim
        262346 by: Jay Blanchard
        262347 by: Jason Pruim
        262348 by: Jay Blanchard
        262349 by: Jason Pruim

List Help - Email Change
        262350 by: Andrew Prostko
        262351 by: Per Jessen

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Found the problem. I had a typo on my conditional statement.

if( $fix->ValArray( $_POST['add_order_items'] === -1 ) ) {
 $errors['add_order_array'] = $erlink;
}

Should have been:
if( $fix->ValArray( $_POST['add_order_items'] ) === -1 ) {
 $errors['add_order_array'] = $erlink;
}

My eyes need to be checked or start exercising my fat fingers.


Instruct ICC wrote:
> Wow this formatted badly.  (new hotmail on Safari -- MS made FF not even 
> render well)
> 
> Anyway, are you sure you are reaching the code you want to reach?
> Perhaps !== is overkill and maybe even wrong when you should use ==.
> 
> Same with the other === usage?
> 
> Try some
> echo "HERE1\n";
> echo "HERE2\n";
> to see if you are getting to the line you expect.  Like after that "count(~) 
> !== ".
> 
> _________________________________________________________________
> Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our way 
> of saying thanks for using Windows Live™.
> http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2

--- End Message ---
--- Begin Message ---
Hi All
I am just converting the data from database to excel format.For that i am
using pack function of php . But i want some data to be in bold like
Employee Name = ABC
How to do that .Will anybody help me
-- 
View this message in context: 
http://www.nabble.com/Font-size-of-text-that-will-be-written-using-php-pack-function-tf4493862.html#a12816141
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message --- I'm currently running Debian Woody with PHP 4.1.2 installed by default. It's really stable and I like it alot. Would I run into any problems upgrading it to say 4.3.0. There are some functions I need in it that 4.1.2 doesn't have. I'm not ready to make the jump to PHP5 yet. I've tried it on a test server and have run into a couple of problems with the upgrade.

Thanks,

Ed

--- End Message ---
--- Begin Message ---
2007. 09. 21, péntek keltezéssel 08.16-kor Ed Curtis ezt írta:
> I'm currently running Debian Woody with PHP 4.1.2 installed by default. 
> It's really stable and I like it alot. Would I run into any problems 
> upgrading it to say 4.3.0. There are some functions I need in it that 
> 4.1.2 doesn't have. I'm not ready to make the jump to PHP5 yet. I've 
> tried it on a test server and have run into a couple of problems with 
> the upgrade.

I really don't think you should upgrade to 4.3.0 instead of going php5.
All versions of php4 are discontinued from the end of this year, see
php.net
If you insist on 4.3.0, I don't know of any problems with upgrading to
it, but pay attention to all the extensions - upgrade them also if
needed, etc...

greets
Zoltán Németh

> 
> Thanks,
> 
> Ed
> 

--- End Message ---
--- Begin Message ---
It really depends on your situation. 
We are an ISP hosting lots of website. Upgrading from 4 to 5 means a lot of 
sites will have trouble. 
Personally I have some problem of upgrading from 4 to 5. 

The below codes work on 4:

include("DB/DataObjects.php");
$pro = DB_DataObject::factory('Product');
$pro->find();
while($pro->fetch())
   $allPro[] = $pro;  

But on 5, it has to be modified to
include("DB/DataObjects.php");
$pro = DB_DataObject::factory('Product');
$pro->find();
while($pro->fetch())
   $allPro[] = clone $pro;  

The above is only an example. So upgrading to 5 is not an option for us.

--
Ben
Web Design Shropshire, Software programing
http://www.sparkcomputing.co.uk

On Friday 21 Sep 2007 13:43, Zoltán Németh wrote:
> 2007. 09. 21, péntek keltezéssel 08.16-kor Ed Curtis ezt írta:
> > I'm currently running Debian Woody with PHP 4.1.2 installed by default. 
> > It's really stable and I like it alot. Would I run into any problems 
> > upgrading it to say 4.3.0. There are some functions I need in it that 
> > 4.1.2 doesn't have. I'm not ready to make the jump to PHP5 yet. I've 
> > tried it on a test server and have run into a couple of problems with 
> > the upgrade.
> 
> I really don't think you should upgrade to 4.3.0 instead of going php5.
> All versions of php4 are discontinued from the end of this year, see
> php.net
> If you insist on 4.3.0, I don't know of any problems with upgrading to
> it, but pay attention to all the extensions - upgrade them also if
> needed, etc...
> 
> greets
> Zoltán Németh
> 
> > 
> > Thanks,
> > 
> > Ed
> > 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

--- End Message ---
--- Begin Message ---
Ben wrote:
It really depends on your situation. We are an ISP hosting lots of website. Upgrading from 4 to 5 means a lot of sites will have trouble. Personally I have some problem of upgrading from 4 to 5.
The below codes work on 4:

include("DB/DataObjects.php");
$pro = DB_DataObject::factory('Product');
$pro->find();
while($pro->fetch())
$allPro[] = $pro;
But on 5, it has to be modified to
include("DB/DataObjects.php");
$pro = DB_DataObject::factory('Product');
$pro->find();
while($pro->fetch())
$allPro[] = clone $pro;
The above is only an example. So upgrading to 5 is not an option for us.

--
Ben
Web Design Shropshire, Software programing
http://www.sparkcomputing.co.uk

Thanks, I did find a way to do what I needed to do and not have to upgrade. There are more system calls but it won't be used often enough to worry about.

Ed

--- End Message ---
--- Begin Message ---
On Fri, 2007-09-21 at 16:18 +0100, Ben wrote:
> It really depends on your situation. 
> We are an ISP hosting lots of website. Upgrading from 4 to 5 means a lot of 
> sites will have trouble. 
> Personally I have some problem of upgrading from 4 to 5. 
> 
> The below codes work on 4:
> 
> include("DB/DataObjects.php");
> $pro = DB_DataObject::factory('Product');
> $pro->find();
> while($pro->fetch())
>    $allPro[] = $pro;  
> 
> But on 5, it has to be modified to
> include("DB/DataObjects.php");
> $pro = DB_DataObject::factory('Product');
> $pro->find();
> while($pro->fetch())
>    $allPro[] = clone $pro;  
> 
> The above is only an example. So upgrading to 5 is not an option for us.

You might want to start a migration path for your code in the near
future. i would suggest something like the following:

<?php

# File: myLib.php

function &myClone( &$someObject )
{
    static $init = true;

    if( $init )
    {
        if( (int)phpversion() < 5 )
        {
            require_once( 'php4Compat.php' );
        }
        else
        {
            require_once( 'php5Compat.php' );
        }
    }

    $clone = &compat_myClone( $someObject );
    return $clone;
}

# File: php4Compat.php

function &compat_myClone( &$someObject )
{
    $clone = $someObject;
    return $clone;
}

# File: php5Compat.php

function &compat_myClone( &$someObject )
{
    $clone = clone $someObject;
    return $clone;
}

?>

This way you can still use PHP4 while providing the necessary changes
for PHP5 before fully switching over.

Cheers,
Rob.

Ps. I used references so PHP4 wouldn't create copies at every
    function call :)
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

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

--- End Message ---
--- Begin Message ---
On 9/21/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
>
> Ps. I used references so PHP4 wouldn't create copies at every
>     function call :)



i noticed the previously posted php4 code was doing a lot of copy
operations.
perhaps thats the only reason the code is actually working under 4 and the
clone keyword needed to be used in 5 (didnt look into it too much tho).
i always use the =& construct when assigning object references in php4.
this is another one of the sore spots i have for php4.  the reason being
php4
requires developers to use the =& construct so that a copy is not created.
i like to think the people i work w/ are competent, but less face it, in
large systems
w/ lots of developers, its hard to ensure =& is always being used.
in fact, in php4 singletons break if =& is not used.  that makes singleton
in php4
very delicate.

-nathan

--- End Message ---
--- Begin Message ---
Colin Guthrie wrote:

<snip />

I know I definitely want to do XSLT stuff and for that I need to use
DomDocument (I'm sure there are other ways but this works fine for me so
far!).

Fairly unknown tidbit: you can pass SimpleXML objects to the XSL extension. XSL will use the document from it.

<snip />

I'll phrase it better: one can easily convert a SimpleXML object to a
DomDocument[1], but nothing is "free" (in terms of time taken and memory
requirements etc.), so really I guess I want to ask if the trade off of
the simplicity of working with SimpleXML is worth it considering the
overhead of the conversion process to a DomDocument for subsequent XSLT
transforms etc?

Conversion is easy and the time/memory is negligible due to how the interoperability was designed. The whole purpose of it is so you can go back and forth to use whichever API suits you need at the time.

    if ($xml instanceof SimpleXMLElement)
    {
      $rv = new DOMDocument('1.0', 'utf-8');
      $node = dom_import_simplexml($xml);
      $node = $rv->importNode($node, true);
      $rv->appendChild($node);
      return $rv;
    }

Why??? If you really want a DOMDocument object why are you creating a new document, copying nodes and incurring all the additional overhead?

if ($xml instanceof SimpleXMLElement)
{
   /* No copying, just use the existing XML tree directly */
   $node = dom_import_simplexml($xml);
   return $node->ownerDocument;
}

--- End Message ---
--- Begin Message ---
Rob wrote:
> Fairly unknown tidbit: you can pass SimpleXML objects to the XSL
> extension. XSL will use the document from it.

Nice to know... /me will have to experiment!

>>     if ($xml instanceof SimpleXMLElement)
>>     {
>>       $rv = new DOMDocument('1.0', 'utf-8');
>>       $node = dom_import_simplexml($xml);
>>       $node = $rv->importNode($node, true);
>>       $rv->appendChild($node);
>>       return $rv;
>>     }
> 
> Why??? If you really want a DOMDocument object why are you creating a
> new document, copying nodes and incurring all the additional overhead?
> 
> if ($xml instanceof SimpleXMLElement)
> {
>    /* No copying, just use the existing XML tree directly */
>    $node = dom_import_simplexml($xml);
>    return $node->ownerDocument;
> }

Yeah I had that initially too but that did not produce a DOMDocument
Object but a DOMNode Object (or something like that.... will have to
test again as memory is corrupted - there /was/ a reason, and stupid me
didn't comment the code.....).

Col

--- End Message ---
--- Begin Message ---
Colin Guthrie wrote:
Rob wrote:

if ($xml instanceof SimpleXMLElement)
{
   /* No copying, just use the existing XML tree directly */
   $node = dom_import_simplexml($xml);
   return $node->ownerDocument;
}

Yeah I had that initially too but that did not produce a DOMDocument
Object but a DOMNode Object (or something like that.... will have to
test again as memory is corrupted - there /was/ a reason, and stupid me
didn't comment the code.....).

It had to have been for some other reason as the return type for the above example is a DOMDocument. A raw DOMNode is *NEVER* returned from the DOM extension. It is simply a base class for most of the DOM classes, such as DOMDocument.

Rob

--- End Message ---
--- Begin Message ---
Rob wrote:
> It had to have been for some other reason as the return type for the
> above example is a DOMDocument. A raw DOMNode is *NEVER* returned from
> the DOM extension. It is simply a base class for most of the DOM
> classes, such as DOMDocument.

I think I just didn't do the ->ownerDocument or something daft like that
in the past. This is great (still need to test but I trust you!) as it
means we can work happily with either model quite happily (for two
reasons if you can just pass the SimpleXML object straight into the XSLT
stuff!!)

Cheers

Col

--- End Message ---
--- Begin Message ---
On 9/21/07, Karl james <[EMAIL PROTECTED]> wrote:
>
> Team,
>
>
> I am in need of some help.
>
> I would love to get some assistance on this.
>
> I need to start creating a database for my website.
>
> This will be for a fantasy football league website.
>
> To store stats on the database for archive purposes,
>
> And be able to pull them out on html reports.



Why reinvent the wheel when there are well-developed apps from Yahoo, ESPN
and other places? Just want the experience?

--- End Message ---
--- Begin Message ---
Hi all,

i'm in need to limit the numbers of conection to the database, whithout loose 
of functionality.
There is a general strategy to achieve this?

--
Stefano Esposito
 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Insoddisfatto del tuo lavoro? Scopri come diventare Family Banker! 
* 
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7063&d=21-9

--- End Message ---
--- Begin Message ---
Stefano Esposito wrote:
i'm in need to limit the numbers of conection to the database, whithout loose 
of functionality.
There is a general strategy to achieve this?

1) Caching
2) Caching
3) Caching

And if all that fails...

4) Caching

Why do you need to reduce database connections? Is the site really busy enough to be legitimately maxing it out? Have you optimised the crap out of the database usage?

If the site really has reached the limit and you can't find any code optimisations then you need to look at adding more hardware. Assuming you've developed the site "properly" you shouldn't have any problems scaling it horizontally.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Hi Everyone,

I have a question about sessions, I am attempting to store a search term in a session variable to that when it finds the set of records from the database it can export it to excel. The problem I have is that the session variable is 1 search behind...

IE:
Search 1: Harry
Result 1: Nothing

Search 2: Bob
Result 2: Harry

Search 3: Larry
Result 3: Bob

Should I not be using a session variable to preform my search but instead use a local variable to do the actual search and then use the session variable to do the export?

Ugg... Session's are driving me crazy so far...

Thanks for looking!


--

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



--- End Message ---
--- Begin Message ---
[snip]
I have a question about sessions, I am attempting to store a search  
term in a session variable to that when it finds the set of records  
from the database it can export it to excel. The problem I have is  
that the session variable is 1 search behind...
[/snip]

When you do the search store the search term immediately to the session
variable;

<?php
//pseudo-code
start_session();
$_SESSION['searchTerm'] = $_GET['searchTerm'];
?>
<html>
<a href="link to excel sheet">
</html>

Now in the code that generates the excel;

<?php
session_start();
$getStuffForExcel = "SELECT foo, bar FROM data where foo =
'".$_SESSION['searchTerm']."' ";
?>

--- End Message ---
--- Begin Message ---

On Sep 21, 2007, at 2:26 PM, Jay Blanchard wrote:

[snip]
I have a question about sessions, I am attempting to store a search
term in a session variable to that when it finds the set of records
from the database it can export it to excel. The problem I have is
that the session variable is 1 search behind...
[/snip]

When you do the search store the search term immediately to the session
variable;

<?php
//pseudo-code
start_session();
$_SESSION['searchTerm'] = $_GET['searchTerm'];
?>
<html>
<a href="link to excel sheet">
</html>

Now in the code that generates the excel;

<?php
session_start();
$getStuffForExcel = "SELECT foo, bar FROM data where foo =
'".$_SESSION['searchTerm']."' ";
?>


Wouldn't that be what this code does:

<?PHP
        if ($_SESSION['search'] != NULL){
        echo "The search string is: <strong>$search</strong>.<BR>";
        $qrow[]= mysql_query($qstring) or die(mysql_error());
        $qresult = $qrow[0];
        $num_rows = mysql_num_rows($qresult);
        //display search form
                echo "
                        <form action='search.php' method='GET'>
                        <label>Search:
                        <input type='text' name='search' id='search' />
                        </label>
                        <input type='submit' value='Go!' />
                </form>";
$_SESSION['search'] = $_GET['search'];


?>

It also displays the search results on the same page and that display works just fine. Just the session variable that's messed up.

Thanks for looking though :)


--

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


--- End Message ---
--- Begin Message ---
[snip]
Wouldn't that be what this code does:

<?PHP
        if ($_SESSION['search'] != NULL){
        echo "The search string is: <strong>$search</strong>.<BR>";
        $qrow[]= mysql_query($qstring) or die(mysql_error());
        $qresult = $qrow[0];
        $num_rows = mysql_num_rows($qresult);
        //display search form
                echo "
                        <form action='search.php' method='GET'>
                        <label>Search:
                        <input type='text' name='search' id='search' />
                        </label>
                        <input type='submit' value='Go!' />
                </form>";
$_SESSION['search'] = $_GET['search'];


?>
[/snip]

Looks like it should if the form is referring to PHP_SELF (search.php).
Do you have a seesion_start() at the top of the page? 

--- End Message ---
--- Begin Message --- errrr... Never mind. Soon as I sent the e-mail I tried moving the $_SESSION['search'] = $_GET['search']; to the top just below the includes and it worked just fine! :)

I think my problem was the session variable was being displayed at the top of the page, and then stored after the form... providing the offset that it did.

Now to make the export like it! :)
--

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

--- End Message ---
--- Begin Message ---
I would like to change the email address this list is sending to,

I sent mail to '[EMAIL PROTECTED]' but I haven't received
anything back.

 

Can anyone tell me how to do this real quick?

Having this email account on my Treo is kind of overwhelming.

 

Andrew Prostko



1445 Washington Lane

West Chester, PA 19382-6871 USA

AProstko @ verizon.net

 

 


--- End Message ---
--- Begin Message ---
Andrew Prostko wrote:

> I would like to change the email address this list is sending to,
> 
> I sent mail to '[EMAIL PROTECTED]' but I haven't received
> anything back.
> 
> Can anyone tell me how to do this real quick?

1. unsubscribe old address.
2. subscribe new address. 

Really quick.


/Per Jessen, Zürich

--- End Message ---

Reply via email to