php-general Digest 29 Jan 2006 13:02:50 -0000 Issue 3933

Topics (messages 229407 through 229418):

Re: ID vs NAME in different browsers
        229407 by: Niels

Re: questions regarding PHP and Forms
        229408 by: Paul Goepfert
        229410 by: Miles Thompson
        229412 by: chris smith

pcntl functions and database
        229409 by: chris smith
        229411 by: Kevin Kinsey
        229413 by: chris smith

Command Line PHP Advice
        229414 by: Angelo Christou
        229415 by: Chris

Re: XML and special characters
        229416 by: Adam Hubscher

XML and htmlentities conditionally?
        229417 by: Adam Hubscher

query regard forms in PHP
        229418 by: suresh kumar

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Saturday 28 January 2006 18:20, David Hall wrote:


> Uh, sorry to disappoint, but that's a description of the form element,
> not of the input element or select input.
Right.

> In fact, if you go to
>
http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.4.2
> , you will see that the example form quite clearly uses name.  And for
> the input element,
>
http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.4.2
> says that name assigns the control name.
> 
Right.

> The attributes for the form element are completely independent of the
> input elements.
Right.

> (Note, for things like radio buttons, using id makes no 
> sense.  You must have multiple elements with the same name.  If you used
> id for these multiple elements, you would be breaking the rules of html
> saying only one element can have a certain id . . .)
Excellent example! I think you've answered my question: I'll have to keep
using both NAME and ID.

Thanks a lot!
Niels

--- End Message ---
--- Begin Message ---
Thanks for the help everyone.  I have decided to use javascript to
deal with my second problem.  I understand that this is not a
JavaScript fourm but I am having some trouble getting my JS function
to work correctly.

Here is my JS code.

function getEquipment ()
{
        var mylist = document.getElementById("equip");
        if (mylist.options[mylist.selectedIndex].value=="other")
        {
                document.writeln("<tr>");
                document.writeln("      <td align="left">Other</td>");
                document.writeln("      <td><input type="text" name="other" 
size="20"></td>");
                document.writeln("</tr>");
        }
}

This is my code for where the function is called

<select name="equipment" size="1" id="equip" onChange="getEquipment()">
                            <option value="treadmill">Treadmil</option>
                            <option value="exercise bike">Exercise Bike</option>
                            <option value="other">Other</option>
                            <option value="rowing machine"
selected>Rowing Machine</option>
                          </select>

My problem is when the page loads in a web browser the Option "Other"
is selected every time. From what you can see from my code   "Rowing
machine is the one that I want to be shown when the page loads.

Anyway can anyonne tell me why my code is not executing correctly.  I
am not too familiar with java script.  What I am trying to accomplish
is if Other is selected then add a new table row below the drop down
menu with the content that I have in the function.

If no one can help with this would someone please direct me to a Java
Script  Forum.

Thanks

Paul

On 1/27/06, Weber Sites LTD <[EMAIL PROTECTED]> wrote:
> Check out this list of code examples to help with #1
> http://www.weberdev.com/AdvancedSearch.php?searchtype=title&search=validatio
> n
>
> Sincerely
>
> berber
>
> Visit the Weber Sites Today,
> To see where PHP might take you tomorrow.
> PHP code examples : http://www.weberdev.com
> Free Uptime Monitor : http://uptime.weberdev.com
> PHP content for your site : http://content.weber-sites.com
>
>
> -----Original Message-----
> From: Paul Goepfert [mailto:[EMAIL PROTECTED]
> Sent: Friday, January 27, 2006 9:28 PM
> To: php-general@lists.php.net
> Subject: [PHP] questions regarding PHP and Forms
>
> Hi all,
>
> I am  writing my first website in php.  I have a few questions.
>
> 1) I need to do vaildation on form values that I have entered into a form.
> Is there a way I can write the vaildation code on the same page as the form
> in php?
>
> 2)  I have a drop down menu on one of my form fields.  What I want to do is
> if a certain item is seelected I want to have a new textbox appear below the
> drop down menu.  Is there a way to do this in php?
>
> Thanks
>
> Paul
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>
>

--- End Message ---
--- Begin Message ---
At 05:39 PM 1/28/2006, Paul Goepfert wrote:

Thanks for the help everyone.  I have decided to use javascript to
deal with my second problem.  I understand that this is not a
JavaScript fourm but I am having some trouble getting my JS function
to work correctly.

Here is my JS code.

function getEquipment ()
{
        var mylist = document.getElementById("equip");
        if (mylist.options[mylist.selectedIndex].value=="other")
        {
                document.writeln("<tr>");
                document.writeln("      <td align="left">Other</td>");
document.writeln(" <td><input type="text" name="other" size="20"></td>");
                document.writeln("</tr>");
        }
}

This is my code for where the function is called

<select name="equipment" size="1" id="equip" onChange="getEquipment()">
                            <option value="treadmill">Treadmil</option>
<option value="exercise bike">Exercise Bike</option>
                            <option value="other">Other</option>
                            <option value="rowing machine"
selected>Rowing Machine</option>
                          </select>

My problem is when the page loads in a web browser the Option "Other"
is selected every time. From what you can see from my code   "Rowing
machine is the one that I want to be shown when the page loads.

Anyway can anyonne tell me why my code is not executing correctly.  I
am not too familiar with java script.  What I am trying to accomplish
is if Other is selected then add a new table row below the drop down
menu with the content that I have in the function.

If no one can help with this would someone please direct me to a Java
Script  Forum.

Thanks

Paul

[EMAIL PROTECTED]

Registration is required.

MT

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 1/27/2006

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

I missed the start of the thread but it may be because you have a space in
"rowing machine" for the option.

Try "rowing_machine" or "rowingmachine" and see what happens.

(check your javascript console - in firefox type 'javascript:' in the
address bar without the quotes).

On 1/29/06, Miles Thompson <[EMAIL PROTECTED]> wrote:
>
> At 05:39 PM 1/28/2006, Paul Goepfert wrote:
>
> >Thanks for the help everyone.  I have decided to use javascript to
> >deal with my second problem.  I understand that this is not a
> >JavaScript fourm but I am having some trouble getting my JS function
> >to work correctly.
> >
> >Here is my JS code.
> >
> >function getEquipment ()
> >{
> >         var mylist = document.getElementById("equip");
> >         if (mylist.options[mylist.selectedIndex].value=="other")
> >         {
> >                 document.writeln("<tr>");
> >                 document.writeln("      <td align="left">Other</td>");
> >                 document.writeln("      <td><input type="text"
> > name="other" size="20"></td>");
> >                 document.writeln("</tr>");
> >         }
> >}
> >
> >This is my code for where the function is called
> >
> ><select name="equipment" size="1" id="equip" onChange="getEquipment()">
> >                             <option value="treadmill">Treadmil</option>
> >                             <option value="exercise bike">Exercise
> > Bike</option>
> >                             <option value="other">Other</option>
> >                             <option value="rowing machine"
> >selected>Rowing Machine</option>
> >                           </select>
> >
> >My problem is when the page loads in a web browser the Option "Other"
> >is selected every time. From what you can see from my code   "Rowing
> >machine is the one that I want to be shown when the page loads.
> >
> >Anyway can anyonne tell me why my code is not executing correctly.  I
> >am not too familiar with java script.  What I am trying to accomplish
> >is if Other is selected then add a new table row below the drop down
> >menu with the content that I have in the function.
> >
> >If no one can help with this would someone please direct me to a Java
> >Script  Forum.
> >
> >Thanks
> >
> >Paul
>
> [EMAIL PROTECTED]
>
> Registration is required.
>
> MT
>

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

I'm trying to work out threaded apps and I'm trying to use the pcntl
functions.

I can get it working ok without using a database but when I plug the
database in I get 'lost connection during query' errors.

Does anyone have any suggestions or a working example ?

Thanks!

My code:

<?php
declare(ticks=1);
$time = time();

if (!$connection_result = mysql_connect('localhost', 'root')) {
    echo 'Unable to connect: ' . mysql_error() . "\n";
    exit();
}

echo "Connected ok\n";

$childcount = 0;
$childrencount = 2;
while($childcount < $childrencount) {
    $pid = pcntl_fork();

    if ( $pid == -1 ) {
        die("error\n");
    }

    if ($pid == 0) {
        $childcount++;
        pcntl_wait($status);
        continue;
    }

    $qry = "select version() AS version";
    $result = mysql_query($qry);
    if (!$result) {
        echo "error: " . mysql_error() . "\n";
    } else {
        $row = mysql_fetch_assoc($result);
        echo $row['version'] . "\n";
    }
    exit();
}

echo 'took ' . (time() - $time) . ' seconds' . "\n";
?>

--- End Message ---
--- Begin Message ---
chris smith wrote:

Hi all,

I'm trying to work out threaded apps and I'm trying to use the pcntl
functions.

I can get it working ok without using a database but when I plug the
database in I get 'lost connection during query' errors.

Does anyone have any suggestions or a working example ?

Thanks!

My code:


Your code works for me, *most* of the time - say, 96%++.  I tested
with small values for $childrencount (2 up to 200).  I'd hesitate to
speculate, but it smells like an SQL server performance issue to
my weak nose...(IANAE).

Kevin Kinsey
DaleCo, S.P.

--
Never offend people with style when you can offend them with substance.
                -- Sam Brown, The Washington Post, January 26, 1977

--- End Message ---
--- Begin Message ---
Hi Kevin,

Thanks for testing it. I got the same when I was using postgresql for the
database so I thought I was doing something wrong.

On 1/29/06, Kevin Kinsey <[EMAIL PROTECTED]> wrote:
>
> chris smith wrote:
>
> >Hi all,
> >
> >I'm trying to work out threaded apps and I'm trying to use the pcntl
> >functions.
> >
> >I can get it working ok without using a database but when I plug the
> >database in I get 'lost connection during query' errors.
> >
> >Does anyone have any suggestions or a working example ?
> >
> >Thanks!
> >
> >My code:
> >
> >
> >
>
> Your code works for me, *most* of the time - say, 96%++.  I tested
> with small values for $childrencount (2 up to 200).  I'd hesitate to
> speculate, but it smells like an SQL server performance issue to
> my weak nose...(IANAE).
>
> Kevin Kinsey
> DaleCo, S.P.
>
> --
> Never offend people with style when you can offend them with substance.
>                 -- Sam Brown, The Washington Post, January 26, 1977
>
>
>

--- End Message ---
--- Begin Message ---
Hello List
I would like some advice from PHP users regarding PHP and the command line. I 
have a PHP script that does a whole bunch of stuff to a file on my intranet.

./edit.php filename var1 var2

Everything works fine but I need to run it on a list of files  - 

./edit.php invoice00212.txt var1 var2
./edit.php invoice00213.txt var1 var2
./edit.php invoice00214.txt var1 var2

I have a list of several thousand files that will change every month. The list 
has the filenames and variables, like this so I am half way there I think -

invoice00212.txt var1 var2
invoice00213.txt var1 var2
invoice00214.txt var1 var2

My question is how should I incorporate this with my PHP script?

I read that it's better to split scripts up into small reusable parts so my 
plan is to keep the logic out of the edit.php script and simply pass the 
variables to it using another script. Am I on the right path doing this?

I am only a beginner with PHP so I admit I don’t really know what I’m doing, 
that is why I am asking for pointers from the PHP Mail List :)

Below is my model, however I am unsure how to achieve this or even if it's the 
best way to do it?

open filelist.txt
for each line create $filename $var1 $var2
then run
./edit.php $filename $var1 $var2
loop back to the next line
end

Many thanks in advance,
Ang.
 

                
---------------------------------
Do you Yahoo!?
 With a free 1 GB, there's more in store with Yahoo! Mail.

--- End Message ---
--- Begin Message ---
Angelo Christou wrote:

I read that it's better to split scripts up into small reusable parts so my 
plan is to keep the logic out of the edit.php script and simply pass the 
variables to it using another script. Am I on the right path doing this?

That is a good ideology, but whether it's best for your script depends on the data. I, personally, would probably split it up, just to keep things clear and separated so when I go back to it later, I can more easily modify it..

I am only a beginner with PHP so I admit I don’t really know what I’m doing, 
that is why I am asking for pointers from the PHP Mail List :)

Below is my model, however I am unsure how to achieve this or even if it's the 
best way to do it?

open filelist.txt
for each line create $filename $var1 $var2
then run
./edit.php $filename $var1 $var2
loop back to the next line
end


That looks good to me. It's not too difficult to jsut throw something together with the file() function. If your file gets really big you may want to look into reading the file line by line with fopen() / fgets(). But if you're going to be running it once a month only, file() should work fine.

Many thanks in advance,
Ang.


                
---------------------------------
Do you Yahoo!?
With a free 1 GB, there's more in store with Yahoo! Mail.
Chris

--- End Message ---
--- Begin Message ---
Steve Clay wrote:
Sunday, January 22, 2006, 10:10:54 PM, Adam Hubscher wrote:

ee dee da da da? &sect;&eth; <-- those that look like html entities are
the represented characters. I was mistaken, they are html entities,


Can you show us a small chunk of this XML that throws errors?

You said you've tried various parsers.  Did none of those parsers have
error logging capabilities?  Show us the errors.

Steve

I realized my problem and fixed it.

For the future, a doctype is required no matter what ;)

--- End Message ---
--- Begin Message ---
I have a block of XML that looks as follows:

<name>&lt;*_~_*&gt; Røyken VGS &lt;*_~_*&gt;</name>

Now, if I run that block of XML through htmlentities, I will get the following:

<name><*_!_*> Røyken VGS <*_~_*></name>

XML parsers will return a problem, as there is both an unclosed tag and an invalid tag, in two places no less (however the error will occur on the first "tag".

In order for this particular XML file to parse properly, I -must- run html_entity_decode. This causes quite the predicament as if I were to then run htmlentities() on this portion of the file, it would produce quite a bit of chaos.

My question is, can I in any way efficiently (i -stress- efficiently, if anyone read my previous XML and special characters post its a rather large XMl file (breaking 18mb now) and speed is of the essence) cause html_entity_decode to not decode those tags?

Or any other way would be nice too, I'm pretty much open to anything... as long as it doesnt severely hurt the efficiency of the script.


(I discovered the error of my ways in the previous problem btw, having a doctype helps... me == brainded in that :s)
--- End Message ---
--- Begin Message ---
 hai,
        i am having 3 files,namely page1,page2  and page3,when i enter username 
and password in my first page i want 2  display  my username and password  in 
my third page through  second page.
  
                                                                 A.suresh
  

                                
---------------------------------
 Jiyo cricket on Yahoo! India cricket

--- End Message ---

Reply via email to