Hi am getting unexpected ')' error on line 65 [duplicate] - laravel

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
Hi kindly help me check if there's any problem with my code. I am creating a command to generate a sitemap but am getting an error; 'unexpected ')' on line 65.
here is the screenshot for the code

I think the issue is on the IF statement. Just remove the last OR operator from the condition. Like this:
if (
$url->segment(1) == $priority[0] ||
$url->segment(1) == $priority[1] ||
$url->segment(1) == $priority[2]
) {...}
If this is not the issue, maybe you can tell us what is the line 65.

Related

Problems with while in bash [duplicate]

This question already has answers here:
Why should there be spaces around '[' and ']' in Bash?
(5 answers)
Closed 4 years ago.
I am doing a bash script with the web api of checkpoint.
126: No such file or directory
this error refers to line 25 in which I have the next sentence:
while [$reglas < $n_reglas ];do
I have tried changing that to:
while [$reglas -lt $n_reglas ];do
but the error persist and I am not sure of what is the real problem.
The variables are defined like this:
reglas=1
n_reglas=$(echo $rulebase_list | jq '.total')
and I have printed their value in order to check that they are taking the correct value. Any idea of which is the problem?
Thanks!
Unfortunately it is not very clear what the actual problem is. Please try to reproduce the problem in a small code snippet that we can execute and troubleshoot. This way we don't need to guess and can provide more precise help.
Here is a small snippet with a ton of assumptions.
reglas=1
n_reglas=4 # https://jqplay.org/s/BCTXyJ4NLc
while [ $reglas -lt $n_reglas ]; do
echo $reglas
reglas=$(($reglas+1))
done
# $bash -f main.sh
# 1
# 2
# 3

syntax error: unexpected end of file while executing a query inside while block [duplicate]

This question already has answers here:
Bash syntax error: unexpected end of file
(21 answers)
Closed 6 years ago.
I have prepared a shell script which takes 6 char(s) from a file and insert a particular record using sql insert query within a while loop(as the number of records in file is huge).
Upon running the script I am receiving below error -
./TestScriptFor.sh: line 40: syntax error: unexpected end of file
#!/bin/bash
varSIAREQUESTID=$1
varCINAME=$2
#varWORDLENGTH=$3
#DB connection parameter
DBUSER='#USERNAME#'
DBUSERPASSWORD='#PWD#'
DB='oracle'
MYDB='#CONNECTIONSTRING#'
OLDIFS=$IFS
# while loop
while IFS= read -r -n6 LOCATIONID
do
#insert into database
sqlplus -s ${DBUSER}/${DBUSERPASSWORD}#${MYDB} <<EOT
set linesize 32767
set feedback off
set heading off
insert into nbn_sia_locationids (siarequestid,locationid,ciname) values('$varSIAREQUESTID','$LOCATIONID','$CINAME');
exit
EOT
echo "$LOCATIONID"
# display one character at a time
done < TestData.csv
IFS=$OLDIFS
Thanks for your responses.
I did below two steps to resolved the issue -
1. dos2unix TestData.csv - although I had created this file in UNIX itself but did this as well.
2. a new line at the end of the file as suggested by #cdark
regards,
dhananjay

Super Simple bash If (variable > integer) treating (variable as a command [duplicate]

This question already has answers here:
Getting "command not found" error while comparing two strings in Bash
(4 answers)
Closed 6 years ago.
I feel like this should be really simple but I can't get past this step.
$num = 5
if [$num > 2]; then echo greater; fi
the problem is, I keep getting [5: command not found.
Why is it not evaluating the if [ test ] block correctly? It's like the shell forgot about the if and just moved on to "hey, [5 > 2 does not look like a command, I can't find [5"... but [5 isn't a command, it's part of the if test block?
I have tried using different brackets and using -gt instead of >. The problem is bash doesn't actually ever do the test. For some reason it ignores if.
Just managed to find the answer:
if compare strings get a "command not found"-Error
really unexpected, there needs to be a space between the [ brackets and the variable.
I would never have guessed.

multiple logical operators in shell script causing an issue [duplicate]

This question already has answers here:
Simple logical operators in Bash
(5 answers)
Closed 8 years ago.
I am trying to write an expression using multiple logical operators and shell script as below
if [ [a != b] && [ -d "/path/to/directory"] || [a = b] && [ ! -d "/path/to/directory"] ] ; then execute some steps.
When I run this code, I get syntax error in conditional operator ']'. I tried different ways of having brackers, but could not get it to work. Can someone please help. Many thanks!
You could seperate the condition expression and keep the value in variant, like this to avoid the unpaired parenthesis problem:
CON_1=((a != b) && [ -d "/path/to/directory"])
CON_2=((a == b) && [ ! -d "/path/to/directory"])
if CON_1 || CON_2
then
# execute some steps
fi
Or try using eclipse plugin ShellEd for the alternative way.
EDIT Change the syntax to be shell. I assumed [] in this context is the logical test operation. Any one please suggest whether it is correct.

After replacing eregi with preg_match I'm getting: preg_match() [function.preg-match]: Unknown modifier ',' [duplicate]

This question already has answers here:
Warning: preg_replace(): Unknown modifier
(3 answers)
Closed 3 years ago.
I'm using PHP Timeclock and I've had to mod several pages due to outdated code.
However, I'm stuck on this one:
preg_match Unknown modifier ',' in timeclock/admin/timeedit.php on line 274
preg_match ("/^([0-9]{1,2})-,/,.-,/,.$/i", $post_date, $date_regs))
This page was unchanged from the source. Any Ideas?
Try changing your Perl delimiters from / to something else.
got it with preg_match ("^([0-9]{1,2})[-,/,.]([0-9]{1,2})[-,/,.](([0-9]{2})|([0-9]{4}))$^"

Resources