Parse Error Syntax Error Unexpected T_variable Expecting T_function Codeigniter
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 parse error syntax error unexpected expecting function t_function about Stack Overflow the company Business Learn more about hiring developers or posting
Unexpected End Of File, Expecting Function (t_function)
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack syntax error, unexpected '$data' (t_variable), expecting function (t_function) Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up unexpected T_VARIABLE, expecting T_FUNCTION up vote 11 down vote favorite 3 syntax error, unexpected 'class' (t_class) in codeigniter I am expecting this to be a basic syntax error I overlooked, but I can't figure it out. In a PHP script, I keep getting the following error. Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in [path]/scripts/users/database_connection.php on line 4 This occurs when my script to connect to the database is called with an include_once(). I stripped my script down to the most basic code (leaving in what
Syntax Error Unexpected '$this' (t_variable)
is required by other code), and it still is calling this error. I have struggled with this for a while, and just wondered if anyone else could spot somewhere I went wrong. php sqlite syntax-error share|improve this question asked Jun 26 '11 at 20:50 Ryan Leonard 5241525 add a comment| 4 Answers 4 active oldest votes up vote 14 down vote accepted You can not put $connection = sqlite_open("[path]/data/users.sqlite", 0666); outside the class construction. You have to put that line inside a function or the constructor but you can not place it where you have now. share|improve this answer answered Jun 26 '11 at 20:53 Sabeen Malik 9,19821940 Thank you, first time I tried to use OOP. –Ryan Leonard Jun 26 '11 at 20:57 @Rhino , its aright. @Lekensteyn has done a wonderful job and shows you how you should ideally do it. –Sabeen Malik Jun 26 '11 at 20:58 add a comment| up vote 13 down vote You cannot use function calls in a class construction, you should initialize that value in the constructor function. Fr
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 codeigniter parse error syntax error unexpected the company Business Learn more about hiring developers or posting ads with us Stack syntax error unexpected function t_function Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of
Class Constructor Php
6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Codeigniter - Parse error: syntax error, unexpected '[' in … user_controler.php [closed] up vote 2 down vote favorite http://stackoverflow.com/questions/6486660/unexpected-t-variable-expecting-t-function 1 I've been trying to run an existing Codeigniter project that's been finished by a friend. At his computer everything works just fine but when I try to run it on mine this message is shown in the browser: Parse error: syntax error, unexpected "[" in C:\wamp\www\P-project\application\controllers\user_controler.php on line 88 This is the code on line 88: $data = []; This is the code for the function: function Shownews(){ $this->load->model('user'); $data = http://stackoverflow.com/questions/16752045/codeigniter-parse-error-syntax-error-unexpected-in-user-controler-ph []; $data['news'] = $this->user->getNews(); $this->load->vars($data); } He's done it so the project URL is : http://localhost/P-project/index.php/user_controler/log We're both using Wampserver for the connection and Netbeans for the project. If anyone can help please do so as soon as you are able, it is urgent. Thank you. php codeigniter share|improve this question edited May 25 '13 at 17:26 Bibhas 7,757114478 asked May 25 '13 at 17:18 John Young 2612 closed as too localized by cryptic ツ, HamZa, Madara Uchiha♦, Jocelyn, andrewsi May 26 '13 at 3:28 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question. I don't know why this question is closed. I had the same problem. It's not Codeigniter specific, but other than that I don't see why this is too localized. –SPRBRN Nov 18 '14 at 15:47 add a comment| 1 Answer 1 active oldest votes up vote 22 down vote Check your PHP version first. The short hand form for
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss http://stackoverflow.com/questions/28580789/codeigniter-parse-error-syntax-error-unexpected-this the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow http://www.dreamincode.net/forums/topic/245340-parse-error-syntax-error-unexpected-t-string/ Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each syntax error other. Join them; it only takes a minute: Sign up Codeigniter - Parse error: syntax error, unexpected '$this' up vote -5 down vote favorite I am starting to learn codeigniter. I get this error while trying to run the project. Parse error: syntax error, unexpected '$this' (T_VARIABLE), expecting ';' or '{' in C:\xampp\htdocs\Codeigniter\application\models\post.php on line 5 My Model-post.php: syntax error unexpected class Post extends CI_Model{ function get_posts($num=20, $start=0) $this->db->select()->from('posts')->where('active',1)->order_by('date_added','desc')->limit($start,$num); $query=$this->db->get(); return $query->result_array(); } } My Controller-posts.php: load->model('post'); $data['posts'] = $this->post->get_posts(); print_r($data['posts']); } } php codeigniter share|improve this question edited Feb 18 '15 at 18:00 tereško 42.6k1567124 asked Feb 18 '15 at 10:05 Pradeep 167 Compare this function header: function get_posts($num=20, $start=0) with this one: function index(){ –Rizier123 Feb 18 '15 at 10:10 1 I think the error is on this line: function get_posts($num=20, $start=0). You declare a function without opening the brace. Add the opening brace like this function get_posts($num=20, $start=0) { It's surprising you didn't open the brace, yet you are closing it on the second-to-last line. –Michael Woyo Feb 18 '15 at 10:11 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted function get_posts($num=20, $start=0) You're missing the brace from this function. It should be; function get_posts($num=20, $start=0) { share|improve this answer answered Feb 18 '15 at 10:10 Craig 1,5371510 I dunno why hav
of 1 New Topic/Question Reply 10 Replies - 3658 Views - Last Post: 29 August 2011 - 01:52 PM Rate Topic: #1 creativecoding Hash != Encryption Reputation: 931 Posts: 3,216 Joined: 19-January 10 Parse error: syntax error, unexpected T_STRING Posted 29 August 2011 - 11:57 AM God, I'm in one of those projects where it's all fine and dandy on my two different servers, but as soon as the client test it, it doesn't work and I look like a complete retard while hindering any future opportunities with this client. Everything works _FINE_ on my end. But as soon as he tried it, he gets this error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in (file) on line 4 The file it's having the problem in is a class. Line 4: Quotepublic $username; Just a note, he's running 4.X and I'm running 5.3, could that affect it? I wrote it for 4.3, but checked it using this (which I have been told isn't that reliable). Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: Parse error: syntax error, unexpected T_STRING #2 Martyr2 Programming Theoretician Reputation: 4954 Posts: 13,366 Joined: 18-April 07 Re: Parse error: syntax error, unexpected T_STRING Posted 29 August 2011 - 12:01 PM Show us the whole class creative... don't get cheap on us now! That error is usually involved with the code around the line it is bitching about, not the exact line. Was This Post Helpful? 1 Back to top MultiQuote Quote + Reply #3 creativecoding Hash != Encryption Reputation: 931 Posts: 3,216 Joined: 19-January 10 Re: Parse error: syntax error, unexpected T_STRING Posted 29 August 2011 - 12:05 PM get_contents("adminData.txt"); $file = explode(", ", $file); $this->username = $file[0]; } public function links(){ $links = array("Manage forms" => "manage.php", "New form" => "newForm.php", "Manage bans" => "bans.php", "Account" => "account.php"); foreach($links as $name => $link){ echo '' . $name . '
'; } } public function login($username, $password){ $file = $this->get_contents("adminData.txt"); $file = explode(", ", $file); if($username == $file[0] && sha1($password) == $file[1]){ $_SESSION['logged_in'] = true; return true; } else { $_SESSION['logged_in'] = false; return false; } } public function logout(){ $_SESSION['isadmin'] = false; return true; } public function get_contents($file){ $fh = fopen($f