Parse Error Syntax Error Unexpected T_var
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the php unexpected t_variable workings and policies of this site About Us Learn more about Stack syntax error, unexpected t_variable Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs php syntax error unexpected 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 other. Join parse error: syntax error, unexpected '=' in them; it only takes a minute: Sign up PHP - Unexpected T_VAR when including a variable [closed] up vote -1 down vote favorite I get this error when I try and include a variable from an external php file: Unexpected T_VAR on line 1 Here is my external php code: Here is the
Parse Error: Syntax Error, Unexpected (t_variable)
PHP file that is including it: if($_POST['admincreate'] == "ok") { include('db.php'); $info = explode("::,", dbStr); $con=mysqli_connect($info[0],$info[1],$info[2],$info[3]); mysqli_query($con,"INSERT INTO admins (id, user, pass) VALUES ('" . $_POST['user'] . "', '" . $_POST['pass'] . "',0)"); } It works if I change the code to if($_POST['admincreate'] == "ok") { $dbStr = 'host::,username::,password::,database'; $info = explode("::,", $dbStr); $con=mysqli_connect($info[0],$info[1],$info[2],$info[3]); mysqli_query($con,"INSERT INTO admins (id, user, pass) VALUES ('" . $_POST['user'] . "', '" . $_POST['pass'] . "',0)"); } But I need the included file. If I change the included file to I get this error: Parse error: syntax error, unexpected '=' in .../db.php on line 1 And I find that the external php file has changed to How do I include this string properly without it giving me an error? P.S. The external php is generated by the main php file use fopen and fwrite, also the actual values of host, username, password, and database have been censored just because I feel better that way. Thanks in advance, -p0iz0n php include share|improve t
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 Business Learn more about hiring
Php Variable
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask php array Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Parse error: syntax error, unexpected T_VAR up vote 1 down vote favorite I want to output like this var data = { { "cname": "Albania" } { "cname": "Austria" } } http://stackoverflow.com/questions/16390233/php-unexpected-t-var-when-including-a-variable This code i tried but i am getting an error "Parse error: syntax error, unexpected T_VAR in C:\wamp\www\mvc\map\data.php on line 22" http://stackoverflow.com/questions/22831504/parse-error-syntax-error-unexpected-t-var or die('Query failed: ' . mysql_error()); $all_recs = array(); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $all_recs[] = $line; } var data = { echo json_encode($all_recs); }; // Free resultset mysql_free_result($result); // Closing connection mysql_close($link); ?> can anyone guide me how to fix this,thanks php json share|improve this question asked Apr 3 '14 at 8:09 Xavi 74241639 Where did you read that kind of syntax ?! –Royal Bg Apr 3 '14 at 8:11 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted I'm not sure why you want that, but you can mix js code in php like this, you may try $jsonData = json_encode($all_recs); echo "var data = {$jsonData}"; share|improve this answer answered Apr 3 '14 at 8:11 Rikesh 19k104267 1 +1 for understanding what the OP wanted ... i was clueless, thought about some weird kind of array ... –Y U NO WORK Apr 3 '14 at 8:12 Thanks it worked .... –Xavi Apr 3 '14 at 8:12 add a comment| up vote 0 down vote $data = "cname : Albania cname : Austria"; share|improve this answer answered Apr 3 '14 at 8:12 asd 988 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a
Detected You currently have javascript disabled. Several functions may not work. Please re-enable javascript to access full functionality. Parse error: syntax error, unexpected T_VAR in Started by RVCom, Mar 08 2010 05:40 PM Please log in to https://forums.phpfreaks.com/topic/194523-parse-error-syntax-error-unexpected-t-var-in/ reply 1 reply to this topic #1 RVCom RVCom Newbie New Members 1 posts Posted 08 March 2010 - 05:40 PM Hi when i visit my site (just uploaded) i got the next error:Parse error: syntax error, unexpected http://board.phpbuilder.com/showthread.php?10376460-RESOLVED-Parse-error-syntax-error-unexpected-T_VARIABLE T_VAR in /home/rvcom/public_html/boddies1/include/db.inc.php on line 198but i cannot find any failures in the db_inc.php file.. please help! This is line 198: var $database ='rvcom_boddies1'; return (@mysql_fetch_assoc($this->result));persistent) { $func = syntax error, unexpected 'mysql_pconnect'; } else { $func = 'mysql_connect'; } // Connect to the MySQL server $this->conn = $func($this->host, $this->user, $this->password); if (!$this->conn) { return false; } // Select the requested database if (!@mysql_select_db($this->database, $this->conn)) { return false; } return true; } function close() { return (@mysql_close($this->conn)); } function error() { return (mysql_error()); } function query($sql = '') { $this->result = @mysql_query($sql, $this->conn); return ($this->result != false); } function affectedRows() { return (@mysql_affected_rows($this->conn)); } function numRows() { return (@mysql_num_rows($this->result)); } function fieldName($field) { return (@mysql_field_name($this->result,$field)); } function insertID() { return (@mysql_insert_id($this->conn)); } function fetchObject() { return (@mysql_fetch_object($this->result, MYSQL_ASSOC)); } function fetchArray() { return (@mysql_fetch_array($this->result, MYSQL_NUM)); } function fetchAssoc() { var $database ='rvcom_boddies1'; return (@mysql_fetch_assoc($this->result)); } function freeResult() { return (@mysql_free_result($this->result)); }}define('BASEURL','http://www.rvcom.org/boddies1');/*define('BASEURLCSSNEW','http://static.css.in...fo/greenfairn
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 5 of 5 Thread: [RESOLVED] Parse error: syntax error, unexpected T_VARIABLE Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 10-27-2010,10:06 AM #1 LemonTea View Profile View Forum Posts Junior Member Join Date Oct 2010 Posts 3 [RESOLVED] Parse error: syntax error, unexpected T_VARIABLE Hello all! I'm very, very new in this PHP stuff [Just started this night!] And I was playing around when I got this error message: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\bohoo\index.php on line 30 PHP Code: set_time_limit(0);
functionutime(){
$time=explode("",microtime());
$usec=(double)$time[0];
$sec=(double)$time[1];
return$sec+$usec;
}
$start=utime();