Jump to content


Popular Content

Showing content with the highest reputation since 05/18/2018 in all areas

  1. 1 point
    I'm not sure what "from inside the div" means. Does that mean that the script that's doing the replacement is inside the div? As far as replacing the content of any element, you can either set its innerHTML property or use DOM methods such as removeChild() and appendChild().
  2. 1 point
    I don't understand the question. Replacing the contents of any element on the page is the same regardless of the content you're replacing it with. Methods of replacing content in an element do not change based on the content. I don't know if you're referring to appending content instead of replacing.
  3. 1 point
    The PHP manual says prior to any output. The reason being that it has to be in the HTTP headers section. If you have studied the HTTP protocol it should be clear. An HTTP response consists of two sections: The headers and the body. The headers provide information about the data being sent, such as the amount of bytes, the file type and also cookies. After the headers goes two line breaks and then the body. The body is the actual file contents. In order to be efficient, PHP goes sending data back to the client while it is still processing, which means that as soon as any content is printed, whether it be HTML or anything else, it immediately sends the two line breaks and enters the body section of the HTTP response. Once those two line breaks have been sent it is impossible to go back an send any more headers to the client because whatever you send is going to be considered part of the body. While PHP is usually used to send HTML, it can also send any other kind of content, like image data, a video or an excel file. PHP can output content of any kind, so saying that headers have to be sent before the <html> tag just covers the specific case that the first part of your output is the string "<html>". The general case is that the headers have to be sent prior to any output.
  4. 1 point
    Indeed, kind of embarrassing to post an example where you send output before trying to set a cookie with a header. The error message with the header tells you where output was sent (in the case of the error message above, line 2), and where you tried to send a header by calling the header or setcookie functions (line 94 in that error message). You need to move anything that sends a header before any output. So, in the case of that error message, you need to set the cookie before line 2 (or just don't send any output at all until PHP is finished processing the request).
  5. 1 point
    The setcookie() call has to be done before any HTML is printed, even before the <!DOCTYPE> declaration, because cookies are sent with the headers which have to go before the content.
  6. 1 point
    It seems the error relates to sessions not cookies, and since it says line 94, In my mind its not related to the cookie code you have supplied. <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php $new_cookie = "123456789abcdefg"; setcookie("username", $new_cookie, strtotime('+30 days'), "/", "", "", TRUE); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" id="viewport" content="target-densitydpi=high-dpi,initial-scale=1.0,user-scalable=no" /> <title>Document Title</title> <script type="text/javascript"> </script> <style type="text/css"> </style> </head> <body> <?php echo $_COOKIE["username"]; echo "<br />"; print_r($_COOKIE); ?> </body> </html> This is what we are discussing.
  7. 1 point
    On loading of the page the first time NOTHING if the cookie does not already exist, but the cookie will be set by the second line. The second time the page is loaded because the cookie now exists, the first line will cause it to be deleted, then the second line will set it again and the circle will start over delete, set on page load, delete, set on page load and so on... It will be deleted. NOTE: With your current code, it won't expire i.e be deleted, as the expiry date increases by 30+ days from current date everytime time it is loaded.
  8. 1 point
    Look up the return transfer option to see what it does. cURL outputs the response by default unless you tell it not to.
  9. 1 point
    First, I have no idea what Colorbox is supposed to be, I'm just talking in general here. If you look up CSS media queries you'll see that you specify things like a min-width or max-width in the rules, and then the browser will apply the rules that match. So, for example, you can say that if the screen is too small, then certain HTML elements should be hidden. If you want to also do similar things in Javascript that's fine, there are multiple ways to get the browser dimensions in Javascript. This information is not available in PHP, through $_SERVER or anywhere else, because PHP is not running in the web browser, it's running on the web server. It has no information about the client device other than what was sent in the HTTP headers. For what it's worth, I've also never looked into Matomo, I don't know what it does or what it's used for. I'm talking about general techniques here that you can apply to any situation, not things dependent on any particular plugin or piece of software that you're using on your site. CSS media queries are a general technique, in fact they are a major way to implement responsive design (where the page layout - i.e. CSS rules - change depending on the page size).
  10. 1 point
    You're missing a meta viewport tag in overview.html.