Page 1 of 1

Random error?

Posted: Mon Feb 21, 2011 6:36 pm
by sn0re
I've pretty new to PHP, but i'm currently using this code

Code: Select all

<?php
$user = $_GET['user'];
$userfile = "users/" + $user + ".txt";
$fh = fopen($userFile, 'w+');
$numdiamonds = fread($fh, filesize($userFile));
$intdiamonds = (int)$numdiamonds;
$newdiamonds = $numdiamonds + 1;
fwrite($fh, $newdiamonds);
fclose($fh);
?>
and i'm just getting this error: Image
Any ideas? I have a file called sn0re.txt in the /users/ folder, and it has the number 0 in it. Also, my website that this is on is located at http://diamonds.net78.net/

Re: Random error?

Posted: Mon Feb 21, 2011 7:56 pm
by Weirdan
string concatenation operator is . (dot), not +

Re: Random error?

Posted: Tue Feb 22, 2011 10:26 am
by sn0re
So it should be $userfile = "users/".$user.".txt";
instead?

Re: Random error?

Posted: Tue Feb 22, 2011 10:29 am
by John Cartwright
sn0re wrote:So it should be $userfile = "users/".$user.".txt";
instead?
Try it

Re: Random error?

Posted: Tue Feb 22, 2011 10:35 am
by sn0re
It's just that my web host takes FOREVER to upload and PHP dosen't work on my computer.
EDIT:

Code: Select all

$userfile = "users/".$user.".txt";
dosen't work either :(