[PHP] Only one instance of a script at a time !

2001-12-28 Thread Nicolas Guilhot

Running a php script with a cron job, how can I do to have only one instance
of the script running ?

Thanks for any answer.


Nicolas


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Only one instance of a script at a time !

2001-12-28 Thread Nicolas Guilhot

I was thinking about this solution, but what can I do if the script ends
prematurely. The file will never be deleted ??
Anybody has an example of how to use flock ?

Nicolas

Gerard Onorato [EMAIL PROTECTED] a écrit dans le message news:
[EMAIL PROTECTED]
 There may be a much easier method however why not write a file and then
check for it's existence on the next execution. Delete the file at the end
of
 execution to clear the way  for the next pass.

 Quick and dirty so probably at least on typo
 ?
 $pidFile = path/to/file/filename;
 if (!is_file ($pidFile)) {
 touch ($pidFile);
 // code to execute
 unlink ($pidFile);
 }
 ?
 On Fri, 28 Dec 2001 15:31:33 +0100, Nicolas Guilhot wrote:

 Running a php script with a cron job, how can I do to have only one
instance
 of the script running ?
 
 Thanks for any answer.
 
 
 Nicolas
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Limit script memory usage !!

2001-12-20 Thread Nicolas Guilhot

Hi all,
I need to limit the amount of memory that a script can use. Is there a
function that I can use to tell the script to die if its memory usage
 becomes greater than $MAX_MEMORY ! Or maybe, I could use a cron job to
monitor processes and kill them if they become too big ?

Thanks for your help.

Nicolas


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Dumped OK, Restore NOT

2001-12-05 Thread Nicolas Guilhot

Maybe you can try to launch the sql dump file from the SQL shell, not
directly from the command line. I think it will give you more feedback about
what is going on.
Go to the directory where you have your smarts.sql file.
Just type mysql smarts
And in the SQL shell type \. smarts.sql
If you are not in the directory of the file smarts.sql then you need to give
a full path to this file.

Hope it helps.

Nicolas

-Message d'origine-
De : René Fournier [mailto:[EMAIL PROTECTED]]
Envoyé : mercredi 5 décembre 2001 17:02
À : [EMAIL PROTECTED]; [EMAIL PROTECTED]
Objet : [PHP] Dumped OK, Restore NOT


Little problem with MySQL 3.23.46 under Windows ME. I'm trying to create
a database from an .sql file (the dumped remains of a functioning
database--also MySQL). The dumping was easy, but I'm having a problem
putting it back. I have a dumped file called smarts.sql that starts this
way:
-

# MySQL dump 8.14
#
# Host: localhostDatabase: smarts
#
# Server version3.23.38

#
# Table structure for table 'about'
#

CREATE TABLE about (
   id smallint(5) unsigned NOT NULL auto_increment,
   lang char(2) default NULL,
   recordname varchar(40) default NULL,
   key1 tinytext,
   key2 tinytext,
   status varchar(10) default NULL,
   title tinytext,
   par1 tinytext,
   PRIMARY KEY  (id)
) TYPE=MyISAM;

#
# Dumping data for table 'about'
#

INSERT INTO about VALUES (1,'en','about'
---(and so on)

This is what I'm doing to try to recreate the database locally:

1. I type mysqladmin create smarts

OK--I see a new directory called smarts (no files in it)

2. I type mysql smarts  smarts.sql

It pauses for a few seconds (seeming to input the file), then returns
the DOS prompt with no message, error or otherwise. Seems to have
worked, right? But when I check the 'smarts' database directory, there
are no files in it. (Incidentally mysqld is running.)

What am I doing wrong??

...Rene

---
René Fournier
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] 1 is not a valid MySQL-Link resource in /home/guestbook.php on line 112

2001-12-04 Thread Nicolas Guilhot

Check that you have not already close the connection to the mysql database.
Or maybe, the mysql_connect returned an error !

-Message d'origine-
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Envoyé : mardi 4 décembre 2001 08:42
À : [EMAIL PROTECTED]
Objet : [PHP] 1 is not a valid MySQL-Link resource in
/home/guestbook.php on line 112


any one here can help my problem?
(I 'am using hypermart.net hosting, so i am not sure which php version that
they
provided)

Here are the problems:

$sqlshow = SELECT * FROM $table ORDER BY id DESC LIMIT $show, $maxshow;
$result = mysql_db_query($database, $sqlshow);

 produce: 1 is not a valid MySQL-Link resource in /home/guestbook.php on
line
112

while (($myrow = mysql_fetch_array($result)))

 produce: Supplied argument is not a valid MySQL result resource in
/home/guestbook.php
on line 116

mysql_close();

 produce: 1 is not a valid MySQL-Link resource in /home/guestbook.php on
line
126

thanks.
hendro.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] HELP URGENT VARS !!!

2001-11-30 Thread Nicolas Guilhot

You can also use this syntax :
$var1=variable 1;
$var2=variable 2;
for ($i= 1; $i  3; $i++)
{
  echo ${var$i};
}

-Message d'origine-
De : Olivier Masudi [mailto:[EMAIL PROTECTED]]
Envoyé : vendredi 30 novembre 2001 12:02
À : [EMAIL PROTECTED]
Objet : [PHP] HELP URGENT VARS !!!


$name1=a; $name2=b;

I want to do this

for($i=0;$i$nbname;$i++)
 echo \$name$i;

output : a b 

where \$name$i=  $name1 , $name2 , $name3 ..

I try to print tha value of the vars $name1,.  not the string
$name1,

Is it possible 


REM : The vars $name1, com from a form where the number of  name input
are variable.


Thank you


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Installing PHP with windows

2001-11-21 Thread Nicolas Guilhot

You can also have a look to EasyPhp http://www.easyphp.org/ which installs
Apache, PHP and MySQL on Windows box.

-Message d'origine-
De : Rob Bennion [mailto:[EMAIL PROTECTED]]
Envoye : mercredi 21 novembre 2001 21:55
A : [EMAIL PROTECTED]
Objet : [PHP] Installing PHP with windows


Hi
I want to try out PHP and wanted to know if it is possible to install it
on a windows machine and use it with personal web server.

Any help would be appreciated.

thanks

Rob


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Problem with very big array !

2001-10-29 Thread Nicolas Guilhot

Hi guys,

I have an sql query returning a result of nearly 150 000 rows. I use the
PEAR DB::getAll method to retrieve this result as an array which is very big
indeed (about 300Mb). I can't use the MySQL LIMIT statement because I need
to do sorting stuff on the result array.
My concern is that even after processing the last line of the script, the
process continue running for about 20~30 minutes (I am watching running
processes using the unix command 'top'). For information, querying the
database, sorting the array and displaying results with a pager system only
takes 3 minutes.

I have made a short example that reproduces the problem. If you could test
it (IT WILL USE ABOUT 120Mb OF RAM) and tell me if you've got the same
problem it would be nice. You need to create a test database with the
following table :

CREATE TABLE test (
  id mediumint(20) NOT NULL,
  text varchar(255) NOT NULL default '',
  PRIMARY KEY  (id)
)

Then populate it with 150 000 rows using the populate.php script.
Finally, execute the query.php script and use top to see if the process
stops running quickly. For me it takes a lot of time to end (more than 20
minutes).
If you empty the database table, remove one character from the string in the
insertInto function and populate it again, it should work correctly.

Thanks for any answer !!

PS : I am using PHP 4.06, MySQL 3.23.41 and Apache on a bi-processor linux
box with 1Gb RAM.


//--
// populate.php
//--
?php
require_once(DB.php);

function getmicrotime()
{
  list($usec, $sec) = explode( ,microtime());
  return ((float)$usec + (float)$sec);
}

function insertInto($db)
{
  for ($cpt = 0; $cpt  15; $cpt++)
  {
$result = $db-query(INSERT INTO test VALUES('$cpt', 'This is the very
big test n° $cpt. With more text. This time it will take more memory, and
more time to execute. This is very strange. I do not understand why
???'));
  }
}


$db = DB::connect(mysql://user:password@localhost/test);
$time_start = getmicrotime();

insertInto($db);

$time_end = getmicrotime();
$time = $time_end - $time_start;
echo Execution time : $time seconds;
?
//-
//End of populate.php
//-



//-
//query.php
//-
?php
require_once(DB.php);

function getmicrotime()
{
  list($usec, $sec) = explode( ,microtime());
  return ((float)$usec + (float)$sec);
}

$db = DB::connect(mysql://user:password@localhost/test);
$time_start = getmicrotime();

$result = $db-getAll(SELECT * from test);

$time_end = getmicrotime();
$time = $time_end - $time_start;
echo Execution time : $time seconds;
?
//--
//End of query.php
//--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Update Query - Urgent

2001-10-23 Thread Nicolas Guilhot

Do you login to the database with a write access or a read only account ??

-Message d'origine-
De : Srinivasan Ranganathan [mailto:[EMAIL PROTECTED]]
Envoyé : mardi 23 octobre 2001 14:22
À : [EMAIL PROTECTED]
Objet : [PHP] Update Query - Urgent


Hi

I have a php script generate a sql update statement.
when i query the database, the update dosent happen.
but when i echo the sql string and copy and paste it
in my mysql client window, the update happens like it
should!

what am i missing/doing wrong here?

Thanks in advance
Srinivasan Ranganthan


*NEW*   Connect to Yahoo! Messenger through your mobile phone   *NEW*
   Visit http://in.mobile.yahoo.com/smsmgr_signin.html

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] preg_replace is modifying the type of replacement parameter !!

2001-09-11 Thread Nicolas Guilhot

Hi guys,

When I use preg_replace with an array of integer as the replacement
parameter, this function modifies the type of each array element to string.
I don't understand why it alters the content of the array while this
variable is not pass by reference (True or not ??).

I have just upgraded to PHP 4.0.6 and it I don't think it was the case in
PHP 4.0.4 (the version I was using before, without this problem).

Here is a short example that demonstrate my problem.

?php
$ary_pattern = array(@One@);
$ary_replace = array(1);
$string_before =  One example;
echo gettype($ary_replace[0]); // This line outputs 'integer'
$string_after = preg_replace($ary_pattern, $ary_replace, $string_before);
echo br$string_afterbr;
echo gettype($ary_replace[0]); // This line outputs 'string'
?

Is this a bug from preg_replace or am I doing wrong somewhere? Any help
would be appreciated.
Regards.

Nicolas Guilhot


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] preg_replace is modifying the type of replacement parameter !!

2001-09-11 Thread Nicolas Guilhot

I understand that RegEx works on strings, but I don't understand why this
function modifies the replacement parameter as it is not pass by-reference.

Nicolas

-Message d'origine-
De : Andrey Hristov [mailto:[EMAIL PROTECTED]]
Envoyé : mardi 11 septembre 2001 14:34
À : [EMAIL PROTECTED]
Objet : Re: [PHP] preg_replace is modifying the type of replacement
parameter !!


Hmmm, RegEx work on strings, so the engine needs strings. Because of that
your integers are converted to strings, if you want to
give their life back make
foreach ($arr as $k=$v){
$arr[$k]+=0;
}
Now all are integers.

Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
BALANCED SOLUTIONS


- Original Message -
From: Nicolas Guilhot [EMAIL PROTECTED]
To: Php General MailingList [EMAIL PROTECTED]
Sent: Tuesday, September 11, 2001 3:24 PM
Subject: [PHP] preg_replace is modifying the type of replacement parameter
!!


 Hi guys,

 When I use preg_replace with an array of integer as the replacement
 parameter, this function modifies the type of each array element to
string.
 I don't understand why it alters the content of the array while this
 variable is not pass by reference (True or not ??).

 I have just upgraded to PHP 4.0.6 and it I don't think it was the case in
 PHP 4.0.4 (the version I was using before, without this problem).

 Here is a short example that demonstrate my problem.

 ?php
 $ary_pattern = array(@One@);
 $ary_replace = array(1);
 $string_before =  One example;
 echo gettype($ary_replace[0]); // This line outputs 'integer'
 $string_after = preg_replace($ary_pattern, $ary_replace, $string_before);
 echo br$string_afterbr;
 echo gettype($ary_replace[0]); // This line outputs 'string'
 ?

 Is this a bug from preg_replace or am I doing wrong somewhere? Any help
 would be appreciated.
 Regards.

 Nicolas Guilhot


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Passing an array to a C program from a php script??

2001-07-02 Thread Nicolas Guilhot

Here is a solution I've found for my problem. I use join to convert my array
into a string. Then, I use exec to run the c program, having a pipe passing
the result from an echo.  I would like to know if this solution is a good
one (in term of speed, security...), and would appreciate your comments.
Thanks.


Nicolas

Here is a short example :
// Initialize the array
$ary_test = array(15, 150, 32, 46, 69, 40, 22);
// Convert it to a string
$str_test = join(' ', $ary_test);

// Execute the c program
exec(echo \$str_test\ | test1, $ary_result, $num_return);

// Display the return value and the result of the program
echo Return value : $num_return\n;
echo Result :\n;
print_r($ary_result);


-Message d'origine-
De : Nicolas Guilhot [mailto:[EMAIL PROTECTED]]
Envoye : lundi 25 juin 2001 12:59
A : [EMAIL PROTECTED]
Objet : [PHP] Passing an array to a C program from a php script??


Hi all,

I have a big array (nearly 1000 lines) that I would like to pass to a C
program. I don't want to create a temporary file to pass my array (If
possible ?!?), and I don't think the command line will fit my needs.

Is there a way to execute a program with a php string as the standard
input. Something like shell redirection 'c_program  input.file' but with
input.file being a php variable and not a real file ?? Any other solution
??

Hope I am clear enough !

Any help would be appreciated.


Nicolas

--



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Passing an array to a C program from a php script??

2001-06-25 Thread Nicolas Guilhot

Hi all,

I have a big array (nearly 1000 lines) that I would like to pass to a C
program. I don't want to create a temporary file to pass my array (If
possible ?!?), and I don't think the command line will fit my needs.

Is there a way to execute a program with a php string as the standard
input. Something like shell redirection 'c_program  input.file' but with
input.file being a php variable and not a real file ?? Any other solution
??

Hope I am clear enough !

Any help would be appreciated.


Nicolas

-- 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Print array items only once

2001-05-09 Thread Nicolas Guilhot

You can try to modify your SQL query and add the DISTINCT statement !! It
will return each distinct row only once.

example SELECT DISTINCT cat_id, cat_name FROM categories

Regards,

Nicolas

-Message d'origine-
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Envoyé : mercredi 9 mai 2001 12:02
À : [EMAIL PROTECTED]
Objet : [PHP] Print array items only once


Hi all,

I am querying the categories field in my database to rurn the various
categories that can be clicked on.

Problem is, if I have 5 items in a category, my categories query lists the
category 5 times..

I am trying to work out how to say:

while($qry = mysql_fetch_array($res)){
print $res[category]; but only once for this results array.
}

Can you help with this?

Many thanks.

Sean.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Check if a variable has been posted-- HOW?

2001-05-03 Thread Nicolas Guilhot

you can try
if (isset($HTTP_POST_VARS['posted_variable_name'])){
  // do something
}

-Message d'origine-
De : Martin Cabrera Diaubalick [mailto:[EMAIL PROTECTED]]
Envoyé : jeudi 3 mai 2001 13:10
À : [EMAIL PROTECTED]
Objet : [PHP] Check if a variable has been posted-- HOW?


Hi everyone

I'm lookign through the manual but can'f find it right now. How do I check
if a variable has been created through a posted form?

TIA


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] sessions and reg_globals=off

2001-05-03 Thread Nicolas Guilhot

When reg_globals is off, you can't access session vars just with $varA and
$varB (thess variables are not set), you need to use
$HTTP_SESSION_VARS['varA'] and $HTTP_SESSION_VARS['varB'] to access these
variables !!

-Message d'origine-
De : ahmad varoqua [mailto:[EMAIL PROTECTED]]
Envoyé : jeudi 3 mai 2001 16:31
À : Php General List
Objet : [PHP] sessions and reg_globals=off


Hello, I'm having a problem getting sessions to work with
register_globals=off.  The following 2 files work fine if reg_globals=on but
not when off.  When I look at the session file it reads like this:

!varA|!varB|

and not like it should:

varA|s:4:funk;varB|s:4:that;


//-sess01.php

?php
session_start();
session_register('varA');
session_register('varB');

?

form action=sess02.php
first name:input type=text name=varA
br
last name:input type=text name=varB
input type=submit value=send
/form


//sess02.php

?php

session_start();
print($varA $varB);

?

What do I have to do to make this work with register_globals off?  Thank you
very much for help.  (If I get some time/answers I think I'm gonna design a
page that shows sample scripts that work with reg_globals=on and their
equivalents with reg_globals=off; this might be beneficial for some
newbies--such as myself.  If anybody would like to contribute, please email
me and you'll be duly credited if such a project comes to fruition. Thanx!)

--ahmad.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] What's wrong with Apache + php + mysql on Windows?

2001-04-27 Thread Nicolas Guilhot

You can try to had HostnameLookups off in your httpd.conf if it is not
already present.
More info at http://www.apache.org/DELETE_ME/mod/core.html#hostnamelookups

---
 Hello, I can't understand the reason apache server running locally on my
 Win98 machine delays so much to respond browser when accesing php
 scripts in the form

 http://localhost/myscript.php

 When I transfer php scripts to host server via FTP, script execution is
 immediate, even remote server being in another continent.

 I was running apache + php + mysql on Win95 and delay was terrible. Now
 I moved to Win98 and delay became still worse.

 I know some parameter in httpd.conf or php.ini should be changed, but
 how to kwow which parameter?.
--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] About sessions !!

2001-04-24 Thread Nicolas Guilhot

You should also check if register_globals is set to ON in your php.ini file.
Otherwise you can't access you session variable just with $myvar !!

And in your code you never increment $myvar, so even if it works, you'll
always get 1.

Regards,

Nicolas Guilhot

-Message d'origine-
De : Yasuo Ohgaki [mailto:[EMAIL PROTECTED]]
Envoyé : mardi 24 avril 2001 16:11
À : [EMAIL PROTECTED]
Objet : Re: [PHP] About sessions !!


SID does not work  unless you enable trans sid.

Regards,
--
Yasuo Ohgaki


Hassan Arteaga [EMAIL PROTECTED] wrote in message
7F548E90E63BD1118E4600609707771F8BEFAF@goliath">news:7F548E90E63BD1118E4600609707771F8BEFAF@goliath...
Hi !!

I just begin with PHP( but is the same as ASP ) and testing some examples...

loock at the code:

Page 1- Session.php

?php
session_start();
$myvar = 1;
session_register(myvar);
?
html
head
meta http-equiv=Content-Type content=text/html; charset=windows-1252
meta name=GENERATOR content=Microsoft FrontPage 4.0
meta name=ProgId content=FrontPage.Editor.Document
titleNew Page 1/title
/head
body
Hello visitor, you have seen this page ? echo $myvar; ? times.p
To continue, A HREF=session1.phpclick here/A
/body
/html

___


Page 2- Session1.php
?php
session_start();
?
html
head
meta http-equiv=Content-Type content=text/html; charset=windows-1252
meta name=GENERATOR content=Microsoft FrontPage 4.0
meta name=ProgId content=FrontPage.Editor.Document
titleNew Page 1/title
/head
body
Hello visitor, you have seen this page ?php echo $myvar; ? times.p
Your SID is:  ?php echo SID; ? p
/body
/html


Page 1 is ok..but when I click to go to page 2  I receive this results..

Hello visitor, you have seen this page times.
Your SID is: SID

Who can tell me what happend !!

Thank you in advanced !!!

--
M. Sc. Hassan Arteaga Rodríguez
Microsoft Certified System Engineer
Network Admin, WEB Programmer
FUNDYCS, Ltd
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Problem with session vars !

2001-04-23 Thread Nicolas Guilhot

I am having problem with PHP4 session variables. I think I misunderstood how
they work, and I can't see what I'm doing wrong. Any help would be
appreciated. I am using the version from EasyPhp 1.1.1.

Below is a short example to explain my problem. I've got two php scripts.
'test1.php' which starts a session, set a variable $sess and register it as
a
session variable. It then redirects to 'test2.php' which only displays
session variables and switches $sess[var1] between true and false on each
call.

With the code in example, I retrieve the variable set by 'test1.php' on
'test2.php', but $HTTP_SESSION_VARS['sess']['var1'] is always true.
With the same code, If I set register_globals to off in my php.ini, I get
the opposite. I never retrieve the variable set by 'test1.php' on
'test2.php', but $HTTP_SESSION_VARS['sess']['var1'] is switches correctly.

What is wrong in this code ??

If I replace
  session_register('sess'); in 'test1.php'
by
  $GLOBALS['HTTP_SESSION_VARS']['sess'] = $sess;
and set register_globals to off everything works. Someone could explain to
me why ??

Best regards,

Nicolas



File test1.php
   ?
   function initSessionVar()
   {
 global $sess;
 // initialise sess variable for the new session
 $sess = array();
 $sess['user'] = test;
 $sess['var1'] = true;

 session_register('sess');
   }
   session_start();
   initSessionVar();

   header('Location: http://localhost/test2.php');
   exit;
   ?

File test2.php
   ?
   session_start();

   echo gettype($HTTP_SESSION_VARS['sess']) . BR;
   echo $HTTP_SESSION_VARS['sess']['user'] . BR;
   echo ($HTTP_SESSION_VARS['sess']['var1'] ? true : false);

   if ($HTTP_SESSION_VARS['sess']['var1']){
 $HTTP_SESSION_VARS['sess']['var1'] = false;
   }
   else{
 $HTTP_SESSION_VARS['sess']['var1'] = true;
   }
   ?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]