Re: [PHP] foreach fails on unitialized array?

2002-08-29 Thread Eric Pignot

I would expect foreach to treat an unitialized variable as an empty
array and hence do nothing. Is this the expected behaviour?

if(is_array($myvar)) foreach($myvar as $key = $value ) {
  ...
}

other possibility, so that the foreach is run each time (and it doesn't
affect the source code, you can put it wherever you want) :
if(!is_array($myvar)) {
$myvar = array();
}

regards !

Eric




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




[PHP] Re: tmpnam filename

2002-08-29 Thread Eric Pignot

Why do you use tmpfile and not tempnam, as you write it in the header of
your message ? it returns the name of the file, as you expect...
string tempnam ( string dir, string prefix)

Then, you'll just need to open the file returned by tempnam and write all
data inside...

regards

Eric



Rus Foster [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 Hi All,
  I'm fairly new to this list/PHP and I've already hit a bit of a brick
 wall. I'm trying to write some data out to a temporary file then make a
 passthru call so that another program can take the file as input on the
 command line

 I first tried

  print pDo stuff/p;
$temp = tmpfile();
fwrite($temp, $text);
passthru(/path/to/program $temp);
fclose($temp); // this removes the file

 However I realised that $temp was a file handle rather than a filename. Is
 there anyway I can get the filename? A google and search on php.net
 doesn't show anything obvious

 Rgds

 Rus

 --
 http://www.fsck.me.uk - Rant wibble wave
 http://shells.fsck.me.uk - Hosting and stuff




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




[PHP] Re: Cannot get data from form.

2002-08-29 Thread Eric Pignot

This is really a FAQ, I would suggest that you read a bit more documentation
before posting.

Eric


Le Van Thanh [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
- I have installed PHP4.2.2 with Apache 1.3.26 on Solaris7.
And now I have problems with getting data from form.
I have 2 pages test.html and welcome.php as following:

test.html---
-
form userDetails method=post action=welcome.php
Enter your Name: br
input type=text  value= name=name
input type=submit value=Enter name=welcome
/form
--welcome.html-

?php
print  $name ;
?

===

Then I cannot get the value of input name.
But if I write  print $_POST['name']; or  print
$HTTP_POST_VARS['name'];, it's ok.

Is there something wrong when I install PHP?
Thanks a lot.






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




Re: [PHP] Re: Doing system things with PHP

2002-08-26 Thread Eric Pignot

 kill -HUP `cat /var/run/httpd.pid`



 If you execute this as nobody, I believe it will work, but I haven't

 tested it.

nope, it won't, as you need to be the owner to send a signal to a process.

regards.

Eric




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




Re: [PHP] check unread messages in a forum

2002-08-26 Thread Eric Pignot

the method explained by Stas is the most common method used on all boards.
But if you need a more precise method, that will also require more
ressources from you server, what you can do is have a specific DB table
called msg_read taking 2 parameters : msg_id, user_id.
- Each time a user reads a message, you insert the pair msg_id/user_id.
- Each time the user reloads a page,you do something like this :
$sql = select msg_id from msg_read where user_id = .addslashes($user_id);
// process $sql query
$msg_list = array();
while ( $row = getNextRow($mysqlResult)){
array_push($msg_list, $row[0]);
}
- when displaying the list of all message you just check if the message is
in the array $msg_list
if ( in_array($currentMsg, $msg_list)){
echo READ;
}else{
echo UNREAD;
}

regards

Eric






 Just store the user's last log-in date/time either in the database or in
 cookie. On the next log-in select * messages where creationDate 
 $userLastLoginDate and highlight those selected. It won't work for every
 particular unread message, but I doubt if one needs to be that much
 specific.

 HTH, Stas

 - Original Message -
 From: Charlotte [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, August 26, 2002 1:04 PM
 Subject: [PHP] check unread messages in a forum


  I have made a forum in PHP, and the users are logged in using cookies. I
  want all new threads (and if there are new replies in an old thread) to
be
  highlight or something like that.
 
  How do I check if a user has read a message or not?
 
 
 
  /Charlotte
 
 
 
 
  --
  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




Re: [PHP] check unread messages in a forum

2002-08-26 Thread Eric Pignot

the method explained by Stas is the most common method used on all boards.
But if you need a more precise method, that will also require more
ressources from you server, what you can do is have a specific DB table
called msg_read taking 2 parameters : msg_id, user_id.
- Each time a user reads a message, you insert the pair msg_id/user_id.
- Each time the user reloads a page,you do something like this :
$sql = select msg_id from msg_read where user_id = .addslashes($user_id);
// process $sql query
$msg_list = array();
while ( $row = getNextRow($mysqlResult)){
array_push($msg_list, $row[0]);
}
- when displaying the list of all message you just check if the message is
in the array $msg_list
if ( in_array($currentMsg, $msg_list)){
echo READ;
}else{
echo UNREAD;
}

regards

Eric






 Just store the user's last log-in date/time either in the database or in
 cookie. On the next log-in select * messages where creationDate 
 $userLastLoginDate and highlight those selected. It won't work for every
 particular unread message, but I doubt if one needs to be that much
 specific.

 HTH, Stas

 - Original Message -
 From: Charlotte [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, August 26, 2002 1:04 PM
 Subject: [PHP] check unread messages in a forum


  I have made a forum in PHP, and the users are logged in using cookies. I
  want all new threads (and if there are new replies in an old thread) to
be
  highlight or something like that.
 
  How do I check if a user has read a message or not?
 
 
 
  /Charlotte
 
 
 
 
  --
  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




[PHP] Re: Output Compression output buffering..

2002-08-26 Thread Eric Pignot

Hi Gerard,

I never had any problem using output buffering...
Do you correctly dump the buffer when an error occurs ? I suppose you have
built your own error() function, a bit like this one :

exit_on_error($msg){
ob_end_clean();
echo $msg;
exit();
}

can you tell us a bit more concerning the way you handle the exit of your
program ?

regards

Eric



Gerard Samuel [EMAIL PROTECTED] a écrit dans le message de news:
[EMAIL PROTECTED]
 In an included file, I have an error handler that is using the 'output
 buffering' trick to
 dump a page in progress to display the error page.
 I also happened to have a switch to turn on output compression.
 When output compression is on, if an error is comitted while the page is
 displaying, I get an empty page,
 instead of the expected error page or the page hangs, depending on the
 browser.

 Has anyone gotten both forms of output control to work together without
 ill side effects??

 Thanks

 --
 Gerard Samuel
 http://www.trini0.org:81/
 http://dev.trini0.org:81/





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




[PHP] Re: Can someone - anyone see my error?

2002-08-25 Thread Eric Pignot

 form enctype=multipart/form-data action=postbit.php method=post
 input type=hidden name=5400 value=1000
 Send this file: input name=userfile type=file
 input type=submit value=Send File
 /form

I am not really replying to your question, but just as a remark, in php, a
variable needs to start with a letter or and underscire. (must be detailed
in the doc)
So I have absolutely no idea how PHP will interpret this line :
 input type=hidden name=5400 value=1000
(and I would be curious to know how it actually does ! can you tell me ? )

bye

Eric



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




[PHP] Re: Doing system things with PHP

2002-08-25 Thread Eric Pignot

Hi !

there is no way to apply a config file to apache without restarting the
webserver
the only way I know (which really does not mean that it is the only one !),
is to use the command apachctl or httpd. But those command need to be
launched as root, I think (try to login as root, then to a su nobody, and
try to launch apache like this. If it works, then a simple exec(apachctl
restart) should be enough, check the syntax of exec() there :
http://www.php.net/exec ).

If you need to be root to start apache, then you'll need to either build a
script that changes user to root, and lauches apachectl restart once
logged ( try the sudo command in your shell, it is available in any linux
distribution, or try freshmeat.net ),  or use the setuid bit so that any
user can start httpd with root provilege (which would work but wouldn't be
recommende. man chmod to know more about this).

regards

Eric



Liam Mackenzie [EMAIL PROTECTED] a écrit dans le message de
news: 008f01c24c98$895404c0$[EMAIL PROTECTED]
 Hey all,

 I need to restart apache using PHP.  Is this possible?
 Or, ar least apply a modified config file...

 PHP is running as nobody:nobody as is Apache.

 Thanks,
 Liam






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