FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Help for sending 2+ cookies in one page.





pixor
Hello. I am developing an image hosting site. You can upload multiple files at once. No registration is required in this site so I have found ways of tracking who uploaded which file. One of them is via cookies. Now the code is like this:
-------------
while ($i < $numberOfFiles) {
move_uploaded_file($_FILES["file" . $i]["tmp_name"], "img/" . $_FILES["file" . $i]["name"]);
$sql = mysql_query("INSERT INTO img (name, size, uploaderip, uploaderid, cat) VALUES ('$fRName', '$fSize', '$fUploaderIP', '$fUploaderID', '$fCat')");

if (!isset($_COOKIES["total"]))
setcookie("total", "0", time()+60*60*24*30*12*10);

$_COOKIE["total"]++;
setcookie("total", $_COOKIE["total"], time()+60*60*24*30*12*10);
setcookie("image[" . $_COOKIE["total"] . "]", $fRName, time()+60*60*24*30*12*10);
-----------------

now the problem here is I get "header already sent" error when trying to upload multiple files. One file is always OK but when I try multiple ones I get this error. Is there an easy way of doing this? THanks for help.
progman89
I'm not absolutely sure, but I'm reasonably certain that you can't create more than one cookie at a time from a script.
kv
Looks like your setcookie is inside the loop. Try copying all the files to server first and then set all cookies at the end. This might work.
dandelion
Be sure there is no HTML output before calling the setcookie function.
I guess some output (skipped in your example) can be found in your while control structure after the last setcookie, so the first calling of this function is ok, but the next is fail.
mathiaus
More of the code used is required I'd say to find the exact cause of the problem and preferable a url so we can check it out.

On another note, just to make sure you know this sint allowed to be hosted on Frihost sorry. Point A.9 of the TOS.
Grimboy
Besides, what's your problem with ImageShack?
Related topics
Help needed link/page checker
I need your help uploading home page
Need help with a page on my website
I Need Help For Intro Page On My Site
Help to Increase Page Rank !!!
Need MAJOR help with cookies! Mmm.... cookies....
help w/web page
Change the name back =/
Looking for something that can list links
Help me in CSS
Logout problem?
Problem With Bandwith
How to display different pages in target frames dynamicaly
history of my state
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.