Click to See Complete Forum and Search --> : Error
the hater
Aug 24th, 2004, 09:21 AM
This Code Always Show An Empty Alert Whay ?:cool:
<?
$Language=($HTTP_COOKIE_VARS["Language"]);
if ($Language=="") {
setcookie("Language","English",time() + 43200);
echo"<script>alert('$Language');</script>";
}
?>
ober0330
Aug 24th, 2004, 09:33 AM
Because you never set the $Language variable equal to anything.
the hater
Aug 24th, 2004, 09:35 AM
and What About This ?
$Language=($HTTP_COOKIE_VARS["Language"]);
john tindell
Aug 24th, 2004, 01:11 PM
Ok your setting $Language to the value of a cookie.
Then if $Language is empty your writing a cookie.
And then your outputting the empty value in $Language
try this
<?
$Language=($HTTP_COOKIE_VARS["Language"]);
if (empty($Language)) {
setcookie("Language","English",time() + 43200);
echo"<script>alert('English');</script>";
}else{
echo"<script>alert('$Language');</script>";
}
?>
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.