Dynadot โ€” .com Transfer

Eh?

SpaceshipSpaceship
Watch

adam_uk

Established Member
Impact
20
hey kinda trying to get to grips with sessions (not getting very far)

i run this script;
PHP:
<?php 

session_start();

session_register("count");

$count++;

echo "$count";


?>

as it says in the book and i get this error

Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

ive looked through php.ini and everything seems to be ok i dont really want to turn register.globals on as its bad programming (or so people say) or is it that i have my error reporting to high?

[EDIT] I changed the error reporting as it says in the error but it didnt sort the porblem (as i thought it wouldnt)

also i uploaded the script the my web host and it worked fine

http://adamuk.kicks-ass.org/phpinfo.php is my phpinfo
http://www.bassment.net/phpinfo.php is my hosts phpinfo


[/EDIT]


any ideas to what im doing wrong?

the server is running

apache 1
windows 2000 server
php-4.3.3

cheers
adam
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
This is a very delicate area, as of php4. Your local server if running php4 where your online server prob is running php3. Thats why it works onlin and not on your local server.

Try doing sessions this way

PHP:
session_start();


if(isset($_SESSION['count'] )){
	$count = $_SESSION['count'];
    $count++;
	$_SESSION['count'] = $count;
}
else{
	$count = 0;
    $_SESSION['count'] = $count;
}

if(isset($_SESSION['count'] )){
    echo $_SESSION['count'];
}

Instead of using
PHP:
session_register("count")
use
PHP:
$_SESSION['count']="whatever"

The only way your code will work is if you turn register_globals on, which as you say is bad practic but it also brings up a lot of security issues!!

Let me know if this is of any help at all.
 
0
•••
hehe cheers mate

worked :)
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Zero Commission
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back