php-general Digest 27 May 2007 04:43:11 -0000 Issue 4813

Topics (messages 255679 through 255695):

Re: installing error
        255679 by: Rafael Mora
        255681 by: Jared Farrish
        255688 by: Rafael Mora

Re: PHP debugger
        255680 by: Jared Farrish

$_GET strings seperation
        255682 by: Navid Yar
        255683 by: Tijnema
        255685 by: Jared Farrish
        255689 by: Navid Yar

Re: Form Validation Issues
        255684 by: tedd
        255695 by: Jim Lucas

calculate xml size
        255686 by: Vo, Lance
        255687 by: Tijnema

Too many records to display in one web page
        255690 by: Eduardo Vizcarra
        255691 by: Jared Farrish
        255692 by: Tijnema
        255693 by: Brian Seymour
        255694 by: tedd

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 ---
Thank you very much for you answers!!! =), but Im trying to work with
PostgreSQL.

So Im gonna review your suggestions in order to see which would be the best
for me

Thank you very much!

Rafa


On 5/26/07, Sathyashrayan <[EMAIL PROTECTED]> wrote:



On 5/26/07, Tijnema <[EMAIL PROTECTED]> wrote:
>
> On 5/26/07, Richard Davey <[EMAIL PROTECTED]> wrote:
> > Hi Rafael,
> >
> > Saturday, May 26, 2007, 12:38:15 AM, you wrote:
> >
> > > Hello does anyone know the correct way to install PHP and APACHE
> (last
> > > versions both of them) on WinXP???, Im doing it with the installers
> and I
> > > cannot even run phpinfo(); script, I see apache's error log and it
> says that
> > > i cant find SAM directory
> >
> > http://wamp.corephp.co.uk
> >
> > Cheers,
> >
> > Rich



May be this helps.

http://www.tanguay.info/wamp/installPhp5.php5



--
"War doesn't determine who is right, war determines who is left."
                                                                 Chinese
proverb

--- End Message ---
--- Begin Message ---
Thank you very much for you answers!!! =), but Im trying to work with
PostgreSQL.

I have never installed PostgreSQL, but I have installed Apache and PHP
together. Three suggestions:

1. Forget the installers. They are worthless, since all you're doing is
adding or editing a few config file lines, plus adding a PATH variable.
2. Where and how you change those files is important, though, so you need to
google the version of php and apache you are installing and follow those
directions. It's tricky the first time, though. Be patient.
3. Start apache during your testing through a command-line. The error
reporting is much better on the command-line.

Also, really try not to put your PHP library in your System32 folder. This
is bad practice. Edit the PATH variable to point at where it should be
looking for the library.

So Im gonna review your suggestions in order to see which would be the
best
for me

WAMPP makes apache and php installation stupid easy (MySQL too, but you
don't seem to need it). Maybe, you might install WAMPP, uninstall MySQL, and
install PostgreSQL... Never done it, but with some fiddling, it should work.

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$

--- End Message ---
--- Begin Message ---
thank you jared!, Im gonna try WAMPP!!, I hope this work, and a message for
php people: nice product but make it easy! lol

thank you
Rafa


On 5/26/07, Jared Farrish <[EMAIL PROTECTED]> wrote:

> Thank you very much for you answers!!! =), but Im trying to work with
> PostgreSQL.

I have never installed PostgreSQL, but I have installed Apache and PHP
together. Three suggestions:

1. Forget the installers. They are worthless, since all you're doing is
adding or editing a few config file lines, plus adding a PATH variable.
2. Where and how you change those files is important, though, so you need
to
google the version of php and apache you are installing and follow those
directions. It's tricky the first time, though. Be patient.
3. Start apache during your testing through a command-line. The error
reporting is much better on the command-line.

Also, really try not to put your PHP library in your System32 folder. This
is bad practice. Edit the PATH variable to point at where it should be
looking for the library.

> So Im gonna review your suggestions in order to see which would be the
best
> for me

WAMPP makes apache and php installation stupid easy (MySQL too, but you
don't seem to need it). Maybe, you might install WAMPP, uninstall MySQL,
and
install PostgreSQL... Never done it, but with some fiddling, it should
work.

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$


--- End Message ---
--- Begin Message ---
Miles Thompson wrote:
> Suggestions will be most welcome. Also, I'm not married to this, so if
> anyone thinks there is a better debugger, please jump in.

The following assumes object-oriented programming paradigms are at least
somewhat applied. I would guess functional would be similar, but procedural
code, you might be on your own there...

I actually use two classes that I include at the bottom of all of my library
definitions (in if(!class_exists()){declare}format). One provides warning
and error message storage, the other type assertion. Between the two of
these, I have simple unit testing that I can perform as I am developing a
class, as well as pre-included simple error logging that, when I install
into the greater system, can be incorporated into the systemic error
catching routines without refactoring code, in most cases to weld-on
systemic error routines.

Thinking aloud, getting code to work correctly usually means testing it
against what you expect it to do, so doing that at a very localized level
first can be helpful. Once I started doing this, my implementation issues
somewhat went away. Results (and implementations) may very.

> PS Why are we doing this? Because we are getting tired of debugging
> with Javascript alert()  boxes. /mt

Firebug in Firefox is a very well-developed javascript debugger, featuring
console.log(), which allows you to stop using alert() for error checking.
Very nice! And I put this:

<code>
// Solve the firebug extension issue in IE by try/catching and creating a
blank object console.log();
try{console.log();}catch(e){var console=new
Object;console={log:function(){var k=0;}};};
</code>

At the head of each js file to prevent errors in IE or other browsers
without Firebug installed.

Example: http://web3.unt.edu/riskman/JS/lem.json.js

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$

--- End Message ---
--- Begin Message ---
Hello Everyone,

I have a problem with GET strings. I use
$_SERVER["REDIRECT_QUERY_STRING"] to get the value-pairs in the URL.
The problem is that there is a cID variable that keeps appending itself
to the string continuously everytime someone clicks on a different
category link on the website. For example, instead of this:

http://www.someexample.com/admin/index.html?cID=42&somevar=value&somevar2=value2

it keeps appending another cID to it everytime it goes to a different
link, like this:

http://www.someexample.com/admin/index.html?cID=42&cID=39&cID=44&cID=37&somevar=value&somevar2=value2

I know that this is happening because I'm appending it with the dot (.)
but is there a way to just inject a single cID and still have the rest
of the value-pairs available? Something built into PHP, maybe a different
predefined variable I don't know about? Or, do I have to make a
complex function to separate each out and then put it back together
again like humpty dumpty? Is there an easier way to do this and still
have a single cID variable in the GET string? Thanks in advance.

--- End Message ---
--- Begin Message ---
On 5/26/07, Navid Yar <[EMAIL PROTECTED]> wrote:
Hello Everyone,

I have a problem with GET strings. I use
$_SERVER["REDIRECT_QUERY_STRING"] to get the value-pairs in the URL.
The problem is that there is a cID variable that keeps appending itself
to the string continuously everytime someone clicks on a different
category link on the website. For example, instead of this:

http://www.someexample.com/admin/index.html?cID=42&somevar=value&somevar2=value2

it keeps appending another cID to it everytime it goes to a different
link, like this:

http://www.someexample.com/admin/index.html?cID=42&cID=39&cID=44&cID=37&somevar=value&somevar2=value2

I know that this is happening because I'm appending it with the dot (.)
but is there a way to just inject a single cID and still have the rest
of the value-pairs available? Something built into PHP, maybe a different
predefined variable I don't know about? Or, do I have to make a
complex function to separate each out and then put it back together
again like humpty dumpty? Is there an easier way to do this and still
have a single cID variable in the GET string? Thanks in advance.

Show us what you have so far, so that we can think about a fix.
*note that you don't need to place all code here, but only the relevant part.

Tijnema

--- End Message ---
--- Begin Message ---
On 5/26/07, Navid Yar <[EMAIL PROTECTED]> wrote:
Hello Everyone,

I have a problem with GET strings. I use
$_SERVER["REDIRECT_QUERY_STRING"] to get the value-pairs in the URL.
The problem is that there is a cID variable that keeps appending itself
to the string continuously everytime someone clicks on a different
category link on the website. For example, instead of this:


http://www.someexample.com/admin/index.html?cID=42&somevar=value&somevar2=value2

it keeps appending another cID to it everytime it goes to a different
link, like this:


http://www.someexample.com/admin/index.html?cID=42&cID=39&cID=44&cID=37&somevar=value&somevar2=value2

I know that this is happening because I'm appending it with the dot (.)
but is there a way to just inject a single cID and still have the rest
of the value-pairs available? Something built into PHP, maybe a different
predefined variable I don't know about? Or, do I have to make a
complex function to separate each out and then put it back together
again like humpty dumpty? Is there an easier way to do this and still
have a single cID variable in the GET string? Thanks in advance.

Is this what you're doing:

<code>
$cid = getCid(); // However you do set the new, included cid
$newlink = 'http://www.someexample.com/admin/index.html?'.$cid.
$_SERVER["REDIRECT_QUERY_STRING"];
</code>

???

If this is similar to what you're doing, this is a fairly problematic way
for you to insert a replacement property in a query string. An example of a
way to get a new query string:

<code>
function getNewQueryString($arr) {
   $store = Array();
   foreach ($_GET as $key=>$val) {
       foreach ($arr as $k=>$v) {
           if (isset($_GET[$k])) {
               $store[$key] = $v;
           }
       }
       if (!isset($store[$key])) {
           $store[$key] = $val;
       }
   }
   $i = 0;
   $str = '?';
   $count = count($store);
   foreach ($store as $key => $val) {
       $amp = $count-1 !== $i ? '&amp;' : '';
       $str .= "{$key}={$val}{$amp}";
       $i++;
   }
   return $str;
}
$query = Array('cID'=>42);
$newlink = "http://www.oompaloompa/land.php".getNewQueryString($query);
echo("<p>$newlink</p>");
</code>

What you need to do is transcribe your $_GET string to a new version,
replacing the current values that need replacing while retaining all other
values. To do this, loop through the $_GET global array, replace those that
match $_GET keynames with the new data, and then rebuild the query into a
string for inclusion in the link.

I'll leave it to you figure out how to add new values that are not replaced
($query=Array('cID'=>51,'doesnotexistyet'=>'completelynewvalue'), for
instance). Also, the above is an example; there are certainly many other
ways to do what is done above (such as replacing the last foreach loop with
an implode() call). There are some strictly unnecessary things done above,
in other words, but I left them in to show what really is happening (and
needs to be done).

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$

--- End Message ---
--- Begin Message ---
Thanks so much Jarred. It helps me learn more when there's an
explaination on how the code works. I'll play around with it, change
it a bit and give that a try. Take care...

P.S. -- I'm in Arlington, TX



On 5/26/07, Jared Farrish <[EMAIL PROTECTED]> wrote:
On 5/26/07, Navid Yar <[EMAIL PROTECTED]> wrote:
> Hello Everyone,
>
> I have a problem with GET strings. I use
> $_SERVER["REDIRECT_QUERY_STRING"] to get the value-pairs in the URL.
> The problem is that there is a cID variable that keeps appending itself
> to the string continuously everytime someone clicks on a different
> category link on the website. For example, instead of this:
>
>
http://www.someexample.com/admin/index.html?cID=42&somevar=value&somevar2=value2
>
> it keeps appending another cID to it everytime it goes to a different
> link, like this:
>
>
http://www.someexample.com/admin/index.html?cID=42&cID=39&cID=44&cID=37&somevar=value&somevar2=value2
>
> I know that this is happening because I'm appending it with the dot (.)
> but is there a way to just inject a single cID and still have the rest
> of the value-pairs available? Something built into PHP, maybe a different
> predefined variable I don't know about? Or, do I have to make a
> complex function to separate each out and then put it back together
> again like humpty dumpty? Is there an easier way to do this and still
> have a single cID variable in the GET string? Thanks in advance.

Is this what you're doing:

<code>
$cid = getCid(); // However you do set the new, included cid
$newlink = 'http://www.someexample.com/admin/index.html?'.$cid.
$_SERVER["REDIRECT_QUERY_STRING"];
</code>

???

If this is similar to what you're doing, this is a fairly problematic way
for you to insert a replacement property in a query string. An example of a
way to get a new query string:

<code>
function getNewQueryString($arr) {
    $store = Array();
    foreach ($_GET as $key=>$val) {
        foreach ($arr as $k=>$v) {
            if (isset($_GET[$k])) {
                $store[$key] = $v;
            }
        }
        if (!isset($store[$key])) {
            $store[$key] = $val;
        }
    }
    $i = 0;
    $str = '?';
    $count = count($store);
    foreach ($store as $key => $val) {
        $amp = $count-1 !== $i ? '&amp;' : '';
        $str .= "{$key}={$val}{$amp}";
        $i++;
    }
    return $str;
}
$query = Array('cID'=>42);
$newlink = "http://www.oompaloompa/land.php".getNewQueryString($query);
echo("<p>$newlink</p>");
</code>

What you need to do is transcribe your $_GET string to a new version,
replacing the current values that need replacing while retaining all other
values. To do this, loop through the $_GET global array, replace those that
match $_GET keynames with the new data, and then rebuild the query into a
string for inclusion in the link.

I'll leave it to you figure out how to add new values that are not replaced
($query=Array('cID'=>51,'doesnotexistyet'=>'completelynewvalue'), for
instance). Also, the above is an example; there are certainly many other
ways to do what is done above (such as replacing the last foreach loop with
an implode() call). There are some strictly unnecessary things done above,
in other words, but I left them in to show what really is happening (and
needs to be done).

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$


--- End Message ---
--- Begin Message ---
tedd wrote:

<SNIP on topic stuff>

    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Unknown

 Hi Jim:

 You might try the array below and the quote above, I believe, was
 > Douglas MacArthur of WWII fame.

Is that the same Douglas MacArthur who was once known as William
Shakespeare :-) IIRC that is from Twelfth Night.



Cheers
--
David Robley

I guess that MacArthur re-quoted it in one of his speeches, because I recall a WWII newsreel where he said it. But in any event, the author of the quote isn't Unknown.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
tedd wrote:
tedd wrote:

<SNIP on topic stuff>

    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Unknown

 Hi Jim:

 You might try the array below and the quote above, I believe, was
 > Douglas MacArthur of WWII fame.

Is that the same Douglas MacArthur who was once known as William
Shakespeare :-) IIRC that is from Twelfth Night.



Cheers
--
David Robley

I guess that MacArthur re-quoted it in one of his speeches, because I recall a WWII newsreel where he said it. But in any event, the author of the quote isn't Unknown.

Cheers,

tedd

well, it was to me. And the digging on google that I did, didn't return anything pointing to either. But, I was told that it was a quote from MacArthur and from Shakespeare.
--- End Message ---
--- Begin Message ---
does php has any function that calculate a xml element in bytes or anything:

example:

 

<tests>

<test1>ABC</test1>

<test2>DEF</test2>

</tests>

 

If I want to calculate element <test1>, it should return 18 bytes.

thanks

Lance 


--- End Message ---
--- Begin Message ---
On 5/26/07, Vo, Lance <[EMAIL PROTECTED]> wrote:
does php has any function that calculate a xml element in bytes or anything:

example:



<tests>

<test1>ABC</test1>

<test2>DEF</test2>

</tests>



If I want to calculate element <test1>, it should return 18 bytes.

thanks

Lance


I have nearly no experience with XML parser in PHP, but it doesn't
look like this function exists. However, you could call
xml_get_current_byte_index [1] once, then read the element, and call
it again, and the difference should be what you're looking for.

Tijnema

[1] www.php.net/xml_get_current_byte_index

--- End Message ---
--- Begin Message ---
Hi All

I am developing a web site that interacts with a MySQL database. When I run 
a query and display the records in a web page, this can become a problem 
because there might be too many records to be displayed in one single web 
page so I am trying to divide the total number of records and display them 
in multiple pages. Let's say, if the query returns 100 records then I would 
like to display the first 10 records and then put a navigation bar where I 
can go to the next 10 or return to the previous 10 records

Is this done at a SQL or PHP level ? any experience on doing this ?

Thanks a bunch
Eduardo 

--- End Message ---
--- Begin Message ---
I am developing a web site that interacts with a MySQL database. When I
run
a query and display the records in a web page, this can become a problem
because there might be too many records to be displayed in one single web
page so I am trying to divide the total number of records and display them

in multiple pages. Let's say, if the query returns 100 records then I
would
like to display the first 10 records and then put a navigation bar where I

can go to the next 10 or return to the previous 10 records

Is this done at a SQL or PHP level ? any experience on doing this ?

This is called pagination, and is well-discussed and documented on the web:

http://www.google.com/search?q=php+pagination

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$

--- End Message ---
--- Begin Message ---
On 5/27/07, Eduardo Vizcarra <[EMAIL PROTECTED]> wrote:
Hi All

I am developing a web site that interacts with a MySQL database. When I run
a query and display the records in a web page, this can become a problem
because there might be too many records to be displayed in one single web
page so I am trying to divide the total number of records and display them
in multiple pages. Let's say, if the query returns 100 records then I would
like to display the first 10 records and then put a navigation bar where I
can go to the next 10 or return to the previous 10 records

Is this done at a SQL or PHP level ? any experience on doing this ?

Thanks a bunch
Eduardo

Ik could be done with both, you could use the LIMIT option in your SQL
code, or just fetch all and only output 10 (using php).
I would prefer the first one, as it won't send all records, but only
the ones you need. This save some time when interacting with the
database. Of course you won't note the difference with 100-200 pages,
but when it becomes more and more (think about atleast 10000+) then
you probably will note the speed difference.

Tijnema

--- End Message ---
--- Begin Message ---
Eduardo,
The best way to do it is on both a php and sql level. Use sql's limit
keyword in your query to return only the amount of records you want. For
instance, page 1 will have LIMIT 0, 9 in the query. Page 2 will have LIMIT
10, 19. Then you can simply use *_fetch_array and a foreach(maybe) to
iterate through all the values. If you want to have the the amount of
records dynamically generate then either have a asdf.php?min=0&max=9 or just
do min = (page * 10) - 10 and max = (page * 10) - 1. Many different ways to
do this. However I find this one to be the most efficient.

Hope this helped. 

Brian Seymour
AeroCoreProductions
http://www.aerocore.net/

-----Original Message-----
From: Eduardo Vizcarra [mailto:[EMAIL PROTECTED] 
Sent: Saturday, May 26, 2007 7:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Too many records to display in one web page

Hi All

I am developing a web site that interacts with a MySQL database. When I run 
a query and display the records in a web page, this can become a problem 
because there might be too many records to be displayed in one single web 
page so I am trying to divide the total number of records and display them 
in multiple pages. Let's say, if the query returns 100 records then I would 
like to display the first 10 records and then put a navigation bar where I 
can go to the next 10 or return to the previous 10 records

Is this done at a SQL or PHP level ? any experience on doing this ?

Thanks a bunch
Eduardo 

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

--- End Message ---
--- Begin Message ---
At 6:17 PM -0500 5/26/07, Eduardo Vizcarra wrote:
Hi All

I am developing a web site that interacts with a MySQL database. When I run
a query and display the records in a web page, this can become a problem
because there might be too many records to be displayed in one single web
page so I am trying to divide the total number of records and display them
in multiple pages. Let's say, if the query returns 100 records then I would
like to display the first 10 records and then put a navigation bar where I
can go to the next 10 or return to the previous 10 records

Is this done at a SQL or PHP level ? any experience on doing this ?

Thanks a bunch
Eduardo

Eduardo:

Yes, look into "LIMIT" in MySQL.

Such as:

$dbQuery="SELECT $id FROM $dbtable ORDER BY title LIMIT $offset, $rowsPerPage";

Cheers,

tedd

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

--- End Message ---

Reply via email to