Jump to content


Popular Content

Showing content with the highest reputation since 09/19/2017 in Posts

  1. 2 points
    Included files must have <?php ?> blocks around the code.
  2. 2 points
    There's nothing formal to tell you things like that. People do it themselves, and it tends to illustrate the Dunning-Kruger effect. People who just recently started tend to rate themselves highly, and only when you get more into something do you realize how much you don't know. I wouldn't put any weight on things like that. If you want to evaluate someone's capabilities look for a portfolio or things they've actually finished.
  3. 1 point
    In the loop, the variable $row is an associative array that contains all the values that you need. The $row variable works exactly the same as it does in this example: https://www.w3schools.com/php/showphpfile.asp?filename=demo_db_select_oo For the LIMIT part, it doesn't matter if you're using PDO or anything else, you just need to put the two numbers in the query. You can have two variables: $offset and $limit and then set the query to be "LIMIT $offset, $limit". Make sure that $offset and $limit are both forced to be integers or you'll be facing the problem of SQL injection again.
  4. 1 point
    First, you have to use prepared statements to send data to your queries. If you don't it's highly likely that some unexpected data will cause errors in your query and break your program and in the worst case scenario this can be used to hack your website. You can use the IN() operator to compare a field to multiple values. This works best in PDO, where you can pass parameters as arrays: <?php $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // Set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Build a string of placeholders like ?,?,?,?, one for each array element. $amount = count($uniqueValueArray_id); $placeholders = array_fill(0, $amount, '?'); $search = implode(',', $placeholders); // Prepare the statement $limit = 5; // Make absolutely sure this value is an integer or the program will break $stmt = $conn->prepare("SELECT id, text, date, FROM text WHERE id IN ($search) ORDER BY id DESC LIMIT $limit"); // Run the statement, passing in the values $result = $stmt->execute($uniqueValueArray_id); while($row = $result->fetch(PDO::FETCH_ASSOC)) { // Display the result here however you want print_r($row); }
  5. 1 point
    It does not improve SEO, in fact it's detrimental. I don't know where you heard that. You actually have it backwards, all hashes belong to the same page, Google treats different query strings as different pages. What does improve SEO is using a hash instead of nothing at all when using AJAX to change the page content. AJAX in itself is bad for SEO but some search engines offer the ability to use the hash to indicate that the page has changed, which reduces the harm of a Javascript-driven website. For Google, the hash must have a specific format, something similar to #/!/page-name, I'd have to look it up again to make sure I got that right. In conclusion, don't use the hash to identify your pages.
  6. 1 point
    You're measuring things they are clicking inside the iframe, right? If you're trying to measure things they click on the parent site from inside the iframe, you're not going to be able to do that because Javascript running inside the iframe can't interfere with the parent site if it's on another domain. If you're just trying to measure how many times the iframe gets shown, that's as easy as updating a database table every time your page gets loaded. That kind of terminology is part of why people are confused. You're not talking about linking to your site, you're talking about embedding an iframe. Those are completely different things. Linking to your site means putting an anchor tag on the page pointing to your site. That's not what you're talking about here. And if you're talking about "impressions", using the same terminology that advertisers use, then you're just counting page views for the page that's inside the iframe. That's what I described above.
  7. 1 point
    You can't use JavaScript for login purposes on its own, because (1) it is viewable by anyone, so they identify the userID AND password , (2) it requires JavaScript to be enabled. PHP should be used for login, it should always validate and sanitize login or for any data sent to php pages, or for example that would be inserted into a database. The code is not viewable, and done in background on the server with only the html or content being returned, not any details of userid and most importantly password details. JavaScript validation is used to make it easier for the user, so the user does not have to submit and reload the page for PHP to validate and return to identify a error made. JavaScript validation being client-side can identify an error and show warnings instantly. BUT! PHP validation as mention above is always required, in case JavaScript is disabled and JS validation bypassed.
  8. 1 point
    In the first example, if you change a, b will also change because they're both pointing to the same thing. In the second example, both a and b can be changed independently of each other because they're two different arrays that merely have identical content.
  9. 1 point
    You can put a <script> tag with a src attribute preceding your code. Some people like to use Javascript to generate script tags, but if you can just write the HTML for it I find that to be a better solution. <script src="arrays.js"></script> <script> This code uses the array </script>
  10. 1 point
    It is there, but hidden. If you wish to hide the login/register part it has a class for it parent ul element, so you can use .alt-mobile-menu { display: none; }
  11. 1 point
    Instance variables are usually declared as private because OOP considers "encapsulation" to be a good thing. This is the same reasoning behind minimizing the number of global variables. If some variable does not need to be public or global then it shouldn't be. In your example the constructor sets the values of the instance variables, so they themselves don't need to be public.
  12. 1 point
    When you use jQuery and its plugins they often put additional classes on the elements. See if any of the class methods in jQuery help solve your problem, if not then you probably should use data attributes instead of the class attribute to store data. Here's how data attributes are defined: <element data-something="value1" data-somethingelse="value2"> In jQuery you can access the value of data attributes using the data() method: http://api.jquery.com/data/#data-key
  13. 1 point
    This forum has nout to do with w3schools.com tutorials, check near bottom of tutorial page and click REPORT ERROR link, though I think you will find 'filetoupload' refers to file input name retrieved from form.
  14. 1 point
    Its not a good idea to use variable names such as form or input, as dot notation uses a similar method you are using, so confusion can arise. Even using id reference name similar to function name can cause issues.
  15. 1 point
    For some reason with Experiment Two, the pagewrap element is not enclosing the sidebar and footer elements, the border along with bottom margin appears wrapping round the header only, which pushes the unenclosed sidebar down. I think you have a extra misplaced closing div after closing main tag, as when viewing page source, the last div is highlighted in red, indicating there is no relative opening div tag to go with it.
  16. 1 point
    Try this $.ajax({ url: 'newsletter_filler.php', data: {name: 'personal', length: 200}, dataType: 'JSON', statusCode: { 404: function() { alert("Page not found"); }}, success: function(jsonData) { console.log(jsonData); $.getScript('wordcount.js').done(function() { setWordConstraint(jsonData.personal['id'], jsonData.personal['length']); }); } }); The done() make sure script has completed, I don't know why used each function, as it will only loop through one set of json associated index row data? unless you plan to expand on this where multiple row of data will be read.
  17. 1 point
    What is $flash? Is that a PDO object?
  18. 1 point
    Eliminate all blank spaces before the header() function is invoked. There should be no blank lines, and no blank spaces after each EOL delimiter. This is, by far, the most common source of a failed header() function. Well, at least in my experience. Roddy
  19. 1 point
    Have you tried printing the stmt and result objects after the match attempt to see for errors? Also not sure if this may be the issue but I don't think you need to call the first line below because when calling 'prepare' it returns a stmt object for you. $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql_select); So instead try: $mysqli_stmt = $this->mysqli_obj->prepare($sql_select); Also noticed: $match = mysqli_num_rows($mysqli_result); Looks like calling procedural function calling attempt? Instead for number of rows, try: $mysqli_stmt->num_rows Use in the if condition instead of $match > 0. Also noticed and just to note, when calling a function from another function within the same object, use $this->update_record(); instead of just update_record(); Good luck! I'm sure some of the others will be here to assist as well!
  20. 1 point
    its a comment should have // at beginning; This // assume all parts are same charset } // EMBEDDED MESSAGE the curly bracket at end is part of elseif condition should be // assume all parts are same charset } // EMBEDDED MESSAGE
  21. 1 point
    You're still doing the same thing you started with. You are not passing the function as an event handler, you are just executing it immediately when that code runs. Any time you put parentheses after a function name you are telling it to execute that function immediately. If you don't want to do that, do not put parentheses after the function name. $("#prod_menu_image_1").on("click", function() { currentDiv(imageindex1) }); $("#prod_menu_image_1").on("click", {index: imageindex1}, currentDiv); Those do slightly different things. The first one uses a closure, and every time the click event runs it executes currentDiv(imageindex1) with whatever the current value of that variable is, assuming it is available globally. The second one uses jQuery's on function to specify that an object should be available inside the click handler with a property called index that will have the value of imageindex1 when that click handler was added. That data is available on the event object according to the jQuery documentation.
  22. 1 point
    In your HTTPS page all the Javascript files should also be loaded with the HTTPS protocol because the browser does not allow loading unencrypted content on an encrypted page. This file on your page is still using unencrypted HTTP: http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  23. 1 point
    in the AREA TAG example (Try it Editor) I would like to suggest to add a title attribute to the alt attribute so that the names of the areas appear in the result, which is NOT the case actually.
  24. 1 point
    What does that mean? How are you opening it? Are you just double-clicking on a file on your computer or something? If so, the PHP code won't run at all. Or, if it's actually on a web server, then there's always a request. The server responds to requests, that's its job.
  25. 1 point
    So what's your idea of coding a comment section? Before we can help you and eventually give you some code examples you need to show us some code too, we can't just give you the code without you doing something first because this way you won't learn to do it by yourself.