3

Fatal error: Function name must be a string in /home/../public_html/updater.php on line 3

 1: <?php
 2:    
 3: $user_id = $_GET("uid"); /* <-- Line 3 */
 4: $user_name = $_GET("uname");
 5: $setting = $_GET("setting");
 6:    
 7: $MyString = $user_name + '[' + $user_id + ']{' + $setting + '} \n';
 8:    
 9: $myfile = fopen('database.txt', 'a');
10: fwrite($myfile, $MyString . '\n');
11: fclose($myfile);
12:    
13: ?>

What's the problem ?

6 Answers 6

24

Change your $_GET() code to $_GET[] with square brackets.

Sign up to request clarification or add additional context in comments.

Comments

5

In addition to using square brackets instead of parentheses, you should change line 7 to

$MyString = $user_name . "[" . $user_id . "]{" . $setting . "} \n";

and line 10 to

fwrite($myfile, $MyString . "\n");

You should use a period (.) for string concatenation instead of a plus (+). Also, when writing special characters (newline), you need to use double quoted strings instead of single quoted.

1 Comment

The reason why you had problems was single quotes don't allow for escaped chars like \n, \t, etc. aren't replaced.
3

To get array values in php you use the square brackets [] not like vb, i.e. $user_id = $_GET["uid"];

Comments

2

The syntax is wrong. Correct syntax is:

$user_id = $_GET["uid"];

Apply the changes wherever applicable.

Comments

1

Confused why you are using two newlines. Shouldn't one be enough?

Also your code is wrong with '\n', you can't do that.

You need to;

"\n" implicit newline that's properly interpreted (or chr(10))

CRLF (chr(13) + chr(10)) which is used for DOS formatted text files.

CR which is used for linux-formatted text files. (or chr(13))


Also, I would suggest using "ta" for the fopen call. Pulled from fopen() php page;

You should use the 't' mode if you are working with plain-text files and you use \n to delimit your line endings in your script, but expect your files to be readable with applications such as notepad. You should use the 'b' in all other cases.

References:

http://php.net/manual/en/function.fopen.php

http://www.december.com/html/spec/ascii.html (13 is considered carriage return or /r, 10 is considered newline or /n)

Comments

-1

Change All GET Methods:

$user_id = $_GET("uid"); /* <-- Line 3 */

to

$user_id = $_GET["uid"];

Done

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.