syntax-error

What's wrong with my except? [duplicate]

♀尐吖头ヾ 提交于 2019-11-29 23:05:23
This question already has an answer here: Python try…except comma vs 'as' in except 5 answers I've got a SyntaxError on my except: try: opts, args = getopt.getopt(sys.argv[1:], 'P:D:H:d:u:p:nvhmJi:c:Ml:TB:', ['host=', 'port=', 'directory=', 'user=', 'password=', 'daemon=', 'noauth', 'help', 'verbose', 'mysql', 'icounter=', 'config=', 'nolock', 'nomime', 'loglevel', 'noiter', 'baseurl=']) except getopt.GetoptError, e: print usage print '>>>> ERROR: %s' % str(e) sys.exit(2) I get the error: File "main.py", line 199 except getopt.GetoptError, e: SyntaxError: invalid syntax Anyone have any idea?

Why doesn't my equality comparison using = (a single equals) work correctly in Java?

让人想犯罪 __ 提交于 2019-11-29 18:52:05
I have a syntax error in the following line. However I can't understand what is the reason of this error. if (address1.compareTo(address2) = 1) System.out.println(address1 + " is greater than " + address2); What I want to achieve is printing proper message if and only if compareTo returns 1 . xenteros You should compare ( == ) instead of assigning ( = ). It can be very dangerous! To avoid such situations you can use Yoda notation so instead of comparing address1.compareTo(address2) == 1 You can compare: 1 == address1.compareTo(address2) In case of missing = , there will be comparation error.

PHP create table error 1064

旧城冷巷雨未停 提交于 2019-11-29 18:37:29
I am trying to create a table in mySQL. This is my php page below, when I run the page there are no errors but the table is not in mySQL and when I test the code in mySQL I'm getting the error #1064 - 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 '$user = "root"' at line 1. I've done a bit of research into what this error means but I'm getting no where. I don't really understand what it means. If I'm honest I don't really understand php I'm just adapting the code I've written in previous uni tutorials.

Unexpected $end in eval()'d code

空扰寡人 提交于 2019-11-29 18:17:33
问题 I hate to ask such a specific question, but I'm getting an error I can't figure out. This is in a cron job which runs on the hour. I'm creating an array of tasks, each of which has a date check which is supposed to be eval()'d. $todo = array(); $todo[] = array( "date('z')%3 == 0", "Task 1" ); $todo[] = array( "date('N') == 1", "Task 2" ); foreach( $todo as $task ) { if( eval($task[0]) ) { echo $task[1]; } } For some reason the eval() line is giving me this error. Note that I am getting this

Parse Error: syntax error: unexpected '{' [closed]

夙愿已清 提交于 2019-11-29 18:16:26
I have this code that processes a user then redirects them to the user homepage. <?php $username = $_POST['username']; $password = $_POST['pwd']; $file = file_get_contents("userdb.html"); if(!strpos($file, $username)) { echo "Your username was not found in our database. Please go back and try again."; } else { echo "Redirecting..."; if (md5($password) == !strpos($file, (md5($password))) { echo "Redirecting..." header ('Location: ./userhome.php') } else { print "Whoops! Your password seems to be incorrect. Go back and try again." } } ?> And I get the error: Parse error: syntax error, unexpected

Untraceable errors in XHTML templates caused by a missing space between attributes among (X)HTML tags

笑着哭i 提交于 2019-11-29 18:10:52
Have a simple question. Let's consider the following tag. <h:inputText id="text" value="#{bean.value}"/> If it is mistakenly written as follows. <h:inputText id="text"value="#{bean.value}"/> Please notice that there is no space between the id and the value attributes in this case. This is expected to be a parse error that should occur during parsing of the XHTML file possibly throwing an appropriate exception. If it were to happen, absolutely nothing exceptional would be reported. No errors/exceptions would be thrown on the server-side. The target web page on the browser would then merely be

MySQL syntax error using python to add column to a table

对着背影说爱祢 提交于 2019-11-29 18:03:11
The code i have is: for key in keys: cursor.execute(""" ALTER TABLE segment_table ADD %s VARCHAR(40) """, key) I get a error telling me my syntax is wrong. When I replace the %s with a actual string the syntax error goes away. for key in keys: cursor.execute(""" ALTER TABLE segment_table ADD myColumn VARCHAR(40) """) Any help is appreciated. Shouldn't you do the replacement before feeding it? query = "ALTER TABLE segment_table ADD %s VARCHAR(40)" % (key) cursor.execute( query ) There is a bit of confusion going here, for several reasons: (1) mySQL uses the % as a parameter marker -- easily

Why is Pydev giving a syntax error for built-in keywords?

不想你离开。 提交于 2019-11-29 17:10:23
问题 Why is Pydev giving me syntax errors for built-in python functions like str()? Undefined variable: str Undefined variable: False Undefined variable: float 回答1: Remove and re-add the python interpreter in the PyDev configuration. Make sure that the project is using the newly added interpreter. 回答2: This means that there's a problem with starting the shell to get completions for builtins (usually a firewall or a misconfiguration in the network -- see: http://pydev.org/faq.html#PyDevFAQ

PHP, Parse error: syntax error, unexpected T_FUNCTION [duplicate]

会有一股神秘感。 提交于 2019-11-29 16:46:30
This question already has an answer here: PHP anonymous function causes syntax error on some installations 3 answers class test { public $do; function __construct($data="") { $this->parse($data); } private function parse($data) { // Decoding the functions $decoded_data = json_decode($data,true); array_walk_recursive($decoded_data,function(&$function) { $first_line = strtok($function, "\n"); preg_match("/\/\*#(.*?)\#*\//",$first_line,$matches); $function = create_function($matches[1],$function); }); $this->do = $decoded_data; } } Parse error: syntax error, unexpected T_FUNCTION The error is in:

A procedure to Reverse a String in PL/SQL

痴心易碎 提交于 2019-11-29 16:27:18
I just started learning PL/SQL and I'm not sure how to create a procedure. The logic seems about right but I think there's some syntactical mistake in the first line. Here's my code:- CREATE OR REPLACE PROCEDURE ReverseOf(input IN varchar2(50)) IS DECLARE reverse varchar2(50); BEGIN FOR i in reverse 1..length(input) LOOP reverse := reverse||''||substr(input, i, 1); END LOOP; dbms_output.put_line(reverse); END; / Przemyslaw Kruglej Two things - you shouldn't specify the datatype size in procedure's/function's parameter list and you do not need the DECLARE keyword. Try this: CREATE OR REPLACE