Forum Moderators: coopster
sometimes the error isnt always on that line it says. Look before that line to see if theres anything that may cause the script to say theres an error on that line.
You may of missed a ; or a ' on the previous line or something more complicated like an opening bracket a few lines before may not be closed in the right place or not at all.
:)
setcookie(string username[string = $_COOKIE['$username']]);
setcookie(string password[string = $_COOKIE['$password']]);
had a lookbut couldnt spot anything
Have a look through php.net's guide to setting cookies.
[uk3.php.net...]
Well, the error is because of the 'string' and 'string =' parts, and you're only supplying one parameter - the name of the cookie (which won't cause an error but isn't likely to be what you're expecting). I assume you're following the function prototype - that's just telling you what sort of data to supply to the function. It's telling you, for example, that this is correct:
setcookie("cookiename","cookievalue");
because the parameters need to be strings, as opposed to:
setcookie(37, 16.4);
which is incorrect because those are numbers.
However, I'm not understanding what you're trying to accomplish. If my user name is joebob, it looks like you're trying to set a cookie named joebob that has a value that you're getting from a cookie named joebob. Are you trying to renew a cookie for another hour? If so, how about:
setcookie($_COOKIE[$username],$_COOKIE[$username],$hour));
That's assuming you've assigned the variable $username previously. Or if you're trying to set it from the posted user name value, change the second parameter above to $_POST['username']
Also, it's not a good idea to save a password in a cookie.