Google Closure Compiler Parse Error [duplicate] - google-closure-compiler

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Partially skip sections with Google Closure Compiler
I get the following error from the compiler:
Number of errors: 2
JSC_PARSE_ERROR: Parse error. syntax error at line 17 character 18
window.location = <?php echo $this->baseUrl(); ?>"/";
^
JSC_PARSE_ERROR: Parse error. syntax error at line 17 character 47
window.location = <?php echo $this->baseUrl(); ?>"/";
^
It doesn't seem to like the (php) syntax. Any suggestion?

Isolated the code in a string:
window.location = eval("<?php echo $this->baseUrl(); ?>") + "/";
this is a similar problem to:
https://code.google.com/p/closure-compiler/wiki/UsingConditionalCommentWithClosureCompiler

Related

R library "XML" doesn't recognize encoding

Problem
I have an XML file that I would like to parse in R. I know that this file is not corrupted because the following Python code seems to work:
>>> import xml.etree.ElementTree as ET
>>> xml_tree = ET.parse(PATH_TO_MY_XML_FILE)
>>> do_my_regular_xml_stuff_that_seems_to_work_no_problem(xml_tree)
Now, when I try to run the following code in R, I get an error message:
> library("XML")
> xml_tree <- XML::xmlParse(PATH_TO_MY_XML_FILE)
Error in nchar(text_repr): invalid multibyte string, element 1
Traceback:
Alright, maybe the parser doesn't recognize the encoding. Luckily this should be specified in a decent XML file. So, I go to my shell and check:
$ head -n1 PATH_TO_MY_XML_FILE
??<?xml version="1.0" encoding="utf-16"?>
Now, I can go back to R and explicitly pass on the encoding, only to face the next error message where I got stuck now:
> library("XML")
> xml_tree <- XML::xmlParse(PATH_TO_MY_XML_FILE, encoding='UTF-16')
Start tag expected, '<' not found
Error: 1: Start tag expected, '<' not found
Traceback:
1. XML::xmlParse(filePath, encoding = "UTF-16")
2. (function (msg, ...)
. {
. if (length(grep("\\\n$", msg)) == 0)
. paste(msg, "\n", sep = "")
. if (immediate)
. cat(msg)
. if (length(msg) == 0) {
. e = simpleError(paste(1:length(messages), messages, sep = ": ",
. collapse = ""))
. class(e) = c(class, class(e))
. stop(e)
. }
. messages <<- c(messages, msg)
. })(character(0))
A last attempt to check (in R) if the file is in fact "UTF-16" encoded yields:
> f <- file(filePath, 'r', encoding = "UTF-16")
> firstLine <- readLines(f, n=1)
> close(f)
> print(line)
[1] "<?xml version=\"1.0\" encoding=\"utf-16\"?>"
Which looks just about right to me.
Question(s)
Does anyone know what is happening here? Is this a bug from the XML library? Is the file maybe not 'UTF-16' encoded, even though it claims it is? What are the two question marks ?? that I see when I print the file into the shell? These question marks don't appear when reading in the file properly...
Is this a bug from the XML library?
I think there could be a bug here. If I generate a valid UTF-16 XML document, which will have an initial byte-order mark:
$ echo '<a>😊</a>' | iconv -t utf-16 >a-utf16.xml
$ xxd a-utf16.xml
00000000: fffe 3c00 6100 3e00 3dd8 0ade 3c00 2f00 ..<.a.>.=...<./.
00000010: 6100 3e00 0a00 a.>...
then I can parse it with:
> XML::xmlParse('a-utf16.xml')
<?xml version="1.0"?>
<a>😊</a>
but not if I specify the encoding:
> XML::xmlParse('a-utf16.xml', encoding='utf-16')
Start tag expected, '<' not found
Error: 1: Start tag expected, '<' not found
Your original problem was when you weren't specifying the encoding. However:
I know that this file is not corrupted because the following Python code seems to work
That's a good hint, but I think you'll find edge cases where that doesn't hold. Try iconv for a second opinion on whether the file is encoded correctly.
For a more specific response, you'll need to post a reproducible XML file,

How to fix "Warning: A non-numeric value encountered in" WP

On my WordPress page I use the plugin occupancy plan "https://wordpress.org/plugins/occupancyplan/" after the update to PHP 7.3 wordpress gives the following error message:
Warning: A non-numeric value encountered in
/homepages/XX/XXXXXXXXXX/htdocs/XXXXXXXXXX/wp-content/plugins/occupancyplan/occupancy_plan_classes.php
on line 4 - 38 and on line 620, 641, 657
How can I solve the problem?
it's probably a bit late but try adding this validation to every line with that error!
//fix issue with tax when it's not selected it
IF(empty ($ variable name)){
/* null */
}else{
$return = whatever was previously at the line
At the end you must to return something
}
return floatval( $return );
Good Luck!

file_get_html() not working for the only webpage

I want to call a simple DOM file
I tested with another links and it works, but with this url it's not working.
My code is:
$bnadatos = file_get_html("http://www.rofex.com.ar/cem/FyO.aspx");
foreach($bnadatos->find('[#id="ctl00_ContentPlaceHolder1_gvFyO"]') as $i){
echo "datos:";
echo $i->innertext;
}
Response is a blank page.
What's wrong?
i solved with
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$response = file_get_html("https://www.rofex.com.ar/cem/FyO.aspx", false, stream_context_create($arrContextOptions));
foreach($response->find('[#id="ctl00_gvwDDF"]/tbody/tr[2]/td[2]') as $i){
echo $i->innertext;
}
thank you #maio290 for light my road
This is just a guess, but do you have your error reporting on?
Out of the box, this is not working with the simple-html-dom library:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /var/www/html/dom.php on line 83
Warning: file_get_contents(): Failed to enable crypto in /var/www/html/dom.php on line 83
Warning: file_get_contents(http://www.rofex.com.ar/cem/FyO.aspx): failed to open stream: operation failed in /var/www/html/dom.php on line 83
Fatal error: Call to a member function find() on boolean in /var/www/html/test.php on line 11
A fix for this can be found here - with that in place, I still get a blank page, which is due to a wrong answer (301 Moved Permanently) - for this to fix, you need to modify
'follow_location' => false
to
'follow_location' => true
so, now we get the proper site content - you can modify the selector to $html->find('#ctl00_ContentPlaceHolder1_gvFyO'); this will find all element which id=ctl00_ContentPlaceHolder1_gvFyO - see the documentation as reference.

error in sqlite database when loaded in php [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
SQLite database path not working
D:/wamp/www/umer.db
Warning: sqlite_query() [function.sqlite-query]: no such table: config in
D:\wamp\www\sqllite\index.php on line 15
Error in query: SQL logic error or missing database
I found this error when loaded data base in PHP. My source code is this:
<?php
$db = $_SERVER['DOCUMENT_ROOT']."umer.db";
echo $db;
$handle = sqlite_open($db) or
die("Could not open database".sqlite_error_string(sqlite_last_error($handle)));
$query = ("SELECT * FROM config");
$result = sqlite_query($handle,$query) or
die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));
if (sqlite_num_rows($result) > 0) {
echo "<table cellpadding=10 border=1>";
while($row = sqlite_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "</tr>";
}
echo "</table>";
}
sqlite_close($handle);
?>
Well, it looks like you don't have a config table:
D:/wamp/www/umer.db Warning: sqlite_query() [function.sqlite-query]:
no such table: config in <<<<< SEE HERE!
D:\wamp\www\sqllite\index.php on line 15
Error in query: SQL logic error or missing database
Are you sure that table exists?
It seems to be opening the database okay since the first error occurs on the sqlite_query() call.

drupal 6 can we write a php file in drupal which changes the headers

i have written a small code which creates a word document but
i got the following errors
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
$fp = fopen("test.doc", 'w+');
$str = "<B>This is the text for the word file created through php programming</B><br>test to create a doc file from php";
ob_start();
include('index.php');
$result = ob_get_clean();
fwrite($fp, $result);
echo "executed";
header("Content-Disposition: attachment; filename=test.doc");
header("Content-Type: application/force-download");
header("Content-Length: " . filesize("test.doc"));
header("Connection: close");
fclose($fp);
?>
warning: Cannot modify header information - headers already comnt by (output started at /var/www/www.example.com/htdocs/test_createdoc.php:6) in /var/www/www.example.com/htdocs/test_createdoc.php on line 19.
warning: Cannot modify header information - headers already comnt by (output started at /var/www/www.example.com/htdocs/test_createdoc.php:6) in /var/www/www.example.com/htdocs/test_createdoc.php on line 20.
warning: Cannot modify header information - headers already comnt by (output started at /var/www/www.example.com/htdocs/test_createdoc.php:6) in /var/www/www.example.com/htdocs/test_createdoc.php on line 21.
warning: Cannot modify header information - headers already comnt by (output started at /var/www/www.example.com/htdocs/test_createdoc.php:6) in /var/www/www.example.com/htdocs/test_createdoc.php on line 22
i have even remove the white spaces between php tags
It looks like echo "executed"; sends output before the headers. PHP then stops the headers from sending, because HTTP requires headers to come before output. If removing that doesn't fix it, try commenting out include('index.php'); to test if the output is coming from there.

Resources