Parse Error Syntax Error Unexpected T_variable Expecting T_function Class
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company expecting function (t_function) php Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs syntax error, unexpected '$data' (t_variable), expecting function (t_function) Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, syntax error unexpected this t_variable just like you, helping each other. Join them; it only takes a minute: Sign up Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION up vote 2 down vote favorite Could someone tell me what I'm doing wrong?
Parse Error: Syntax Error, Unexpected T_variable In Php
I want to display the users online on specific rooms only. the code below is the function that calls my online.php this is under my chat.php when I load the page this function also loads. function whos_online() { if ( window.XMLHttpRequest ) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET", "online.php?room=", false); xmlhttp.send(); document.getElementById("whos_online").innerHTML = xmlhttp.responseText; } ONLINE.PHP this is the content of my online.php get_status_query ); if( mysql_num_rows( $get_current_status ) != 0 ) { while( $row_status = mysql_fetch_array( $get_current_status ) ) { if( $_SESSION['username'] == true ) { echo "
"; } } } } } $Online = new WhosOnline; $Online->DisplayUsers(); ?> Any help? php ajax syntax-error share|improve this question edited Aug 30 '12 at 10:18 hakre 134k26216390 asked May 1 '12 at 17:35 user1232117 23114 You made a type somewhere, look in the neighborhood of the error and see if there is a syntax error. –Zombaya May 1 '12 at 17:36 what do you mean by type?. the error points out to $rn = $_GET['room']; and i dont know why. –user1232117 May 1 '12 at 17:37 This is not how you should do it. Ever. –Ignacio Vazquez-Abrams May 1 '12 at 17:38 Should have been typo. And you can not have code inside a class, only within a method of a class. –Zombaya May 1 '12 at 17:38 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote accepte
Forum View Course 176 points Submitted by James Barclay about
Php Class Variables
3 years ago Confusing error with PHP objects - Unexpected T_VARIABLE, expecting T_FUNCTION Whenever I http://stackoverflow.com/questions/10401722/parse-error-syntax-error-unexpected-t-variable-expecting-t-function create a new instance of an object I receive this error: Parse error: syntax error, unexpected TVARIABLE, expecting TFUNCTION on line ...(in the example to come, line 10) The code passes https://www.codecademy.com/en/forum_questions/5211e84af10c607d6b000ff0 each task, however I just wanted to know whether this is actually a legitimate error in how I'm writing the code or whether it is a error not related to me. Below is the simplest code I have done that still produces the error.
` 1 vote permalink You're supposed to create the instance outside of the class: class Person{ } $me = new Person(); 322 points Submitted by DM about 3 years ago
not connect to SMTP host, mysql_num_rows() expects parameter 1 to be resource, unexpected T_STRING, unexpected T_ECHO, session had already been started, unexpected T_VARIABLE expecting '.' or ';', Use of undefined constant, Call to undefined function, headers already sent, Undefined variable, Undefined index /Undefined offset, unexpected T_IF, unexpected T_FOR, unexpected ')', Illegal offset type, unexpected '=' expecting ')', unexpected ... T_CONSTANT_ENCAPSED_STRING expecting ..., unexpected T_BOOLEAN_AND, unexpected '$variable' (T_VARIABLE) expecting function (T_FUNCTION), unexpected 'some_string' (T_STRING) expecting function (T_FUNCTION), unexpected '$var_name' (T_VARIABLE), unexpected '->' (T_OBJECT_OPERATOR), Missing argument ... for function_name(), zip_read() expects parameter 1 to be resource, syntax error unexpected 'unset' (T_UNSET) in ..., preg_match(): Compilation failed: nothing to repeat at offset, Cannot redeclare class, Call to undefined function curl_init(), Expects parameter 1 to be string; array given in, Expects parameter 1 to be array; string given in, domdocument.loadhtml Unexpected end tag, simplexml_load_string() / loadXML() Input is not proper UTF-8 indicate encoding, session_start() The session id is too long or contains illegal characters, preg_replace / preg_match Unknown modifier, Invalid argument supplied for foreach(), Call to undefined method stdClass, Call to a member function bind_param() on boolean, Class finfo not found - First, to be sure that PHP displays all errors and warning messages, add this code at the beginning of the PHP script. ini_set('display_errors',1);error_reporting(E_ALL); • Parse error: syntax error, unexpected '/' in ... Cause: - Posible forgot a slash "/" in the comment line.