syntax-error

Getting a syntax error unexpected T_STRING for namespace line

余生长醉 提交于 2019-11-28 03:01:47
问题 Well, I keep getting Parse error: syntax error, unexpected T_STRING in /path/to/index.php on line 2 Googled my arse off and still nuthing, so far the index.php contains: <?php namespace Infire; # Line 2 ... I am using PHP 5.1 Any ideas? 回答1: The PHP namespace is only supported in PHP 5.3+ version Check this PHP 5.3.0 Release Announcement 回答2: I've found namespaces introduced in PHP 5.3 to suffer from multiple usability problems due to performance trade-offs, limitations of PHP's parser,

syntax-error: can't assign to operator

巧了我就是萌 提交于 2019-11-28 02:58:00
问题 def RandomString (length,distribution): string = "" for t in distribution: ((t[1])/length) * t[1] += string return shuffle (string) This returns a syntax error as described in the title. In this example, distribution is a list of tuples, with each tuple containing a letter, and its distribution, with all the distributions from the list adding up to 100, for example: [("a",50),("b",20),("c",30)] And length is the length of the string that you want. 回答1: Python is upset because you are

Rails 3.2 Postgres Save Error “ActiveRecord::StatementInvalid: PG::Error: ERROR: Syntax error near 'T' at position 5”

有些话、适合烂在心里 提交于 2019-11-28 02:40:53
问题 My app has started throwing errors when I try to save a particular class to the database. I'm not sure exactly what caused this to start happening - I've been having all kinds of database issues for the last few days.... In any case, my model seems to be working fine (it is properly calculating all of the before_save values), but then it tries to save to the database and blows up. SQL (0.8ms) INSERT INTO "portfolios" ("correlation_matrix", "created_at", "data", "mean_return", "std_dev",

Why and I getting: “Invalid regular expression. Uncaught SyntaxError. Invalid escape.”?

天涯浪子 提交于 2019-11-28 02:20:45
Im trying to create an html input tag that accepts only numbers entered in 1 of 2 formats, and reject all other input. I want to accept numbers in these formats only, including requiring the dashes: 1234-12 and 1234-12-12 note: this is not for dates, but rather legal chapter numbers Everything I am reading about regex says that the following should work, but it isn't. <input class="form-control" type="text" pattern="^(\d{4}\-\d{2}\-\d{2})|(\d{4}\-\d{2})$" required /> Devtools Console Error in Chrome: Pattern attribute value ^(\d{4}\-\d{2}\-\d{2})|(\d{4}\-\d{2})$ is not a valid regular

Running SQL script through psql gives syntax errors that don't occur in PgAdmin

…衆ロ難τιáo~ 提交于 2019-11-28 01:59:51
I have the following script to create a table: -- Create State table. DROP TABLE IF EXISTS "State" CASCADE; CREATE TABLE "State" ( StateID SERIAL PRIMARY KEY NOT NULL, StateName VARCHAR(50) ); It runs fine in the query tool of PgAdmin. But when I try to run it from the command line using psql: psql -U postgres -d dbname -f 00101-CreateStateTable.sql I get a syntax error as shown below. 2: ERROR: syntax error at or near "" LINE 1: ^ psql:00101-CreateStateTable.sql:6: NOTICE: CREATE TABLE will create implicit sequence "State_stateid_seq" for serial column "State.stateid" psql:00101

MySQL: “error in your SQL syntax … near key …”? [closed]

会有一股神秘感。 提交于 2019-11-28 00:19:46
I found one very cool scirpt for lost password but this row is making me problems $r = mysql_query('INSERT INTO `keys` (username,key, vreme) VALUES ("'.$user.'", "'.$acckey.'", "'.$keyexp.'"') or die(mysql_error()); error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, vreme) VALUES ("123123", "1ed2f5100a26298a55b2935cbea7d4a0", "1337991670"' at line 1 eggyal KEY is a Reserved Word . As documented under Schema Object Names : If an identifier contains special characters or is a reserved word, you must

Constant truncated to integer

眉间皱痕 提交于 2019-11-28 00:03:50
问题 The following GO program gives the error: ./fft.go:13: constant -6.28319 truncated to integer ./fft.go:13: cannot use -7 * k / N (type int) as type float64 in assignment Program: package main import ( "math" "fmt" ) func main() { fmt.Println("Hello world ",math.E) var k, N int = 1, 10 var ans float64 = 0 var c float64 = (-2.0 * math.Pi * k) / N x := make([]float64,N) for i := 0; i < len(x); i++ { x[i] = 1 } ans = 0 for i := 0; i < N; i++ { ans += x[i] * math.E } fmt.Println(ans) } Why cant I

“EOL while scanning single-quoted string”? (backslash in string)

三世轮回 提交于 2019-11-27 23:19:22
import os xp1 = "\Documents and Settings\" xp2 = os.getenv("USERNAME") print xp1+xp2 Gives me error File "1.py", line 2 xp1 = "\Documents and Settings\" ^ SyntaxError: EOL while scannning single-quoted string Can you help me please, do you see the problem? gimel The backslash character is interpreted as an escape. Use double backslashes for windows paths: >>> xp1 = "\\Documents and Settings\\" >>> xp1 '\\Documents and Settings\\' >>> print xp1 \Documents and Settings\ >>> Additionally to the blackslash problem, don't join paths with the "+" operator -- use os.path.join instead. Also, construct

How to fix the YAML syntax error: did not find expected '-' indicator while parsing a block?

白昼怎懂夜的黑 提交于 2019-11-27 23:12:38
问题 I have some code written in my .travis.yml written for a Python library. Using lint.travis-ci.org, I came to know that there is some indentation problem in my YAML file. Here is the part which the error points to install: - if [[ "${TEST_PY3}" == "false" ]]; then pip install Cython; python setup.py build; # To build networkx-metis mkdir core; # For the installation of networkx core cd core; git clone https://github.com/orkohunter/networkx.git; cd networkx/; git checkout addons; python setup

Java variable scope in if statement [duplicate]

旧巷老猫 提交于 2019-11-27 20:02:42
This question already has an answer here: Declaring a useless local variable 2 answers A single-line loop with a mandatory pair of braces in Java 3 answers I received a compilation error for the following code: if(true) int a = 10; else int b = 20; If I change it to the following code, then there is no compilation error: if(true) { int a = 10; } else { int b = 20; } Why is the first syntax wrong, and from what language standard? The Java specification says that an if-then-else statement is of the following form: IfThenElseStatement: if ( Expression ) StatementNoShortIf else Statement Where