I have got an issue that I don't know how to debug. Sometimes the output suddenly stops halfway through a PHP script, after a specific echo.
This is a part of the code. After someLonJsonString the output sometimes stops. When the output stops, refreshing the page won't help, so it has something to do with the value also?
<div class="ac-calendar-options">
<div class="timestamp"><?php echo $currentTimestamp;?></div>
<div class="someLongJsonString"><?php echo $someLongJsonString;?></div>
<!-- The output of the script will cut off here -->
<div class="timezone"><?php echo $timezone;?></div>
</div>
Refreshing won't help, but adding some useless echo before the long Json string does help:
<div class="ac-calendar-options">
<div class="timestamp"><?php echo $currentTimestamp;?></div>
<div style="display:none"><?php echo "test"; ?></div>
<div class="someLongJsonString"><?php echo $someLongJsonString;?></div>
<div class="timezone"><?php echo $timezone;?></div>
</div>
When I remove the fix, the problem comes back. Above fix does fix it for that item, but after a while, it pops up again but for another item with another JSON string.
How can I debug this problem? Even temporarily showing the errors for that page/item does fix the problem. And I just don't understand why a simple echo will temporarily fix the problem.
Since we moved to php 7.x from 5.6 this problem magically solved.
Since we moved to php 7.x from 5.6 this problem magically solved. I can't provide any other info I'm afraid, this is just it...
Related
I have one small issue with my code below, I'd like the HTML view of the source code to be "tidy" as well as the PHP, I've spent days searching but I've drawn a blank as to why the HTML side is not tidy, the only thing I'm guessing is extra whitespace is being generated, if that's the case I'm not sure why, if anyone could help it would be appreciated, thanks.
html
<div class='col-md-12'>
<div class='alert alert- info'>
Already Logged In
</div>
</div>
php
<div class='col-md-12'>
<?php if ($action=='logged-in'): ?>
<div class='alert alert- info'>
Already Logged In
</div>
<?php endif ?>
</div>
Your lines with just PHP code still keep their whitespace, so the spaces at the beginning of that line and the \n at the end still count.
Unfortunately, this means you'd have to have your code look like this:
<div class='col-md-12'>
<?php if ($action=='logged-in'): ?> <div class='alert alert- info'>
Already Logged In
</div>
<?php endif ?></div>
Pretty ugly, right?
You have a couple options:
Run the final HTML (captured using an output buffer) through something like Tidy, which has indentation correction built-in as an option. A lot of work for something no one's ever gonna see, but it'll do the trick.
Use a templating system to separate out the PHP a bit. Something like Twig can probably be massaged a little easier into the nicely indented HTML you want, but there'll still be some of the same troubles if you're not careful.
Stop caring. (This is my recommendation.) Focus on the readability and simplicity of the code you'll actually be working with, not the whitespace of the resulting HTML, which pretty much no one will ever notice or care about. Take a look at the HTML generated for any major website - Amazon.com, Facebook.com, Google.com, etc. - and you'll see that this is the standard practice.
Since it looks like the root <div> will be there no matter what, try using the following:
echo
'<div class="col-md-12">',
($action == 'logged-in' ? '
<div class="alert alert-info">
Already Logged In
</div>' : '
'), '
</div>';
Fiddle: Live Demo
I wonder how can I remove footer option saying "Your are using Open Source POS Version blah blah". I've already tried to edit files but after saving and restarting server UI get blocked. that means we can't change in footer. is there anyway to edit this option without blocking UI?
Please Just add this in application/views/partial/header.php
<script type="text/javascript">
$(document).ready(function() {
$('.blockUI').remove();
});
</script>
Problem Solved :)
The footer signature "You are using Open Source Point Of Sale" with version, hash and link to the original distribution of the code MUST BE RETAINED, MUST BE VISIBLE IN EVERY PAGE and CANNOT BE MODIFIED.
Better leave it as it is. Someone went through a lot of trouble making it work, and lets you use it for free. Donate instead of altering stuff you are not supposed to touch.
Its against the license terms to remove the footer. It is always professional and to credit someone's work and effort. Anyway you just need to open application/views/partial/footer.php and remove the following code:
<div id="footer">
<div class="jumbotron push-spaces">
<strong><?php echo $this->lang->line('common_you_are_using_ospos'); ?>
<?php echo $this->config->item('application_version'); ?> - <?php echo substr($this->config->item('commit_sha1'), 0, 6); ?></strong>.
<?php echo $this->lang->line('common_please_visit_my'); ?>
<?php echo $this->lang->line('common_website'); ?>
<?php echo $this->lang->line('common_learn_about_project'); ?>
</div>
</div>
I have this situation.
Three 'section' elements, on each one i load a view
<section class="col-md-12 col-sm-6">
<?= $this->load->view('folder/view1',NULL,TRUE); ?>
</section>
<section class="col-md-12 col-sm-6">
<?= $this->load->view('folder/view2',NULL,TRUE); ?>
</section>
<section class="col-md-12 col-sm-6">
<?= $this->load->view('folder/view3',NULL,TRUE); ?>
</section>
I can delete, move or edit the view on top and the one on the bottom, but not the view in the middle, if I do so, the browser return me a blank page without errors.
I have enabled all error logs, there is nothing.
Every single view got their tags and php code perfectly idented and closed.
That one is the only one giving me troubles.
What could be the problem?
I would use firebug/ console to see if the view resource is found, or something else related to fetching the asset.
The three includes i´ve posted before are inside another one,
I save the view as cache, for this, I difined the result as a variable and send in to the browser.
$string=$this->load->view('main/mainview',$data,TRUE);
echo $string;
but i skiped an echo $string to send it to the browser, because the last parameter of load->view is false for default but in this way it must be TRUE
i´m still confused about what changes view2 does to avoid this parameter, but after solving it i can edit all file properly.
If someone considers this answer as useless i will delete it as fast as possible
Thanks for your time.
I have a small problem, and I'll try to break it down into a smaller one so I can explain it properly.
I'm working on a web application and I have a couple of divs, such as this:
<div class="1">
//search bar
</div>
<div class="2">
include_once 'actioncontroller.php';
</div>
<div class="3">
</div>
In the actioncontroller.php I'm having an action controller which decides what action to take depending on what's pressed on the page. I've put it in the second div because ultimately that's where I want to print everything.
My question is, is there any way that I can use the code from the second div in the first one, without it printing it there? Basically I want the search bar from div one to do/print the same thing as the one in div 2 does, but I know(think) that PHP can't see code above the include_once, and if I include the actioncontroller.php in the first div it will print it there, instead of printing it in the second one, as I want.
Hope I was clear enough, it's not a problem of coding, it's just a matter of how can I read the script in the first div and then run it in the second one...
Thanks in advance
My question is, is there any way that I can use the code from the second div in the first one, without it printing it there?
Yes, but the best solution is to change the code you've already written. In the long-term, it is vitally important that you minimize your "procedural" PHP code, so that nothing ever happens simply by include/require-ing a file.
Trust me on this, it works for toy project, but it always leads to insanity and pain in the end. For example, don't put this in a file:
<?php
echo("Header section");
This is bad because you have no choice about when it prints. This is a step up:
<?php
function WriteHeader(){
echo("Header section");
}
Even better would be to use classes an autoloading, but that's probably more than you need to hear right now. With that kind of approach, your main page would look more like:
<?php
// This next line simply makes the class ActionController *available*,
// it does NOT cause new things to happen on its own
include_once("actioncontroller.php");
?>
<div class="1">
<?= ActionController::MakeSomeHTML(); ?>
</div>
<div class="2">
<?= ActionController::MakeSomeHTML(); ?>
</div>
<div class="3">
</div>
This code takes the output of actioncontroller.php and saves it into a variable, which can be echo'd multiple times.
<?php
ob_start();
include_once 'actioncontroller.php';
$output = ob_get_contents();
ob_end_clean();
?>
<div class="1">
<?php echo $output; ?>
</div>
<div class="2">
<?php echo $output; ?>
</div>
I have a page where all links where working properly but all the sudden some links are not working anymore.
I am puzzling myself to undersand why. Nothing really changed. Maybe some css details.
Is there anyone who can give a clue?
Thank you for any help. me abou twhat might have happened.
Francesco
PS sorry forgot to say that looking at the source code the links are there and they work. In design view they just do nothing. They look like normal text.
<div id="centrale"><h1> Upcoming events</h1>
<div class="centrale_event">CLICK HERE TO SEE ALL UPCOMING EVENTS</div>
<p class="line"> </p>
<?php do { ?>
<div class="centrale_event">
<p><img src="<?php echo 'drawings/'.$row_rstevents['event_picture']; ?>" class="float" alt="" /><span class="big"><?php echo $row_rstevents['event_title']; ?></span></p>
<p><strong><em>Starting on <?php echo $row_rstevents['date']; ?></em></strong></p>
<p><strong>Where</strong>: <?php echo $row_rstevents['event_town']; ?></p>
<p><strong>Place</strong>: <?php echo $row_rstevents['place']; ?></p>
<p><?php echo extractFirst($row_rstevents['event_details']); ?> MORE INFO HERE</p>
<p class="line"> </p>
</div>
<?php } while ($row_rstevents = mysql_fetch_assoc($rstevents)); ?>
<div class="centrale_event"><p>CLICK HERE TO SEE ALL UPCOMING EVENTS</p></div>
</div>
Are you using Dreamweaver? I thought you might seeing as you mentioned Design View.. If that's the case then just hit F12 to view in a browser, the design view of DW is pretty lame.
Nothing to do with the link problem, but is there a reason you're using a do {} while () loop to output your database results? Using this construct will output at least one blank event before any actual data shows up, as the first time around the loop, you haven't retrieved any data from the query yet. Any reason you can't do a regular while() { } loop?