php-general Digest 5 Feb 2006 00:59:51 -0000 Issue 3945

Topics (messages 229871 through 229883):

Serious bug ?
        229871 by: Bogdan Ribic

Re: xml to array
        229872 by: Brian V Bonini

Re: REGEX query
        229873 by: phplists

system('bell'); ?
        229874 by: tedd
        229876 by: Gerry Danen
        229878 by: Dan Harrington
        229879 by: php-mail

Using API in other languages
        229875 by: Eli
        229883 by: Rory Browne

Arrays
        229877 by: Philip W.
        229880 by: Eli
        229881 by: Paul Novitski

need help to update a mysql table from dynamic form
        229882 by: Patrick Aljord

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 ---
Hi all,

  I've found a strange bug with extract($GLOBALS, EXTR_REFS), and it
only shows up if you try to access a non-existent variable or array
member before that. Here's a demo script:


// Uncomment this line to see the problem
// $return = @$_GET['xx'];

function extr_globals() {
  extract($GLOBALS, EXTR_REFS);
};

function test($msg) {
  $x = 'OK';
  $msg = 'wrong';
  return $x;
};


echo test('login') . "\n";
extr_globals();
echo test('login');

If you run this script, it will output two OKs, as it should. If you
however uncomment the first line, one with $_GET assignment, it will
output an OK and then text "wrong". Tested with php 4.3.10 and 5.0.3 on
a windows machine.

What actually happens is that extract($GLOBALS, EXTR_REFS) really messes
up nametables. If you step into test function with debugger, you will
see that all variables inside the function will already be "initialized"
to the value of the parameter $msg, and assigning to one var will
overwrite values in unrelated variables. I repeat, this only happens if
you tried to access non-existent var or array member before that.

So it's a bug. Do I get a PHP T-shirt ? :-)

Boban.


--

   Open source PHP code generator for DB operations
   http://sourceforge.net/projects/bfrcg/

--- End Message ---
--- Begin Message ---
On Fri, 2006-02-03 at 16:23, Richard Lynch wrote:
> I've got my money on the XML spec REQUIRING an alphabetic start to
> tagnames, and subsequent characters can be alphanumeric...
> 
> In other words, it doesn't work because <0> is not a valid XML tag.


Yeah, that was my instinct too... Just could not find anything to
confirm it after a quick browse through the spec. Though can you find
anything in the spec via a quick browse.. ;-)

However, after a closer look I still can't find (at least in plain
English) anything that says this is NOT OK. Though the parser does
return '[xml_error] => not well-formed (invalid token)'.

Good stuff....

-Brian


-- 

s/:-[(/]/:-)/g


Brian        GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
======================================================================
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

--- End Message ---
--- Begin Message ---
Thanks for the options David.

I think I'll go for the last option as I'm determined to get to grips with REGEX, and your first choice of REGEX won't work for me as the 'RV-6' bit can be too variable with what it contains, whereas the \(EX\) bit IS more constant...it's only the EX bit that changes.

I knew I had to to escape some characters but got confused as to how many times to do each one.
I have tried using your example as follows:

$postScriptData =preg_replace("/\\\(.*?\)\\/","",$postScriptData);

and get the following error:
Warning: No ending delimiter '/' found in...

Any suggestions?

Cheers
Alexis


David Tulloh wrote:

I assume that the text inside can change around a fair bit.  If the
string is of a fixed with or simple format you can just use substr() and
friends, it's simpler and faster.

That said, there is really two approaches that I can see with this string.

You can match on the spaces to extract the 'RV-6', something like
'/\s\S+\s/' should do the trick, that pulls out some non-whitespace
characters from between two whitespace characters, including the
whitespace characters.  Then just add the () on again afterwards.

The other approach would be to use preg_replace to get rid of the \(EX\)
portion by replacing it with an empty string.  Personally I would
probably use the first technique as I generally don't like using replace
functions in this way.  A pattern which should match is '/\\\(.*?\)\\/',
the mess of \ is because \ ( and ) all need to be escaped with a \.


David

phplists wrote:

Hi,

I'm still trying to get to grips with REGEX and have hit a hurdle with
the following:

I have this bit of text:
(\(EX\) RV-6 )

I want to remove the '\(EX\)' part of it
so leaving just: ( RV-6 )

Any suggestions would be most appreciated.

Thanks
Alexis






--- End Message ---
--- Begin Message ---
I simple wrote a small C program that basically sent a bell, 0x07
and it opened my cash drawer. In php I just did system('bell'); and
it worked fine.

Kevin

Hi:

Interesting! The statement system('bell'); is new to me.

If I'm writing code on a hosted domain, and using that statement, who's bell am I ringing?

tedd

--
--------------------------------------------------------------------------------
http://sperling.com/

--- End Message ---
--- Begin Message ---
bell is his C program... :)   Outputs an ascii 7 (bell) at the machine
where it runs. It basically outputs a character to stdout or stderr.

He probably has that machine next to his cash drawer...

Gerry

On 2/4/06, tedd <[EMAIL PROTECTED]> wrote:
> >I simple wrote a small C program that basically sent a bell, 0x07
> >and it opened my cash drawer. In php I just did system('bell'); and
> >it worked fine.
> >
> >Kevin
>
> Hi:
>
> Interesting! The statement system('bell'); is new to me.
>
> If I'm writing code on a hosted domain, and using that statement,
> who's bell am I ringing?
>
> tedd
>
> --
> --------------------------------------------------------------------------------
> http://sperling.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Gerry
http://portal.danen.org/

--- End Message ---
--- Begin Message ---
Ask not for whom the bell tolls, it tolls for thee!
 

-----Original Message-----
From: Gerry Danen [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 04, 2006 12:00 PM
To: tedd
Cc: php-general@lists.php.net
Subject: Re: [PHP] system('bell'); ?

bell is his C program... :)   Outputs an ascii 7 (bell) at the machine
where it runs. It basically outputs a character to stdout or stderr.

He probably has that machine next to his cash drawer...

Gerry

On 2/4/06, tedd <[EMAIL PROTECTED]> wrote:
> >I simple wrote a small C program that basically sent a bell, 0x07 and 
> >it opened my cash drawer. In php I just did system('bell'); and it 
> >worked fine.
> >
> >Kevin
>
> Hi:
>
> Interesting! The statement system('bell'); is new to me.
>
> If I'm writing code on a hosted domain, and using that statement, 
> who's bell am I ringing?
>
> tedd
>
> --
> ----------------------------------------------------------------------
> ----------
> http://sperling.com/
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>


--
Gerry
http://portal.danen.org/

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

--- End Message ---
--- Begin Message ---
Suppose someone had to :)

-----Original Message-----
From: Dan Harrington [mailto:[EMAIL PROTECTED] 
Sent: 04 February 2006 19:50
To: php-general@lists.php.net
Subject: RE: [PHP] system('bell'); ?


Ask not for whom the bell tolls, it tolls for thee!
 

-----Original Message-----
From: Gerry Danen [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 04, 2006 12:00 PM
To: tedd
Cc: php-general@lists.php.net
Subject: Re: [PHP] system('bell'); ?

bell is his C program... :)   Outputs an ascii 7 (bell) at the machine
where it runs. It basically outputs a character to stdout or stderr.

He probably has that machine next to his cash drawer...

Gerry

On 2/4/06, tedd <[EMAIL PROTECTED]> wrote:
> >I simple wrote a small C program that basically sent a bell, 0x07 and 
> >it opened my cash drawer. In php I just did system('bell'); and it 
> >worked fine.
> >
> >Kevin
>
> Hi:
>
> Interesting! The statement system('bell'); is new to me.
>
> If I'm writing code on a hosted domain, and using that statement, 
> who's bell am I ringing?
>
> tedd
>
> --
> ----------------------------------------------------------------------
> ----------
> http://sperling.com/
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>


--
Gerry
http://portal.danen.org/

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

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


__________ NOD32 1.1393 (20060203) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

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

I have a class in PHP which offers some API functions. I want to access this API with other languages (such as C/C++, Java, Perl, etc), so the functions will run from PHP.
How can I do that?

-thanks.

--- End Message ---
--- Begin Message ---
I could be wrong on this, but I think your best hope is something
using web services like SOAP, or XML-RPC.

On 2/4/06, Eli <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a class in PHP which offers some API functions. I want to access
> this API with other languages (such as C/C++, Java, Perl, etc), so the
> functions will run from PHP.
> How can I do that?
>
> -thanks.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message --- Sorry if this question seems stupid - I've only had 3 days of PHP experience.

When using the following string format, I get an error from PHP.

$text['text'] = "String Text" ;

Can someone help me?

--- End Message ---
--- Begin Message ---
Philip W. wrote:
Sorry if this question seems stupid - I've only had 3 days of PHP experience.

When using the following string format, I get an error from PHP.

$text['text'] = "String Text" ;

Can someone help me?

This seems ok and should not give any error. Mabye the error is of something else.
What's the error you get?

--- End Message ---
--- Begin Message ---
At 11:12 AM 2/4/2006, Philip W. wrote:
When using the following string format, I get an error from PHP.

$text['text'] = "String Text" ;

Hi Philip,

If that's literally a line from your script, my guess is that "text" is a reserved word and can't be used as a variable name. Try $sText or $sSomethingMeaningful.

In this and future postings, it would help us help you if you share all relevant details such as the exact error message you see.


I've gotten into the habit of prefixing all my variable names with their type:

$aSomething - array
$sSomething - string
$iSomething - integer
$nSomething - numeric
$bSomething - Boolean

In a language like PHP in which data typing is so loose, I find that prefixing the variable type a) helps me keep variables straight and b) prevents me from inadvertantly using reserved words as variable names.

Great resource:
http://php.net/

You can quickly look up details from the reference guide by entering key words after the domain name, for example:
        http://php.net/array
gets you a page of array functions.

Have fun,
Paul
--- End Message ---
--- Begin Message ---
could someone please help me on that one? http://hashphp.org/pastebin?pid=6156

basically this is how I do:
I display a mysql table in an html table and I put each value in an
input text box.
At the bottom I put a submit button to update changes.
My question is how do I update everything knowing that I don't know in
advance the name of all the input textbox?

Here is the code to display the table:
 <table width=\"1\" border=\"1\">
   <tbody>
     <tr>
       <td><strong>English</strong></td>
       <td><strong>Fran&#231;ais</strong></td>
       <td><strong>Espa&#241;ol</strong></td>

     ";
 $getdisplaycatname = "select
catid,categoryfr,categoryen,categoryes,categoryar from category";
 $getdisplaycatnameq = mysql_query($getdisplaycatname);
 while ($getcatrow = mysql_fetch_array($getdisplaycatnameq)){
 //$display_category=mysql_result($getcatnameq, 0);
 $showcatid=$getcatrow['catid'];
 $showcat=$getcatrow['categoryfr'];
 $showcaten=$getcatrow['categoryen'];
 $showcates=$getcatrow['categoryes'];
 echo "  <tr>
       <td> <input type=\"text\" name=\"<????>\" value=\"$showcaten\"
size=\"18\"/></td>
       <td> <input type=\"text\" name=\"<????>\" value=\"$showcat\"
size=\"18\"/></td>
       <td> <input type=\"text\" name=\"<????>\" value=\"$showcates\"
size=\"18\"/></td>
     </tr>
  ";
 }
 echo "
 </tr>
   </tbody>
 </table>
 <br /><input type=\"submit\" name=\"update\"  value=\"update\" /></form>

 ";
 thanx in advance

Pat

--- End Message ---

Reply via email to