php-general Digest 25 Apr 2004 05:14:04 -0000 Issue 2725

Topics (messages 184527 through 184545):

Re: PHP5 bloats the code
        184527 by: Johannes Reichardt
        184529 by: Marek Kilimajer
        184531 by: Mark Charette
        184533 by: Marek Kilimajer
        184535 by: Johannes Reichardt

Re: Fetching XML for parsing
        184528 by: Patagonia Hosting Development Group

>From IIS to Apache
        184530 by: Stephen Craton
        184532 by: Richard Harb

Re: php/apache/mysql on ntfs
        184534 by: Curt Zirzow

PHP Auth
        184536 by: Anton Krall
        184538 by: Rainer Müller
        184539 by: Curt Zirzow
        184540 by: Anton Krall

Re: MySQL Dump
        184537 by: Michal Migurski

Problem when compiling php5
        184541 by: Martin Hjort Eriksen

formatting a string
        184542 by: Andy B
        184543 by: Tom Rogers
        184545 by: Andy B

Re: The COM problem when converting from ASP to PHP [works now!!]
        184544 by: Steven Kidd

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

thank you for pointing this one out. Who are the "php internals" and how could i contact them? This issue was rejected as bug recently.

- Johannes

* Thus wrote Marek Kilimajer ([EMAIL PROTECTED]):


I just installed php5 (finaly :-)) and it does not throw any error nor warning. I think what you see is Notice, so the behavior did not change.



Here is the offending situation:


<?php

/* E_NOTICE: undefined index, returns false */
unset($a);
echo is_array($a['foo']['asdf']);

/* returns false */
$a = 'asdf';
echo isset($a['foo']['asdf']);

/* returns false */
$a = array('foo' => 'asdf');
echo is_array($a['foo']['asdf']);

/* E_ERROR Invalid offset */
$a = 'asdf';
echo is_array($a['foo']['asdf']);

The last one is the biggie, the solution of course is to have
something like:

if (isset($a['foo']['asdf']) &&
   is_array($a['foo']['asdf']) {

This is a big BC issue, IMO, and might be worth asking internals
why the E_ERROR is given vs. a E_WARNING.


Curt



--- End Message ---
--- Begin Message --- Curt Zirzow wrote:
Here is the offending situation:

<?php

/* E_NOTICE: undefined index, returns false */
unset($a);
echo is_array($a['foo']['asdf']);

/* returns false */
$a = 'asdf';
echo isset($a['foo']['asdf']);

/* returns false */
$a = array('foo' => 'asdf');
echo is_array($a['foo']['asdf']);

/* E_ERROR Invalid offset */
$a = 'asdf';
echo is_array($a['foo']['asdf']);

The last one is the biggie, the solution of course is to have
something like:

if (isset($a['foo']['asdf']) &&
    is_array($a['foo']['asdf']) {

This is a big BC issue, IMO, and might be worth asking internals
why the E_ERROR is given vs. a E_WARNING.


Curt

Well, what I always know about my variables is if they are arrays or scalar ;) And I don't consider warning to be much nicer then error



--- End Message ---
--- Begin Message ---
> From: Marek Kilimajer [mailto:[EMAIL PROTECTED]

> Well, what I always know about my variables is if they are arrays or
> scalar ;) And I don't consider warning to be much nicer then error

Hmmm ... my current methods and functions in PHP 4.x oftentimes adapt to the
type passed to them since PHP doesn't have method signatures, meaning I
_don't_ know a priori what will be passed to them. Currently type checking
is mandatory if you want to avail yourself of a single method name.

Mark C.

--- End Message ---
--- Begin Message --- Mark Charette wrote:
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]


Well, what I always know about my variables is if they are arrays or
scalar ;) And I don't consider warning to be much nicer then error


Hmmm ... my current methods and functions in PHP 4.x oftentimes adapt to the
type passed to them since PHP doesn't have method signatures, meaning I
_don't_ know a priori what will be passed to them. Currently type checking
is mandatory if you want to avail yourself of a single method name.

Mark C.


So you have to check the type of the passed variable anyway, even in php4. You won't be affected by the new behavior in php5.

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

actually this behaviour is "too critical" since there are many cases where "compliant code" is not as well as much more simpler code. reminds me on the w3c standards that are so high that some things simply dont comply if you want them ;)

just a warning would be way better.

- Johannes




So you have to check the type of the passed variable anyway, even in php4. You won't be affected by the new behavior in php5.



--- End Message ---
--- Begin Message ---
That may be the exact problem. I was not figuring that one out. Thi is my
fopen and XML parser code:

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($uFile,"rb"))) {
  die ("could not open RSS for input");
}
while ($data = fread($fp, 4096)) {
  if (!xml_parse($xml_parser, $data, feof($fp))) {
    die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
  }
}

xml_parser_free($xml_parser);

How can I make PHP to first open the dynamically built page and THEN read
it's content?

Thanks a lot,

Cesar Aracena
Patagonia Hosting Development Group

"Mike Ryerse" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]
> How is your fopen code written?
> Could it have something to do with your browser is requesting a
> dynamically built page, and your php script is not?
>
> --- Patagonia Hosting Development Group
> <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > I know that fopen and fread should do the trick, but for some
> > strange reason
> > (maybe piping) I get an error when trying to fetch a XML document
> > generated
> > from an ASP page. If I open the file in my browser, I click in
> > "View Source
> > Code", copy and paste it in a new notepad document, save it as a
> > .xml file
> > and then open it, my sript works fine. The problem is when fetching
> > the
> > "live" version. It tells me the error is some misspelled tag at
> > line 8.
> >
> > Has anybody seen this before?
> >
> > Thanks in advanced,
> >
> > Cesar Aracena
> > Patagonia Hosting Development Group
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Photos: High-quality 4x6 digital prints for 25¢
> http://photos.yahoo.com/ph/print_splash

--- End Message ---
--- Begin Message ---
I've been running IIS for a while now and I'm really sick of it and all it's
security flaws. I decided today to upgrade to Apache, so I download the msi
from the Apache website. I install it, but once it tries to install it as a
service onto my XP Pro box, it gives me an error telling me that port 80
cannot be used. IIS ran on port 80 and I uninstalled it, rebooted, but I got
the error.

 

I've tried reinstalling Apache, rebooting, and pretty much everything I know
to do. Any help here would be greatly appreciated.

 

Thanks,

Stephen Craton

http://www.melchior.us

 

 

--- End Message ---
--- Begin Message ---
Though this isn't stricly a PHP question - here we go:

It sounds as if IIS didn't really go away...

There's a nice utility out there that lets you know what ports are
active and in use ...
It's called Active Ports (duh!) and is a small download from
http://www.ntutility.com (section /freeware.html). Though it needs
admin rights to run I found this very useful.

Alternatively you could just open a command shell and:

telnet localhost 80

if the connection is opened type "GET /" to check what might be
answering ... (there's no local echo, so you're typing blind).

If all else fails you can always edit apache's configuration file in
notepad: C:\program files\apache2\apache\conf\httpd.conf (or some
such) and tell it to listen on another port (like the ever popular
8080 for example) .. the config file is very well documented, you
shouldn't have a problem finding your way.

HTH
Richard


Saturday, April 24, 2004, 7:57:53 PM, thus was written:
> I've been running IIS for a while now and I'm really sick of it and all it's
> security flaws. I decided today to upgrade to Apache, so I download the msi
> from the Apache website. I install it, but once it tries to install it as a
> service onto my XP Pro box, it gives me an error telling me that port 80
> cannot be used. IIS ran on port 80 and I uninstalled it, rebooted, but I got
> the error.

 > I've tried reinstalling Apache, rebooting, and pretty much everything I know
> to do. Any help here would be greatly appreciated.

 

> Thanks,

> Stephen Craton

--- End Message ---
--- Begin Message ---
* Thus wrote Andy B ([EMAIL PROTECTED]):
> does anybody have any idea why this message keeps coming up every time i
> send a msg to the list?? im sort of confused now

I've gotten so used to them now, that I consider them receipts that
my messages have been posted to everyone :)


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
Guys.
 
Im doing a small php auth system and I was wondering, how can avoid having
to do a form to pass the user and pw to the php scripts and just use the
popup auth windows on IE and NS? do you remember the names of the vars that
get passed thru that popup or how can I invoke it?
 
Thx!

--- End Message ---
--- Begin Message --- Anton Krall schrieb:
Guys.
Im doing a small php auth system and I was wondering, how can avoid having
to do a form to pass the user and pw to the php scripts and just use the
popup auth windows on IE and NS? do you remember the names of the vars that
get passed thru that popup or how can I invoke it?
Thx!

This is called "Basic Auth" and google should give you some infos.


Rainer
--- End Message ---
--- Begin Message ---
* Thus wrote Anton Krall ([EMAIL PROTECTED]):
> Guys.
>  
> Im doing a small php auth system and I was wondering, how can avoid having
> to do a form to pass the user and pw to the php scripts and just use the
> popup auth windows on IE and NS? do you remember the names of the vars that
> get passed thru that popup or how can I invoke it?

This page should tell you everything you need to know:
  http://www.php.net/manual/en/features.http-auth.php

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
Thx Curt!

------------------------------------
Intruder Consulting
Anton Krall
Director General
[EMAIL PROTECTED]
tel: 5233-9281
mobile: 044-55-1320-8717
IM: [EMAIL PROTECTED]
www.intruder.com.mx
------------------------------------
 

%-----Original Message-----
%From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
%Sent: Sábado, 24 de Abril de 2004 02:30 p.m.
%To: [EMAIL PROTECTED]
%Subject: Re: [PHP] PHP Auth
%
%* Thus wrote Anton Krall ([EMAIL PROTECTED]):
%> Guys.
%>  
%> Im doing a small php auth system and I was wondering, how can avoid 
%> having to do a form to pass the user and pw to the php scripts and 
%> just use the popup auth windows on IE and NS? do you remember the 
%> names of the vars that get passed thru that popup or how can 
%I invoke it?
%
%This page should tell you everything you need to know:
%  http://www.php.net/manual/en/features.http-auth.php
%
%Curt
%--
%"I used to think I was indecisive, but now I'm not so sure."
%
%--
%PHP General Mailing List (http://www.php.net/) To unsubscribe, 
%visit: http://www.php.net/unsub.php
%
%

--- End Message ---
--- Begin Message ---
> I just tested it and yes, the Michal function runs on Windows and Linux.
> Just must write the path in the proper format for the OS you're using.

Holy smokes, that's good news. :)  Spreading dis-information is my price
for not having the first clue about windows.

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html

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

I am having a major prolem when compiling PHP5....the problem is new, and I have never had it before. I have tried compiling on to seperate dists og Linux, Debian testing and Slackware 9.0, but the error persistes.

The output I recieve is:

/usr/local/include/unix.h:222: error: parse error before "MAILSTREAM"
/usr/local/include/unix.h:223: error: parse error before '*' token
/usr/local/include/unix.h:224: error: parse error before '*' token
/usr/local/include/unix.h:225: error: parse error before '*' token
/usr/local/include/unix.h:226: error: parse error before '*' token
/usr/local/include/unix.h:228: error: parse error before '*' token
/usr/local/include/unix.h:229: error: parse error before '*' token
/usr/local/include/unix.h:230: error: parse error before '*' token
/usr/local/include/unix.h:231: error: parse error before '*' token
make: *** [ext/zlib/zlib.lo] Fejl 1

my configure is:

'./configure' '--prefix=/usr' '--disable-static' '--with-apxs2' '--enable-discard-path' '--with-config-file-path=/usr/conf' '--enable-safe-mode' '--enable-bcmath' '--with-pic' '--enable-calendar' '--enable-ctype' '--with-imap=/usr/imap-2002e' '--enable-dbase' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr' '--with-png' '--with-mysql=/usr/local/mysql' '--with-mm=/usr' '--enable-trans-sid' '--enable-shmop' '--enable-sockets' '--with-regex=php' '--enable-sysvsem' '--enable-sysvshm' '--enable-yp' '--enable-memory-limit' '--with-tsrm-pthreads' '--enable-shared' '--disable-debug' '--with-zlib' '--disable-libxml' '--with-pgsql'

What is wrong

\Martin
--- End Message ---
--- Begin Message ---
hi...

i have a string i want to pull out of a database (mysql). the column name is
Phone1 and it is a 10 digit phone number. the raw string coming out of the
table column would look like this: 1234567890

what i want to do is format the string on display like this: (123)456-7890
but dont quite know how to start with that. what function(s) would i use for
that?

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

Sunday, April 25, 2004, 11:17:16 AM, you wrote:
AB> hi...

AB> i have a string i want to pull out of a database (mysql). the column name is
AB> Phone1 and it is a 10 digit phone number. the raw string coming out of the
AB> table column would look like this: 1234567890

AB> what i want to do is format the string on display like this: (123)456-7890
AB> but dont quite know how to start with that. what function(s) would i use for
AB> that?


Try this:
$phone = '1234567890';
$newphone = preg_replace('/(\d{3})(\d{3})(\d)/','(\1)\2-\3',$phone);
echo $newphone.'<br>';

-- 
regards,
Tom

--- End Message ---
--- Begin Message ---
[snip]
$phone = '1234567890';
$newphone = preg_replace('/(\d{3})(\d{3})(\d)/','(\1)\2-\3',$phone);
echo $newphone.'<br>';

--
regards,
Tom
[/snip]
ok sorry but since i never used preg_* before i dont quite get what some of
this stuff means. i looked at the doc page for it but it doesnt make mention
at all of what \d, \w, \s or any of those things mean... i only assume that
\d means digit and \w or \s means blank space??

anyways to go through the whole example above part by part:
$phone = '1234567890';//understand that
$newphone = preg_replace(//ok now what does this stuff
//mean??
'/(\d{3})(\d{3})(\d)/'
im gathering the line above is the search string (what to look for)? if so i
get from it that it is supposed to look for the first block of 3 digits then
the second block of 3 digits and the other 4 numbers by themself in a sense
seperating the string into 3 different parts: 123 456 7890 and then asigning
like "id numbers to the blocks"
'(\1)\2-\3'
and this one above says put block 1 between (). take block 2 and put a -
after it and leave the other 4 numbers alone to come up with: (123)456-7890
$phone);
the original number to do the replace on of course

let me know if i got that set right

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

Thx ur help Richard , but ur method doesn't work.

However, when I switch to the PHP5 RC1, it works!~~
I use the recommonded php.ini setting.
my previous version is 4.3.6.


I really love PHP 5! :)


Strongly suggest anyone who uses COM switch to PHP 5.





Hello Steven,

Saturday, April 24, 2004, 2:08:20 AM, you wrote:

SK> Hi,

SK> When I converting lines of ASP code:

SK> <%
SK> dim keysobjs
SK> dim privkey
SK> dim pubkey
SK> dim seed
SK> Set keysobj= CreateObject("wmrmobjs.WMRMKeys")
SK> keysobj.GenerateSigningKeys privkey, pubkey
SK> seed = keysobj.GenerateSeed()
SK> Response.Write privkey
SK> Response.Write "<br>"
SK> Response.Write pubkey
SK> Response.Write "<br>"
SK> Response.Write seed
%>>

SK> To the PHP one:

SK> <?
SK> $com = new COM("wmrmobjs.WMRMKeys");
$com->>GenerateSigningKeys($privkey,$pubkey);
$seed = $com->>GenerateSeed();

SK> echo "Private key=".$privkey;
SK> echo "<br>";
SK> echo "Public key=".$pubkey;
SK> echo "<br>";
SK> echo "Seed=".$seed;
?>>

SK> In the ASP code everything works pretty well,
SK> In the PHP code, although I can obtain the value of $seed,
SK> the $privkey and $pubkey are null,
SK> kindly check the code for me, thx...

There is nothing wrong with your PHP code, it's just that you never
set the values of $privkey or $pubkey anywhere.

$com->GenerateSigningKeys($privkey,$pubkey);

This is PASSING the values into the GenerateSigningKeys function, it
is not setting them. Are you sure they are not set as the return
values? Like:

$com = new COM("wmrmobjs.WMRMKeys");
$privkey = $com->Privkey;

(etc?)



--- End Message ---

Reply via email to