Parse error: syntax error, unexpected ',' preg_match [duplicate] - php

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I keeping getting the error:
Parse error: syntax error, unexpected ',' on line 97
Line 97:
if (preg_match('/['.unichr(0x1F300).'-'.unichr(0x1F5FF).unichr(0xE000).'-'.unichr(0xF8FF).']/u'), $_POST['username'])) {
How do I fix this?

if (preg_match('/['.unichr(0x1F300).'-'.unichr(0x1F5FF).unichr(0xE000).'-'.unichr(0xF8FF).']/u', $_POST['username'])) {
Remove the ) right before the ,
It might be easier to spot this way:
$pattern = '/['.unichr(0x1F300).'-'.unichr(0x1F5FF).
unichr(0xE000).'-'.unichr(0xF8FF).']/u';
if (preg_match($pattern, $_POST['username'])) {
A good reason to keep your lines short, and use a good IDE.

Related

Parse error: syntax error, unexpected 'foreach' (T_FOREACH), expecting ',' or ';' in C:\xampp\htdocs\policycode\sample_code\policy1.php on line 54 [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
Below is the program i have created using PHP.
foreach (.$resource->getAttributeMap()->entrySet() as .$entry);
if($entrey->getkey()->equal($Resource->RESOURCE_ID_KEY))
continue;
echo".$entry->getkey(). $entry->getValue()[0]";
The program can't iterator for each. How to the solve the issue?
The actual context of the code is not clear but it has syntax errors like .(dot) preceding the variable names, not consistent variable names etc. A modified code would be :
foreach ($resource->getAttributeMap()->entrySet() as $entry){
if($entry->getkey()->equal($resource->RESOURCE_ID_KEY)){
continue;
}
echo $entry->getkey()."". $entry->getValue()[0];
}

PHP Parse error: syntax error, unexpected '}' in line 762 [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
last "}" is line 762. log says "PHP Parse error: syntax error, unexpected '}' in /home/u230748479/public_html/application/controllers/api_new.php on line 762" if you need whole code ill send you. please help me. thanks.
https://drive.google.com/open?id=0B6DjyTFNtfv5SjZBM2JGNVh2V2c
link to my php file
There is nothing wrong with your code, but you got 3 invalid (\u007F) characters before the } that gives the error.
This is your code
echo "1";
}
// this line contains 3 invalid characters (\u007F = DELETE character)
} // this is line 762
Remove the line with the invalid characters and you should be good to go.

PHP Parse error: syntax error, unexpected 'preg_match' (T_STRINGd [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
When i try to run this script :
include('db.php');
$site=file_get_contents("https://example.com");
$baslik='#<title>(.*?)</title>#si';
$içerik='#<div class="post-content">(.*?)</div>#si';
$kategori='#<p class="post-categories"><span>Kategoriler:(.*?)</a></p>#si';
preg_match($baslik,$site,$baslikfonksiyon);
preg_match($icerik,$site,$icerikfonksiyon);
preg_match($kategori,$site,$kategorifonksiyon);
$baslikkullan=$baslikfonksiyon[1];
$icerikkullan=$icerikfonksiyon[1];
$kategorikullan=$kategorifonksiyon[1];
i see this error in error_log file :
[01-Mar-2017 20:39:41 UTC] PHP Parse error: syntax error, unexpected
'preg_match' (T_STRING) in /example/file/path on line 9
Can anyone explain to me why i get this error
Thanks.
I think you have problem with the regex. Try with:
$baslik = '^.*?<\/title>';

Parse error: syntax error, unexpected ''aws_account.aws_account_id'' (T_CONSTANT_ENCAPSED_STRING) in project [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I came across the following error, but I fail to see what is wrong:
Parse error: syntax error, unexpected ''aws_account.aws_account_id'' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\laravel\awsconfig\app\controllers\CRUDController.php on line 11
my join statement where the error is being thrown:
$query = DB::table('ec2_instance')->join('aws_account', 'aws_account.id', '=', 'ec2_instance.id')->select('ec2_instance.instance_id', 'ec2_instance.public_dns_name', 'ec2_instance.key_name','ec2_instance.instance_type','ec2_instance.launch_time',‌​'aws_account.aws_account_id')->get();
You've got some junk characters there between the last , and ':

php parse/syntax error - help [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
php parse/syntax error help
I keep getting a "Parse error: syntax error, unexpected ':', expecting ')' in /home/jobkill/public_html/process.php on line 8" when processing inputs from a page that redirects here. I dont know what to fix.
You cant use these backquotes, use
"
instead

Categories