I finished a simple project with F3 (fat free framework) 2.0 and everything worked great. Now I'm starting a new project and I see it's been changed quite a bit. I've created a simple basic test and just keep hitting error's and weirdness. I'm no expert with F3 and yes I've read the documentation and yes of course I probably missed something. Hoping someone can help me. Here's my example that fails:
Start with my config file
config.cfg
cfgDbConnection="mysql:host=localhost;port=8889;dbname=test";
cfgDbUser="root"
cfgDbPassword="123456"
cfgCache=true
//...etc
The starting point
index.php
$f3=require('lib/base.php');
$f3->set('UI','ui/');
$f3->set('AUTOLOAD', 'classes/'); // this folder contains class objects for the project
$f3->config('config.cfg');
$f3->set('CACHE', $f3->get('cfgCache'));
$f3->set('DEBUG',3);
$db = new DB\SQL(
$f3->get('cfgDbConnection'),
$f3->get('cfgDbUser'),
$f3->get('cfgDbPassword')
);
$f3->set('DB',$db);
require_once("menuRoutes.php");
$f3->run();
The first of 5 php files for routing
menuRoutes.php
<?php
$f3->route('GET /', function() use ($f3){
AuthManager::authenticateSession($f3); // checks if user is logged in /classes/AutManager.php
echo View::instance()->render('landing.htm');
});
landing.htm
<include href="mainHeaderBar.htm"/> (this has css & js loads)
general html.......
<include href="mainFooterBar.htm"/> (other jquery scripts)
At this point page loads the general html, CSS and JS scripts are not loading because the includes are not loading, they are being ignored.......?
PHP Log shows:
HTTP 405 (HEAD /)
/Users/home/Documents/My Projects/testApp/web/index.php:39 Base->run()
ob_clean(): failed to delete buffer. No buffer to delete
/Users/home/Documents/My Projects/testApp/web/lib/base.php:859 ob_clean()
/Users/home/Documents/My Projects/testApp/web/lib/base.php:1118 Base->error(405)
/Users/home/Documents/My Projects/testApp/web/index.php:39 Base->run()
PHP Fatal error: Uncaught exception 'ErrorException' with message 'ob_clean(): failed to delete buffer. No buffer to delete' in /Users/home/Documents/My Projects/testApp/web/lib/base.php:1391
Thanks for the help/advice.
Your include Tags are Not being rendered, because you're not using the template class... Try
echo Template::instance()->render('landing.htm');
Instead of View
Related
How to add tracing (for bug hunting) code to my MediaWiki extension?
When I add echo "XXX"; or var_dump(...);, I don't see it in output (despite the code line where I put this tracing works for sure, as I checked by adding exit(0); instead of this tracing and watching it crashing by exit as expected).
I assume you mean debug logging ("trace" is usually used for recording what method calls happen, as in XDebug function traces). The MediaWiki debugging help page has some information on it, although it's not in great shape. Basically you set $wgDebugLogGroups['mydebuglog'] to point to a logfile, and then use wfDebugLog( 'mydebuglog', 'XXX' ). (PSR-3-style structured logging is possible but requires some setting up.)
Usually var_dump works too, but there is a lot of stuff that happens outside of requests with a web response (jobs or heavy processing that's delayed until the response has been sent).
If you did mean tracing, the profiling help page has some information.
Im trying to embed some application in IE by creating activeX control. I've got xyz.dll. Normally if I register this dll through command prompt(batch file), the embedding is successful. But if i use the cab file methodolgy, only the first snapshot of application loads in IE(embedded application fails to run) inspite of the fact that registration of dll is taking place.
xyz.cab file contains, xyz.dll and xyz.inf.
The xyz.inf is as following:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
xyz.dll=xyz.dll
[Deployment]
InstallScope=user|machine
[xyz.dll]
file-win32-x86=thiscab
clsid={HJI9D4D39-K9F5-489B-8032-CCHB1B189J10}
FileVersion=1,0,0,0
RegisterServer=yes
RedirectToHKCU=yes
HRESULT IEInstallScope(LPDWORD pwdScope);
I'm making cab file through makecab.exe and im signing cab file too with signtool.exe and makecert technique and finally the excerpt from the html is as following:
...
CLASSID="clsid:HJI9D4D39-K9F5-489B-8032-CCHB1B189J10"
CODEBASE="C:\xyz\13\plugins\ie\xyz.cab#Version="1,0,0,0"
...
So i dont know why Im facing this problem.The reason may be because thers something Im mistaking inside inf file or I dont know the exact usage of "HRESULT IEInstallScope(LPDWORD pwdScope); "or is it associated with dll????
please help me!!!!!!
EDIT:::well this worked out for me, but i still dont know why registerserver=yes fails to embedd activex perfectly::
new inf file is as following:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
xyz.dll=xyz.dll
[Deployment]
InstallScope=user|machine
[Setup Hooks]
xcxc=xcxc
xcxc1=xcxc1
[xyz.dll]
file-win32-x86=thiscab
clsid={HJI9D4D39-K9F5-489B-8032-CCHB1B189J10}
FileVersion=13,0,0,0
RegisterServer=yes
RedirectToHKCU=yes
HRESULT IEInstallScope(LPDWORD pwdScope);
[regDll]
hook=xcxc
[xcxc]
run=C:\Windows\System32\regsvr32.exe "C:\xyz\13\plugins\ie\xyz.dll"
[abcDll]
hook=xcxc1
[xcxc1]
run=C:\Windows\syswow64\regsvr32.exe /u /s "C:\xyz\13\plugins\ie\xyz.dll"
I have written a script to update my db table after reading data from db tables and solr. I am using asyn.waterfall module. The problem is that the script is not getting exited after successful completion of all operations. I have used db connection pool also thinking that may be creating the script to wait infinitly.
I want to put this script in crontab and if it will not exit properly it would be creating a hell lot of instances unnecessarily.
I just went through this issue.
The problem with just using process.exit() is that the program I am working on was creating handles, but never destroying them.
It was processing a directory and putting data into orientdb.
so some of the things that I have come to learn is that database connections need to be closed before getting rid of the reference. And that process.exit() does not solve all cases.
When my project processed 2,000 files. It would get down to about 500 left, and the extra handles would have filled up the available working memory. Which means it would not be able to continue. Therefore never reaching the process.exit at the end.
On the other hand, if you close the items that are requesting the app to stay open, you can solve the problem at its source.
The two "Undocumented Functions" that I was able to use, were
process._getActiveHandles();
process._getActiveRequests();
I am not sure what other functions will help with debugging these types of issues, but these ones were amazing.
They return an array, and you can determine a lot about what is going on in your process by using these methods.
You have to tell it when you're done, by calling
process.exit();
More specifically, you'll want to call this in the callback from async.waterfall() (the second argument to that function). At that point, all your asynchronous code has executed, and your script should be ready to exit.
EDIT: As pointed out by #Aaron below, this likely has to do with something like a database connection being active, and not allowing the node process to end.
You can use the node module why-is-node-running:
Run npm install -D why-is-node-running
Add import * as log from 'why-is-node-running'; in your code
When you expect your program to exit, add a log statement:
afterAll(async () => {
await app.close();
log();
})
This will print a list of open handles with a stacktrace to find out where they originated:
There are 5 handle(s) keeping the process running
# Timeout
/home/maf/dev/node_modules/why-is-node-running/example.js:6 - setInterval(function () {}, 1000)
/home/maf/dev/node_modules/why-is-node-running/example.js:10 - createServer()
# TCPSERVERWRAP
/home/maf/dev/node_modules/why-is-node-running/example.js:7 - server.listen(0)
/home/maf/dev/node_modules/why-is-node-running/example.js:10 - createServer()
We can quit the execution by using:
connection.destroy();
If you use Visual Studio code, you can attach to an already running Node script directly from it.
First, run the Debug: Attached to Node Process command:
When you invoke the command, VS Code will prompt you which Node.js process to attach to:
Your terminal should display this message:
Debugger listening on ws://127.0.0.1:9229/<...>
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Then, inside your debug console, you can use the code from The Lazy Coder’s answer:
process._getActiveHandles();
process._getActiveRequests();
I know this question has been asked many times but I can't find similarity with my issue. I'm getting this error only in Chrome, in every other browser everything is ok. I return data with JSON in several places but since my code works in other browsers I assume nothing is wrong with it.
Chrome doesn't show me where is error (in my code) it shows me these errors:
This is how I use JSON:
$.post("getData.php", {'id' : id}, function(data){
var obj = jQuery.parseJSON(data);
.
.
.
... some mysqli query
$data = $query->fetch_assoc();
echo json_encode($data);
So I don't see a problem here, can someone help me with this.
You can check your Network (console) and See the answer from the Server ... The "<" will be the first letter of your response. Something like "<"undefined index XY in line Z>"
My solution to this is pretty unbelievable.
<script type="text/javascript" src="/js/dataLayer.js?v=1"></script>
The filename in the src attribute needed to be lowercase:
<script type="text/javascript" src="/js/datalayer.js?v=1"></script>
and that somewhat inexplicably fixed the problem.
In both cases the reference was returning 404 for testing.
Error with Uncaught SyntaxError: Unexpected token < using #Mario answer but that was only part of my problem. Another problem is, javascript doesn't get any data from PHP file. That was solved using this code, inside PHP file: header("Content-Type: text/javascript; charset=utf-8");
This answer is found on this link, where I opened another question to solve this issue: Can't receive json data from PHP in Chrome and Opera
I got the same error ("Uncaught SyntaxError: Unexpected token <" ) at these two lines when testing a sample application .
<script type = "text/javascript" src="raphael-min.js"></script>
<script type = "text/javascript" src="kuma-gauge.jquery.js"></script>
After a control, I realized that, local file locations are not correct and my local server app returns default page as the result. Client app can find the files but the founded files are default page, not the *.js files. So I receive Uncaught SyntaxError: Unexpected token <
I changed to orginal location on the intenet andit solved.
<script type = "text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script>
<script type = "text/javascript" src="//www.jqueryscript.net/demo/Creating-Animated-Gauges-Using-jQuery-Raphael-js-kumaGauge/js/kuma-gauge.jquery.js"></script>
To override the error that you might experience in Chrome (and probably in Safari), try to set the Ajax parameter as dataType: "json". Then you shouldn't call parseJSON() on the obj because the response you'll get comes deserialized.
I have commented my this code : // $('#description').val('<?php echo $_POST['description']; ?>'); and I got that error.
header("Location: route_to_main_page");
I've encountered this problem while having a custom 404 error handling file. Instead of throwing some html content it was suppose to redirect to the main page url. It worked well.
Then I used this as a skeleton for a next project, therefore not changing the "route_to_main_page" actually on the new project (different URL) became a "route_to_external_url" so any 404 errors within your code (missing css stylesheets, js libraries) would return the "Uncaught SyntaxError: Unexpected token <".
I faced similar issue when I moved some of the js files into folders then deployed into production, after some struggle I found out that the js files were not actually got deployed to production. So
make sure that the file for which the error is shown does exist in
the server
the path given is correct
So, In the absence of js file, the server then server responds with as below
<!doctype html>
<html>
<someTag />
<AnotherTag />
</html>
Thats why we get Uncaught SyntaxError: Unexpected token <
It could be that the resource you're trying to request is under restricted access via your web app configuration, i.e. user must be logged for the application to serve the file.
Try adding this to your Web.Config file (this is for .NET applications):
<location path="js/resourcefile.js">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
You can place it anywhere before the closing configuration tag.
If you are trying to perform Ajax file upload or something similar, you have to get rid of displaying further HTML after printing your ajax response text. Probably that gives this error message. If you are using PHP framework you have to follow framework syntax to end the application. If you are coding pure PHP, you can use 'exit' after your ajax response text.
Hope this will help save some ones' time on finding solution for this. :) happy coding!!!
change it to
$.post({
url = 'getData.php',
data : { 'id' id } ,
dataType : 'text'
});
This way ajax will not try to parse the data into json or similar
Seems everyone has difference experiences from this and therfore solutions as well :) This is my "story".
My thing came from a validate.php file fetched with ajax. The output was meant to be :
$response['status'] = $status;
$response['message'] = $message;
$response['param'] = $param;
echo json_encode($response);
And the error that cause the "Unexpected token <" error was simply that in some cases $message hadn't been declared (but only $status and $param). So, added this in the beginning of the code.
$message = ''; // Default value, in case it doesn't get set later on.
So I guess, those "little things" may in this scenario big of quite importance. So be sure to really check your code and making it bulletproof.
Had the same error. My problem was caused from shifting around my project directory, and failing to adjust the path to my static files on the server to reflect the new path (i.e. was ./src/public but should have been ./public).
The only place it worked for me is when I place the scripts in public folder where my index.html resides and then placing these <script type="text/javascript" src="test/test.js"></script> inside <body> tag.
In my case, host had enabled iisnode at my web.config file so I've commented.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<!-- <add name="iisnode" path="*.js" verb="*" modules="iisnode" /> -->
</handlers>
</system.webServer>
</configuration>
I am having trouble using HTML::Mason's $m->comp to redirect from one view to another.
There is a file say file1.mi which has embedded HTML code in this file1.mi I am using $m->comp to redirect to file2.mi.
But in the webpage whenever file1.mi is loaded it prints the footer multiple times and in the logs i am getting the errors
Nested page framework application dispatch detected, this usage is not
fully supported and may result in unexpected behavior
and
Error: APPLICATION CONTEXT ERROR (RENDER): 32 levels deep in component
stack (infinite recursive call?)
. Here is the script which i am using for redirecting from file1.mi
return $m->comp('/page-framework/dispatch.mi', applicationPath =>'/gp/tradein/omc', viewID => 'file2.mi', %ARGS);
I am using this script in file1.mi before it renders the webpage -- i.e. before any HTML scripts are executed.
I am kinda new to Mason, if you have queries regarding this please go ahead.
It looks like that your file1.mi gets loaded and rendered, then file2.mi gets executed and it in infinite loop.
Please, show us more code, it is not possible to debug with that small details.
What do you in the web server logs? Please, paste some example from loglines too.
Regards,
It should be your dispatcher dispatch.mi that is calling file1 or file2. Deciding that you want to go elsewhere after the request has already been dispatched seems like the logic is in the wrong place.