php-general Digest 29 Dec 2002 14:53:59 -0000 Issue 1791
Topics (messages 129556 through 129579):
unpack() - how to handle bitfields??
129556 by: Tim Molendijk
Form duplicate post problem
129557 by: Pag
129558 by: Timothy Hitchens (HiTCHO)
129559 by: Pag
129561 by: John W. Holmes
129562 by: Timothy Hitchens (HiTCHO)
129568 by: Pag
129570 by: Michael J. Pawlowsky
Directing to a URL from a radio group
129560 by: Denis L. Menezes
129563 by: John W. Holmes
php.ini ignored! Re: [PHP] PHP 4.3.0 released
129564 by: omer k
include option and calling only part of a file.
129565 by: Stephen of Blank Canvas
129572 by: John W. Holmes
snmpget
129566 by: Gareth Hastings
PHP 4.3.0, function removed?
129567 by: Detritus
129569 by: Sterling Hughes
129571 by: Detritus
129573 by: gamin
Re: [PHP-DEV] Re: [PHP] PHP 4.3.0 released
129574 by: Rick Widmer
preg_split
129575 by: Mr Nik Frengle
Re: IIS Quit Working
129576 by: Jason Wong
Warning: 1 is not a valid File-Handle resource - HELP!
129577 by: Phil Powell
European "daylight saving" summer-time.
129578 by: Martin Thoma
PHP 4.3 unable to load php_domxml.dll in WinXP Apache 2.0.43
129579 by: Rui Costa
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 all,
I'm wrestling with this problem for a while now. I want to read a binary
file (created by C software) using PHP. I know of unpack(). But the C struct
that is stored in the binary file contains variables with bitfields:
struct some_struct {
char val_a : 2
int val_b : 7
}
Such a construct means that val_a is char with a bitfield of 2 and therefore
can contain values between 0 (00 binary) and 3 (11 binary). val_b is an
integer with a range of 0 (0000000) to 127 (1111111).
Now the problem is: how on earth do I handle those values with PHP's
unpack()?!? I've tried a lot of syntaxes but none of them seem to work. Can
someone please shortcut whether it is possible or not and if yes, *how*?
Thanks in advance,
Tim
--- End Message ---
--- Begin Message ---
Hi,
I am having some problems with duplicate form input.
I have a form that adds comments to an article, works fine, but if the
user clicks on "refresh", having added a comment previously, the same
comment is added again. I tried clearing the variables after the database
write, but the refresh somehow resends the previous values.
Roughly, heres how my script works: (not using actual code syntax here)
------------------
if {$flag=1 AND $name!='' AND $commentbody!=''){
inserts the comment into the database
$flag = 0
$name = ''
$comment = ''
}
------------------
routine to display the article and the existing comments here
------------------
form here
if user clicks send, puts $flag=1 and calls same page
------------------
How can i prevent these double entries? Some command to definitely clear
the variables?
Thanks.
Pag
--- End Message ---
--- Begin Message ---
There is a very simple solution to this on the page that
does the entries into the database simply to a header redirect
to a new page that displays the success notices etc and if they
do a back or a refresh nothing will happen as the POST data
is on the previous now "removed" from history page.
header('Location: http://www.yourdomain.com/success.html');
* you will need to put some GET data in the URL to show the correct page.
That will do it for you.
Remember that you can't send output on the database entry page simple
to the database calls and they do the header call as above.
Timothy Hitchens (HiTCHO)
[EMAIL PROTECTED]
If you need PHP hosting with an experienced
support team 24/7 then email me today.
On Sun, 29 Dec 2002, Pag wrote:
>
> Hi,
>
> I am having some problems with duplicate form input.
> I have a form that adds comments to an article, works fine, but if the
> user clicks on "refresh", having added a comment previously, the same
> comment is added again. I tried clearing the variables after the database
> write, but the refresh somehow resends the previous values.
> Roughly, heres how my script works: (not using actual code syntax here)
>
> ------------------
> if {$flag=1 AND $name!='' AND $commentbody!=''){
>
> inserts the comment into the database
> $flag = 0
> $name = ''
> $comment = ''
> }
> ------------------
> routine to display the article and the existing comments here
> ------------------
> form here
> if user clicks send, puts $flag=1 and calls same page
> ------------------
>
>
> How can i prevent these double entries? Some command to definitely clear
> the variables?
> Thanks.
>
> Pag
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
to a new page that displays the success notices etc and if they
do a back or a refresh nothing will happen as the POST data
is on the previous now "removed" from history page.
I understand, but the reason i am trying to stick with just one
page is that i want it to be practical. I mean, the moment the user clicks
"submit" the page reloads and shows his comment immediately, and give him
the functionality of pressing refresh to see if anyone else commented in
the meantime.
Also, by using a different page, even with a redirect back to the
original, might take a little while, since the original is a bit heavy on
the download side. ;-)
Pag
--- End Message ---
--- Begin Message ---
> >to a new page that displays the success notices etc and if they
> >do a back or a refresh nothing will happen as the POST data
> >is on the previous now "removed" from history page.
>
> I understand, but the reason i am trying to stick with just
one
> page is that i want it to be practical. I mean, the moment the user
clicks
> "submit" the page reloads and shows his comment immediately, and give
him
> the functionality of pressing refresh to see if anyone else commented
in
> the meantime.
> Also, by using a different page, even with a redirect back to
the
> original, might take a little while, since the original is a bit heavy
on
> the download side. ;-)
You can still use one page and use a "middle-man" technique. The part
that processes the form input would redirect back to itself after the
data is inserted into the database, thus getting rid of the post data.
So subsequent refreshes of the page will refresh without attempting to
repost the data.
The only other way to do it is to check the data you're about to insert
to see if it's already there. If it is, then don't insert it...
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
The redirect using the header method is instant and if the middle
page just does the inserts and you redirect right away using PHP
it is not noticable at all.
Timothy Hitchens (HiTCHO)
[EMAIL PROTECTED]
If you need PHP hosting with an experienced
support team 24/7 then email me today.
On Sun, 29 Dec 2002, Pag wrote:
>
>
>
> >to a new page that displays the success notices etc and if they
> >do a back or a refresh nothing will happen as the POST data
> >is on the previous now "removed" from history page.
>
> I understand, but the reason i am trying to stick with just one
> page is that i want it to be practical. I mean, the moment the user clicks
> "submit" the page reloads and shows his comment immediately, and give him
> the functionality of pressing refresh to see if anyone else commented in
> the meantime.
> Also, by using a different page, even with a redirect back to the
> original, might take a little while, since the original is a bit heavy on
> the download side. ;-)
>
> Pag
>
>
>
--- End Message ---
--- Begin Message ---
The redirect using the header method is instant and if the middle
page just does the inserts and you redirect right away using PHP
it is not noticable at all.
I gave up on reinventing the wheel and i am trying to use that
middle-page method you guys mentioned. To make things a little more
transparent to the user, i thought of using a popup window instead, you
know, a tiny window pops up, with the code to insert the comment on the
database, and closes right after it does so.
but err..how can i close it right after the database insert?
Pag
--- End Message ---
--- Begin Message ---
You can close it with JavaScript.
Something like
<script language="JavaScript">
function open_a_window_please(){
lovechild = window.open("childpage.htm");
</script>
Now we have a name that can tell the browser which window to close.
We're ready to use the "window.close()" method. In the parent page add the following
closing link:
<body>
<a href="javascript: open_a_window_please()">Click here to open a window.</a>
<a href="javascript:lovechild.close()">Click here to close the child window.</a>
</body>
Dont forget you will need to use "flush" betwen your major parts otherwise it might
not get sent to the browser right away.
Mike
P.S. Alot of PC's dont allow window.open anymore. People install ad blockers so it
doesn't work.
*********** REPLY SEPARATOR ***********
>
> I gave up on reinventing the wheel and i am trying to use that
>middle-page method you guys mentioned. To make things a little more
>transparent to the user, i thought of using a popup window instead, you
>know, a tiny window pops up, with the code to insert the comment on the
>database, and closes right after it does so.
>
> but err..how can i close it right after the database insert?
>
> Pag
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello friends.
Somehow, I cannot find the right code here.
I have a radio group with options as follows:
value1 = orgname
value2=orgcity
value3=orgsize
value4=orghead
When the user chooses "orgname" he must be redirected to the page ../orgname.php
When the user chooses "orgcity" he must be redirected to the page ../orgcity.php
...and so on.
Can you please help me with the code?
Thanks
Denis
--- End Message ---
--- Begin Message ---
> Somehow, I cannot find the right code here.
>
> I have a radio group with options as follows:
> value1 = orgname
> value2=orgcity
> value3=orgsize
> value4=orghead
>
> When the user chooses "orgname" he must be redirected to the page
> ../orgname.php
> When the user chooses "orgcity" he must be redirected to the page
> ../orgcity.php
> ...and so on.
Say your radio group was named "choice" then you could do something like
this:
Header("Location: http://yourdomain.com/{$_POST['choice']}.php");
Throw in some validation to $_POST['choice'] (or $_GET['choice']) to
make sure you are directing to the directory you should be directing to.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
redhat, apache2.0.43 (as dso). compiles and runs without a problem
php4.3.0release fails to utilize php.ini settings. ignores changes to the
ini file.
./configure --with-config-file-path=/usr/local/apache2/conf/php.ini --with-a
pxs2=/usr/local/apache2/bin/apxs --with-mysql (got no errors)
this was not an issue when i had 4.3.0RC2 installed in the exact same
manner!
ive tried this twice, reinstalling apache as well with not difference and
since php otherwise works with its defaults i have a feeling this might be a
bug with the release!?
any help appreciated,
omer.
"The Doctor" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Sat, Dec 28, 2002 at 04:04:14AM -0700, Rick Widmer wrote:
> > At 08:40 PM 12/27/02 -0700, The Doctor wrote:
> >
> >
> > >Is it just my or are there problems with static Aapche 1.3.27 compiles?
> >
> > I don't know if it is _just_ you, but my static install compiled and is
> > running just fine.
> >
> > SuSE 8.0
> >
> > php 4.3.0
> >
> > Apache 1.3.27
> >
> > Mod_SSL 2.8.12-1.3.27
> >
> > OpenSSL 0.9.6h
> >
> > ming 0.2a
> >
> > pdflib 4.0.3
> >
> > ./configure --with-apache=../apache --with-mysql --with-pgsql=/usr
> > --enable-cli --enable-calendar --enable-debug=no
> > --with-config-file=/web/conf --with-PEAR --with-jpeg-dir=/usr/local
> > --with-phg-dir=/usr/local --with-zlib-dir=/usr/local --with-gd=/usr
> > --enable-gd-native-ttf --with-freetype=/usr/include/freetype2
>
> --with-pdflib=/usr/local --with-ming --enable-magic-quotes --with-mm=../mm
> > --with-pspell
> >
> >
> >
> > >
> > >Script started on Fri Dec 27 20:34:45 2002
> > >nl2k.ca//usr/source/php-4.3.0$ cat configphp
> > >
> > >configure --prefix=/usr/contrib --localstatedir=/var
> > >--infodir=/usr/share/info --mandir=/usr/share/man --with-low-memory
> > >--with-elf --with-x --with-mysql --with-zlib --enable-track-vars
> >
>--enable-debug --enable-versioning --with-config-file-path=/usr/local/lib
> >
>--with-iconv=/usr --with-openssl=/usr/contrib --enable-ftp --with-gd=/usr
> > >--enable-imap --with-bz2
> > >--with-apache=/usr/source/apache_1.3.27_nonSSL/
> > >--with-pgsql=/usr/contrib/pgsql --enable-gd-native-ttf
> > >--with-jpeg-dir=/usr --with-png-dir=/usr
> > >--with-freetype-dir=/usr --with-xpm-dir=/usr/X11/lib
> >
>
> Same result adding in --enable-cli and --with-PEAR .
>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> --
> Member - Liberal International On 11 Sept 2001 the WORLD was violated.
> This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED]
> Society MUST be saved! Extremists must dissolve.
> Merry Christmas 2002 and Happy 2003
--- End Message ---
--- Begin Message ---
Hi Everyone,
I have one file with several sections of code which I have so far
accessed using a good old fashioned - - if ($HTTP_GET_VARS['action'] ==
"Update") - - however I now want to include this code within some other
web pages, I thought I may be able to use the following code - -
include("/modules.php?action=Update") - - however the code does not run.
Hoping someone can help me out on a way to overcome this. I am running
IIS 5, and PHP 4.2.3
Thanks
Stephen
--- End Message ---
--- Begin Message ---
> I have one file with several sections of code which I have so far
> accessed using a good old fashioned - - if ($HTTP_GET_VARS['action']
==
> "Update") - - however I now want to include this code within some
other
> web pages, I thought I may be able to use the following code - -
> include("/modules.php?action=Update") - - however the code does not
run.
> Hoping someone can help me out on a way to overcome this. I am
running
> IIS 5, and PHP 4.2.3
When you include() a file, it has the same variable scope as the file it
was included from. So, if you have the following code:
$action = "Update";
include("modules.php");
Then you can use $action in modules.php and it'll be set to "Update".
modules.php will have the same variables as the file that included it.
I hope that helps...
---John Holmes...
--- End Message ---
--- Begin Message ---
I can't get this to work, I'm using RH 8 with php 4.2.2.
Is there a way to fix this? I think its something to do with ucd-snmp
and me needing to use net-snmp but I'm not sure.
Any ideas?
Thanks
--- End Message ---
--- Begin Message ---
Can't see anything in the changelog but after upgrading to 4.3.0 I get an error when
using leak();
Fatal error: Call to undefined function: leak() in .........
I was previously using 4.2.3 and it worked fine.
I upgraded with the Windows Binaries (PHP 4.3.0 installer [1,028Kb] - 27 December
2002) and running on Win2k/Apache.
The function still shows as being a function as such..
http://www.php.net/manual/en/function.leak.php
and there is no notices that it won't work with 4.3.0
I can probably run the script without the function fine but has anyone else found any
problems with using this function in 4.3.0 or have I configured something wrong? :P
--- End Message ---
--- Begin Message ---
leak() is only included if you compile PHP with debug mode.
Out of interest, why on earth would someone in user-space be using
the leak() function.
-Sterling
> Can't see anything in the changelog but after upgrading to 4.3.0 I get an error when
>using leak();
> Fatal error: Call to undefined function: leak() in .........
>
> I was previously using 4.2.3 and it worked fine.
> I upgraded with the Windows Binaries (PHP 4.3.0 installer [1,028Kb] - 27 December
>2002) and running on Win2k/Apache.
>
> The function still shows as being a function as such..
> http://www.php.net/manual/en/function.leak.php
> and there is no notices that it won't work with 4.3.0
>
> I can probably run the script without the function fine but has anyone else found
>any problems with using this function in 4.3.0 or have I configured something wrong?
>:P
>
--- End Message ---
--- Begin Message ---
Ah thank you. :)
I can't remember why it was added but its never done any noticable harm. :P
----- Original Message -----
From: "Sterling Hughes" <[EMAIL PROTECTED]>
To: "Detritus" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, December 29, 2002 4:28 AM
Subject: Re: [PHP] PHP 4.3.0, function removed?
> leak() is only included if you compile PHP with debug mode.
>
> Out of interest, why on earth would someone in user-space be using
> the leak() function.
>
> -Sterling
>
> > Can't see anything in the changelog but after upgrading to 4.3.0 I get
an error when using leak();
> > Fatal error: Call to undefined function: leak() in .........
> >
> > I was previously using 4.2.3 and it worked fine.
> > I upgraded with the Windows Binaries (PHP 4.3.0 installer [1,028Kb] - 27
December 2002) and running on Win2k/Apache.
> >
> > The function still shows as being a function as such..
> > http://www.php.net/manual/en/function.leak.php
> > and there is no notices that it won't work with 4.3.0
> >
> > I can probably run the script without the function fine but has anyone
else found any problems with using this function in 4.3.0 or have I
configured something wrong? :P
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
"Detritus" <[EMAIL PROTECTED]> wrote in message
006401c2aef5$6cc70cc0$8800a8c0@rincewind">news:006401c2aef5$6cc70cc0$8800a8c0@rincewind...
> Ah thank you. :)
> I can't remember why it was added but its never done any noticable harm.
:P
>
Flavouring code with documentation can sometimes be useful. <g>
Happy new year
gamin.
--- End Message ---
--- Begin Message ---
At 11:29 AM 12/28/02 -0700, The Doctor wrote:
On Sat, Dec 28, 2002 at 04:04:14AM -0700, Rick Widmer wrote:
> At 08:40 PM 12/27/02 -0700, The Doctor wrote:
> ./configure --with-apache=../apache --with-mysql --with-pgsql=/usr
> --enable-cli --enable-calendar --enable-debug=no
> --with-config-file=/web/conf --with-PEAR --with-jpeg-dir=/usr/local
> --with-phg-dir=/usr/local --with-zlib-dir=/usr/local --with-gd=/usr
> --enable-gd-native-ttf --with-freetype=/usr/include/freetype2
> --with-pdflib=/usr/local --with-ming --enable-magic-quotes --with-mm=../mm
> --with-pspell
vs.
> >configure --prefix=/usr/contrib --localstatedir=/var
> >--infodir=/usr/share/info --mandir=/usr/share/man --with-low-memory
> >--with-elf --with-x --with-mysql --with-zlib --enable-track-vars
> >--enable-debug --enable-versioning
--with-config-file-path=/usr/local/lib
> >--with-iconv=/usr --with-openssl=/usr/contrib --enable-ftp
--with-gd=/usr
> >--enable-imap --with-bz2
> >--with-apache=/usr/source/apache_1.3.27_nonSSL/
> >--with-pgsql=/usr/contrib/pgsql --enable-gd-native-ttf
> >--with-jpeg-dir=/usr --with-png-dir=/usr
> >--with-freetype-dir=/usr --with-xpm-dir=/usr/X11/lib
What I have that you do not:
cli - create command line interface executable program.
calendar - fancy tricks with dates.
pear - a library of handy functions
gd-native-ttf
pdflib - create pdf files
ming - create swf files
magic-quotes - eliminates a lot of addslashes()
mm - I'm not sure
pspell - spelling checker
I don't think anything I added would make any difference.
Things that look wrong to me:
--with-low-memory, --with-elf and --with-x are not listed as valid options
in ./configure --help, and look scary to me. Get rid of them.
You used enable-zlib, but the correct statement is with-zlib or with-zlib-dir.
--enable-track-vars - is enabled by default and ignored for a couple of php
versions now.
--enable-versioning - is only needed when you want to run more than one PHP
module version at the same time.
The next thing to try...
xpm-dir, bz2, imap, iconv are the modules you are using that I am
not. Try compiling without them and see what happens.
I don't see where any of these _should_ affect things, but I've gotten in
trouble before using options I did not need...
--prefix - --with-apache specifies where the resulting files are placed, so
prefix is not relevant to static install.
localstatedir, infodir, mandir - not relevant to a static install because a
php module does not use any of the directories specified by these.
Rick
--- End Message ---
--- Begin Message ---
I have the following code with a rather odd behaviour:
<html><head><title>Test></title></head><body>
<?php
$string='This is some text which will eventually need
to be split<p>
Hopefully it gets done here</p><p>
I would like that very much</p>
<p>but whether it will happen or not</p>
<p>is difficult to say.</p>';
$Xarray=preg_split('/(?=<p>)/',$string,-1,
'SPLIT_DELIM_CAPTURE');
$count=count($Xarray);
for ($i=0;$i < $count;){
print $Xarray[$i];
//print $i;
$i++;
}
?>
</body></html>
The behaviour is that on the last '<p>' delimiter that
is supposed to be returned instead returns 'p>',
leaving of the first '<'. Below is the source:
<html><head><title>Test></title></head><body>
This is some text which will eventually need to be
split<p>
Hopefully it gets done here</p><p>
I would like that very much</p>
<p>but whether it will happen or not</p>
p>is difficult to say.</p></body></html>
This was done as a test to figure out what was going
on. I am probably making some stupid newbie mistake,
but I have no idea what it is. Any ideas?
Best,
Nik
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--- End Message ---
--- Begin Message ---
On Sunday 29 December 2002 09:14, Stephen wrote:
> Since I like new things and all, I decided to download and install PHP 4.3.
> Before, I had the latest (4.2.3) and IIS worked fine. But then, after
> uninstalling PHP and installing the new one, it just quit working. I go to
> http://localhost/ and nothing comes up except a "This page cannot be
> displayed" thing since I'm using IE. Any ideas why this is happening?
Turn on error reporting and log to file and examine it for any clues.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
You can tell how far we have to go, when FORTRAN is the language of
supercomputers.
-- Steven Feiner
*/
--- End Message ---
--- Begin Message ---
Ok, I am a bad coder. :( I can't figure this out at all:
$fileID = fopen("nicknames.txt", 'r');
$stuff = fread($fileID, filesize("nicknames.txt")); fclose($fileID);
if (strlen($stuff) > 0) $priorNickNewLine = "\n";
$nicks = explode("\n", $stuff);
The last line produces the Warning.. why? I am trying to read contents from
nicknames.txt and split according to the newline character so that each nickname is an
array element.
What did I do wrong? :(
Phil
--- End Message ---
--- Begin Message ---
Hello!
I just want to get the actual date and time which works fine with
date(). The problem is that php doesn't give the european
daylight-saving-time in summer, so the time shown is offset by 1 hour in
summer. It seems that my internet service provider doesn't adjust the
clock of the server to this. How can I avoid this without manually
correct it every spring/autumn?
Martin
--- End Message ---
--- Begin Message ---
hi,
Windows XP, Apache 2.0.43(Win32) with PHP 4.3 can't load DLL
'php_domxml.dll'.
it pops-up: Unknown(): unable to load dll'C:\php\extensions\php_domxml.dll'
if I use the old 'php_domxml.dll' from PHP 4.2.4, it works fine. I'm using
libxml2-2.4.30, expat 1.95.4.
by the way, 'libxml2.dll' is not packed in the PHP 4.3 Windows distribution,
although it mentions that it does in the PHP documentation.
thanks in advance
rui
--- End Message ---