This is a beginner's question -- surely already answered but I don't know how to find it:
When a coding/system error message pops up during processing of a PHP script or possibly JavaScript, its title is usually "The page at localhost [or other URL] says:". Its content usually includes a load of non-rendered HTML code (<b>, <br>, etc), a long reference to a PHP manual, an actual error message, and a reference to where the error occurred. Because the HTML is being ignored, the whole dialog is hard to read.
How can I get such windows to appear styled properly, as surely intended by the "folks at PHP or JavaScript", or at least appear in simple text with line breaks?
Please note: It is not an error message that I am intending to pop up in response to any user action; I don't know what is causing the message. Also, I'm not seeking advice on how to make user-friendly software or on how to do continuous development-and-delivery
How can I get such windows to appear styled properly, as intended?
I don't know which window you are talking about, however from the rest of your description it sounds to me that you want to turn HTML error off so to get the plain text version of the error messages.
PHP has a setting for that Docs:
html_errors boolean
Turn off HTML tags in error messages. The new format for HTML errors produces clickable messages that direct the user to a page describing the error or function in causing the error. These references are affected by docref_root and docref_ext.
So all you need to do is to turn if off, either in your php.ini:
html_errors = 0
Or within your code:
<?php
ini_set('html_errors', 0);
You might also be interested in:
How to get useful error messages in PHP?
Never have your errors show up in a production website!!
If you're talking about dealing with errors while you're developing, then check out the Whoops library. It'll give you everything you want, plus much more.
Here's a quote from their homepage:
whoops is a nice little library that helps you develop and maintain your projects better, by helping you deal with errors and exceptions in a less painful way.
Check out their demo here. You can click on the left side to go through the stack. Really cool.
Related
firstly very sorry, I cant find out what the real problem is.
I ll try to explain.
My client given code which is developed using opencart and nitropack.
he includes common.js in header, it is basic js file with some ajax calls, UI events etc which has 1297 lines(no formating in code, lots of blank spaces, blank lines etc).
my real problem is, when I made any changes in this file,
the browser console is throwing error invalid or unexpected token.
I checked the common.js file in browser console, seeing that some kind of reddots added at last of the file. I just added a alert() at the begining of file. nothing else.
very sorry, dont know how to explain more detaily.
This is the first time I have seen this kind of issue.
when I removed the alert(), the error gone.
I've been really stumped on this issue for the past week and after countless hours of it not working, I am hoping someone more knowledgeable may be able to help! :)
I am creating a view pane which has a list of divs done one side holding a small bit of information such as a title and then once these have been clicked on more detailed information shows on the left. To do this have it linked up to a database which stores information ( for this it is record information).
The image attached shows an outline of what I am aiming for. There is also a screen grab of my database uploaded.
I have created the basic outline of it (albeit a rather ugly one for now! ) but I cannot get the information to show on the left hand side when it is clicked on.
The only error I have on the console is : Uncaught SyntaxError: Unexpected token <
On the connect_and_get page. I have already run the code through visual studio but didn't find any errors.
I would really appreciate any help.
Please see the code attached: https://bitbucket.org/snippets/AimeeH/je56K
Many many thanks in advance
Layout I'm aiming for
This is a syntax error
<?php
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script> is not valid php. Either exit the PHP (?>) or echo the line.
For anyone who might want to reference this, I did get it working in the end although I am not completely sure as to why ( I am still very new at this!) here's what I remember doing, I really hope it helps!!
I changed all the " marks into ' (turned all the quotes into singular ones) as I read that PHP can sometimes have issues with this.
I actually uploaded the code to an online server (I used C-Panel) instead of running it on my computer with a local server running. This also meant that I made a new database for c-panel as the data would now all be accessed through this.
I added the user name in front of the table name (as this was how cpanel recognised the table name)
These were the main changes I made, and then using the console on Google chrome I worked through all the errors that popped up. As now the error messages being given were clear and useful.
I hope this helps :)
I need to bruteforce through pages and check it's contents for certain text.
ie. I have page: http://example.whatever/internet?ip=$4.2$$.$$6.$$$ and those dollar signs, are missing numbers. I need to go through all of existing combinations untill 404 - Page not found text isn't present on that page anymore (it's not an error code, that gets returned, just the text.)
I also need to be able to use it when there is login required to access the pages, and I have the necessary access, that's why I suggest JS to be used in this, and not server side script, like PHP or Python.
Edit 1: In case you want to complain, that this is not a question, I'm asking how to do it. And if you don't have the balls (or whatever it is you have or don't have) to comment bellow, why you did press that arrow down next to this question, so we can resolve it, please don't do it. Thanks for understanding.
I'd recommend using something like PhantomJS for this. You could login then iterate through pages until you find a non-404 page.
This is a NEAR duplicate of this post which has a very nice example of ember-validations (without EAK) here. However, I am wondering if anybody can do an EAK version of this for me, with the one difference that the JSBIN has validation errors shown only once the user has blurred a form input. This jsbin shows the errors on load. I would expect to see the validation messages come after the field has been focused for the first time at the very soonest, rather than onload. Im not sure if this is an artifact of JSBIN implementation or the actual expected feature design of ember-validations. I would love to see a clean EAK in git or bitbucket that has just this, the same 5 or 6 inputs in the index.hbs that are tied to a controller with the same five elements in the validations object, but the difference that it doesn't show errors until after the controls are at least interacted with once by the user. I would be extra happy to see the steps the user took at the terminal to add ember-validations to their EAK, because currently, I'm following this study below and I am unsure if perhaps the problem is not the EAK implementation, but rather the manner in which I've brought the ember-validations.js into my app in the first place. I've had some conflicting suggestions on how this should be done, but considering that right now, I have at least seen error messages in the page it's hard to tell if there's a problem with the way the script is included or not.
gem install bundler
git clone git://github.com/dockyard/ember-validations.git
cd ember-validations
bundle install
bundle exec rake dist
cp dist/ember-validations/ember-validations.js vendor/ember-validations/ember-validations.js
subl app/index.html
insert line 57: <script src="/vendor/ember-validations/ember-validations.js"></script>
open http://localhost:8000
With this, I am able to see the errors highlighted when the app loads. However, for my attempt, I don't see the errors clear or the continue button enabled after satisfactory input is added. So I am having the same unwanted functionality as the JSBIN and the OP. This maybe a more basic ember js question, or a basic EAK question, but I would love to see a simple ember-validations set up in EAK(ES6) format. With a list of files, their locations, or better still a git to clone.
Also, I am looking to see this done without FIXTURES or DS store if possible. I am thinking a simple object in the controller. It appears to me in the documentation that as soon as the object is created, validation fires. So, how to defer the validation until after the form-controls are interacted with?
Thanks!
Edit: So, I was able to get the EAK architecture to happen... anybody interested in my solution, there's a bitbucket repo now for you to inspect and enjoy!
Edit 2: So, looking and thinking about this some more. It makes sense the way it is. It's only my styling and message language that makes it clunky. Of course the presence: property makes them seem like errors, but they are in fact, also hypostatized as cta's or call to actions, highlighting fields that need attention. When the fields are empty initially, instead of thinking about them like errors, think about them like attention getting call outs. Since my button is disabled as long as the fields are inValid, there's no reason to have the messages at any other time, since there will never be a use case in which the user has submitted the button without satisfying the presence and other properties of the validations object. So, to solve my "problem" I just need to think about the errors differently. Instead of styling them with an error class, I'll style them normally, and when presence is satisfied, show a checkmark or something friendly like that. So in effect, these validations are working as I want them to. It's just a matter of not following the out-of-the-box nature of the message error styling.
Double Thanks!
Does anyone know what the core drupal javascript functions are to force an error message? More importantly, it must work with Message Effects (http://drupal.org/project/messagefx).
With JS Theming you can call these: (this is javascript code)
Drupal.messages.set("The Message!", 'error');
But, it doesn't hook into Message Effects, and after disabling JS theming, this function no longer works.
It seems like you have asked the wrong question. The status, warning, error messages that you see, is not invoked by javascript. Instead they are generated by the drupal_set_message() function. It work, by saving the messages in the session table for that user, and then they get printed whenever that user (re)load a page. It ends up as $messages in the page.tpl.php. I believe that there are no javascript version of this functionality, but you could mimic it. It's no harder than to insert some html on the page, something like.
$("#message").append('<div class="message error">The error message</div>');
I'm not sure about the exact html structure, and it cal also vary from theme to theme, but you get the idea. If you do take this approach, you will also need to hook into the messagefx module's js, to add the effect, but this shouldn't be too hard.