Parse error: syntax error, unexpected 'image' (T_STRING) in eval line - eval

I`m trying to create a page that read the metadata of an image and allow user to edit it and save it to the same image.
After searching the internet I have found exiftool as the solution but I can make it work only as a command line not as a library in the page.
I have this code:
eval('$metadata=' . exiftool.exe -php -q $imagePath);
foreach ($metadata[0] as $key => $value) {
if ($metadata[0][$key]!=$_POST[$key]){
if ($_POST[$key]=="") $_POST[$key]=" "; //if metadata is not set, than create an empty metadata
eval('$metadata=' . exiftool.exe "-$key=$_POST[$key]" $imagePath);
}
}
and I`m getting this error:
Parse error: syntax error, unexpected 'image' (T_STRING) in E:\xampp\htdocs\imgdata\index.php(30) : eval()'d code on line 1
I tried to replace the ` with other like " and ' but no luck.
What do I miss?
Any better idea on how to do it?
Thanks

I had the same problem, but using Centos OS, and found a solution here:
'command not found' error when using subprocess in apache
Might not work for Windows but worth a look. Basically the answer suggests specifying the full exiftool path rather than simply exiftool.exe.
If that doesn't help then have a look for errors in the Apache Error Log File.

Related

JSON parse error on running `hugo` command

I'm trying to build a blog using Hugo. Every time I run the hugo command, I get this error
ERROR 2021/06/22 18:57:50 JSON parse error: expected comma character
or an array or object ending on line 52 and column 40
12: {
^
Total in 145 ms
Error: Error building site: failed to render pages: JSON parse error:
expected comma character or an array or object ending on line 52 and column 40
12: {
^
I suspect my project directory structure to be the problem but I'm open to more questions about the situation.
My project directory structure looks like
root-folder
--content
--posts
--my-first-post.md
--posts-again
--my-second-post.md
--my-third-post.md
--my-fourth-post.md
and all markdown files contain exactly the following
---
title: "Project"
date: 2021-06-22T18:09:26+01:00
draft: false
---
This is a post
When draft is set to true, I don't get the error when I run the hugo command. The error comes up when draft for any of the files in posts or posts-again is set to false
I have searched every file for a line 52 that I can understand but I cannot find any.
Where could this error be coming from and how can I resolve it?
hugo serve and hugo serve -D work fine, but hugo doesn't
hugo-PaperMod is missing a comma in a JSON block in layouts/partials/templates/schema_json.html
I got this error and just pushed up a PR to fix it
https://github.com/adityatelange/hugo-PaperMod/pull/614
this may be your issue
Issue is baseurl set to "/" in config.toml.
Change it to "" and try

Getting an error in output when passing dynamic variable in ElFileBody in Gatling 3.0.3

I am using Gatling 3.0.3 and Java home is set to Jdk9. I am getting an error when running my script using 'ElFileBody' and I am passing a dynamic variable Session_ID in the ElFileBody .txt file. Below is my code
.exec(http("TEAMXPRESS_INIT")
.post("/WEBXPAPIT/api/Common/wxRequestHandlerJSON")
.headers(headers_7)
.body(ElFileBody("bodies/resources/TeamXPLoginUnSchShift_0021_request.txt")).sJson
.check( jsonPath( "$" ).saveAs( "TEAMXP_INIT_RESPONSE_DATA" ) )
.check(status.in(200))
.check(jsonPath("$.pcResult").is("OK")))
bodies/resources/TeamXPLoginUnSchShift_0021_request.txt file is
{"pcwxSessionID":"${Session_ID)","pcServiceName":"TeamXpressInit","pcContextString":"{\"ttContext\":[{\"contextName\":\"pcToken\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"},{\"contextName\":\"pcPlatform\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"}]}","piClientVersion":"20190414001","pcIODataSetString":""}
Error I am getting is
Caused by: java.util.concurrent.CompletionException: io.gatling.core.session.el.ElParserException: Failed to parse {"pcwxSessionID":"${Session_ID)","pcServiceName":"TeamXpressInit","pcContextString":"{\"ttContext\":[{\"contextName\":\"pcToken\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"},{\"contextName\":\"pcPlatform\",\"contextValue\":null,\"contextGroup\":\"PARAM\",\"contextOperator\":\"\",\"contextType\":\"\"}]}","piClientVersion":"20190414001","pcIODataSetString":""} with error ''}' expected but ')' found'
at com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache.lambda$new$0(BoundedLocalCache.java:3373)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2039)
at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1922)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2037)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2020)
at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:67)
at io.gatling.core.body.ElFileBodies.asBytesSeq(ElFileBodies.scala:71)
at io.gatling.core.body.ElFileBody$.apply(Body.scala:34)
at teamXPLogin.TeamXPLoginUnSchShift.<init>(TeamXPLoginUnSchShift.scala:86)
What wrong am I doing here. If I pass the post request body manually using StringBody method then it works fine. Please help.
I figured out the silly mistake I have done. Instead of passing dynamic variable ${Session_ID} like this, I have passed ${Session_ID).

Cake Email Gives an Error

In my Controller file i wrote the following code for attaching an image to the mail,But it gives an error
$email->attachments(array('/localhost/projname/app/webroot/img/file.png'));
It shows an error like File not found: "&quot
You can use the IMAGES constant to get the file path to the images folder:
$email->attachments(array(IMAGES.DS.'file.png'));
Finally I got solution for attaching Images
$email->attachments(array (
array('file'=>ROOT.'/app/webroot/img/car.gif',
'mimetype'=>'image/png'
),
));

mpdf no output and php errors in mpdf.php

I'm trying to generate a pdp file in a cakephp application. Therefore, I use the mpdf library as a vendor. But when I try to make a even very simple output it doesn't work. Then when I use the debug property, it shows php errors in the mpdf.php file.
Here is my source code:
<?php
$mpdf=new mPDF();
$mpdf->WriteHTML('hello');
$mpdf->debug = true;
$mpdf->Output();
exit;
?>
And these are the errors shown in the browser:
Notice (8): Undefined index: BODY [APP\vendors\MPDF54\mpdf.php, line 14242]
Notice (8): Undefined index: BODY>>ID>> [APP\vendors\MPDF54\mpdf.php, line 14288]
Notice (8): Undefined offset: -1 [APP\vendors\MPDF54\mpdf.php, line 14421]
Thank you for your help!
This is not a CakePHP problem but related to the library you're using.
Read about how to use the WriteHTML() method.
http://mpdf1.com/manual/index.php?tid=121
And try passing 2 as the 2nd argument.
$mpdf->WriteHTML('hello', 2);
If this still does not work read the documentation, check the examples there.
This is caused by buggy mpdf code. It depends on error (level "notice") reporting to be switched off (it switches it off itself). But if you handle errors some nonstandard way, it is problem..
I solved it by ignoring errors from mpdf.php file in my custom error handler.
I was using my custom error reporting via set_error_handler();

CakePHP "Warning: Cache not configured properly"

I am using CakePHP and getting the following error
Warning: Cache not configured properly. Please check Cache::config(); in APP/config/core.php in D:\PHP-SERVER\cheesecake\cake\libs\configure.php on line 663
Notice: Undefined variable: Route in D:\PHP-SERVER\cheesecake\app\config\routes.php on line 38
Fatal error: Call to a member function connect() on a non-object in D:\PHP-SERVER\cheesecake\app\config\routes.php on line 38
Any problem in the settings?
Which CakePHP version are you using?
The fatal error looks like a typo. Open the file D:\PHP-SERVER\cheesecake\app\config\routes.php and check what there is written on line 38. It looks like there is a letter missing.
It should be something along the lines of
Router::connect(...[whatever your route settings are]...);
and I guess in your file it says (note the missing r in Router)
Route::connect(...);
Did you do what the other error message said? Check the Cache::config call in app/config/core.php. You seem to have not properly set your cache configuration.
The default call looks like
Cache::config('default', array('engine' => 'File'));
If you changed that post the code-piece to figure out if something is wrong..

Resources