How to fix velocity ParseErrorException lexical error - velocity

Hi i am totally new to apache velocity and i am having velocity.exception.ParseErrorException: Lexical error issue in my code, Can anybody help me in how to solve it?
Here is the code
#set ($file_name = ${ctx.FILE_NAME}.split('_REPORT'))
$file_name.get(0) - Some Text
And here is the error I am getting
Caused by: org.apache.velocity.exception.ParseErrorException: Lexical error, Encountered: "s" (115), after : "." at *unset*[line 1, column 37]
at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1301) ~[velocity-1.7.jar:1.7]
Can anybody help me to solve this?

Try:
#set ($file_name = ${ctx.FILE_NAME.split('_REPORT')})
$file_name.get(0) - Some Text
Or just:
#set ($file_name = $ctx.FILE_NAME.split('_REPORT'))
$file_name.get(0) - Some Text
Curly braces are only here to disambiguate a reference from surrounding text.

Related

"Error: unterminated parenthesized expression" when using function of object after parenthesis

i'm running into the problem:
Error: unterminated parenthesized expression
when trying to compile:
expiry_epoch = (expiry_date_bytes.pointer(expiry_date_bytes.size) as Int64*).value
I'm not that comfortable with crystal so i'm better off asking.
The only fix in my mind is:
expiry_epoch = expiry_date_bytes.pointer(expiry_date_bytes.size) as Int64*
expiry_epoch = expiry_epoch.value
Thanks in advance!
That as syntax is very old and effectively obsolete by now.
You can write expiry_date_bytes.pointer(expiry_date_bytes.size).as(Int64*).value

ZSH function not working with a "Missing end of string" error

I'm teaching myself to write zsh functions and I'm stumped right away with a string error I don't understand. I have this function:
function copyToDrafts() {
print($1)
}
in my command line editor (Terminal) I type:
copyToDrafts "test"
and receive this error:
copyToDrafts:1: missing end of string
I couldn't find any explanation on the error message and can't see anything wrong with what I am passing, though obviously something is wrong. Any help would be appreciated.
The parentheses are not part of the syntax; they are interpreted as introducing a glob qualifier on the pattern print. After parameter expansion, the pattern to be evaluated is
print(test)
with the following glob qualifiers:
t - match files named print that have their sticky bits set
e execute a shell command. s acts as the delimiter, but there is no "closing" s, which produces the observed error.
You simply need to drop the parentheses.
copyToDrafts () {
print $1
}

"$ "giving mule expression error in regex

I am trying to match my input field to a regex expression. But it gives mule-expression error,
regex: ^(?:[1-9][0-9]?(?:\.[0-9]{2})?|100(?:\.0{2})?)$
Exception: Unable to resolve reference of $. at 1 : 1"
evaluating expression:
Please help me in resolving this issue
Please add "\" before $ and it will work

invalid syntax in generating a variable in Stata

While creating this variable in stata14 I've got an error (198)
this is the variable that I want to generate:
g ncskew =(-(([_n])*([_n-1])^(1.5)*(sum(returns^3))))///
/(([_n-1])*([_n-2])*(sum(returns^2)^(1.5))
It is quite a puzzle but I think that the brackets are well placed.
Any help or advice would be appreciated.
The problem that jumps out at my eye is that the /// at the end of the first line is not preceded by any whitespace. That is a syntax error.
The other problem is that you have 13 opening parentheses ( and just 12 closing parentheses ). Is this your actual code or a mis-typed copy?
Whether that are the only problems with your code, I cannot say. If that is your actual code, fix that first and see what happens.

Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:... on line 22

I want to update a row in a table for my project, I'm copying a syntax I saw somewhere else here however, I think my problem comes when I try updating where ApplicantID is equal to $_SESSION["ID"].
I get this error
Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\...\InsertPData.php on line 22
here is the php along side the SQL:
<?php
include_once'dbconnect.php';
session_start();
function INSERT()
{
$Name=$_POST['name'];
$Relation=$_POST['Relation'];
$Email=$_POST['Email'];
$Address=$_POST['Address'];
$Postcode=$_POST['Postcode'];
$Mobile_Number=$_POST['Mobile_Number'];
$Home_Number=$_POST['Home_Number'];
$INSERT="UPDATE Applicants
SET ParentName='$Name',
Relationtoapplicant='$Relation',
ParentEmail='$Email',
ParentAddress='$Address',
ParentPostcode='$Postcode',
ParentMobile='$Mobile_Number',
ParentHome='$Home_Number',
WHERE ApplicantID=$_SESSION["ID"] "; #THIS IS LINE 22
$data=mysql_query($INSERT) or die(mysql_error());
if($data)
{
echo "Parents/Gauridan details hav been entered";
}
else print "error";
}
INSERT()
?>
I've already searched for a solution to this but haven't found something where the user is using a session thing. Thank you.
This is why an IDE with syntax highlighting is helpful. StackOverflow uses syntax highlighting on code blocks as well and actually already gives you the answer based on your code:
$INSERT="UPDATE Applicants
WHERE ApplicantID=$_SESSION["ID"] ";
See how ID is suddenly black instead of dark red? That's because you are terminating the string there. The double quotes should either be escaped or replaced with single quotes, like:
$INSERT="UPDATE Applicants
WHERE ApplicantID=$_SESSION[\"ID\"] ";
Or
$INSERT="UPDATE Applicants
WHERE ApplicantID=$_SESSION['ID'] ";
See how the ID bit stays dark red? This is because now your string is not suddenly terminated.
Also, please do not use mysql_ functions anymore. They have been deprecated since 2013 and are currently not even a part of PHP anymore. So if you'd update your PHP to the latest version, this code would not work. On top of that, this code is vulnerable to SQL injection attacks.
Also see Why shouldn't I use mysql_* functions in PHP? and How can I prevent SQL-injection in PHP?.