Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. It should be "expires", with an S. The function toGMTString() is deprecated, use toUTCString(). Aside from that, yes, your script is right. Using the same cookie name but changing other parameters will overwrite the value of that particular cookie.
  2. Ingolme

    Problem using PDO

    You would need to call $query->errorInfo(), not $db->errorInfo(). But what exactly is the program doing and what did you expect it to do?
  3. The tutorial page explains it clear enough: The length doesn't matter. The cookie tutorial also explains multiple cookies: Setting a cookie, or changing its value, won't interfere with any of the other cookies.
  4. Ingolme

    Ajax call

    "Executable" is not the right word for this. Executable refers to binary files that the operating system interprets as a program. AJAX is a technology that loads content from a file. You tell AJAX where the file is and it will load the content. In the example it is loading the text that is stored in a file called "ajax_info.txt". Here's a link to that file so that you can see it for yourself: http://www.w3schools.com/ajax/ajax_info.txt The extension of the file doesn't matter, AJAX loads whatever is in the file regardless of what extension it has. It could be called "ajax_info.txt", "ajax_info.html" or "ajax_info.js" and it wouldn't make a difference.
  5. Cookies are in the Javascript tutorial: http://www.w3schools.com/js/js_cookies.asp Cookies only contain strings, but casting from number to string or string to number is easy. Usually it occurs automatically. If you pass a string to a property that expects a number it will be interpreted as a number.
  6. You just need to set it to an empty string before you begin the loop. var propiedades;content.innerHTML = "";for (propiedades in objeto){ content.innerHTML += propiedades + ':' + objeto[propiedades] + "<br />";}
  7. You have to call the function after you have declared it. This line: jssor_slider2_starter('slider2_container'); has to go further down in the page than this line: jssor_slider2_starter = function (containerId) {
  8. Ingolme

    Ajax call

    Which try-it demo are you referring to? Could you link to it? The content received by AJAX is in the responseText property. In the following example, the response is being displayed as the innerHTML of the element <div id="myDiv"> http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first
  9. That should be easy to figure out: Look at the ID you're giving it, then look at the ID of the element itself, see if they match. It would have taken you less time to look through your own code than to wait for an answer from me. So here's what I see: You are telling it to look for "slider2_container" There is an element on your page called "slider_container2"
  10. That's the idea. But you could find that out on your own: try it out and see if it works. You should check the browser's error console when using Javascript.
  11. You probably should call the jssor_slider2_starter() function after the element has loaded. It's a good idea to put all your scripts at the bottom of the page right before the closing </body> tag to make sure that all other page elements have loaded already.
  12. Image elements are empty elements. You can't put anything inside them. If you want a watermark, open the image in a photo editor and add the watermark manually. If you really want a program that automatically adds watermarks, learn about PHP's GD library: http://php.net/manual/en/book.image.php
  13. It's not intended primarily for SEO. It is just an attribute that tells where the quotation comes from. The fact that browsers decided not to show anything is just a design choice by the browser vendors themselves.
  14. First you execute the query, then you do comparisons with whatever data has been returned from the query.
  15. You'll need to store some data on the server. I'd just make a file for it. The link will target a page, which I'll call "target.php". Inside target.php: <?php// Get the number from the file if the file existsif(file_exists('counter.txt')) { // Cast the contents of the file to an integer $counter = (int) file_get_contents('counter.txt');} else { // If the file does not exist, the counter is zero $counter = 0;}// If the page hasn't been visited yet the counter will be zero (and just in case we'll also include negative numbers)if($counter <= 0) {?><h1>Page content for first viewer</h1><?php} else {?><h1>Page content for all other viewers</h1><?php}// Increase the counter and save it to the file$counter++;file_put_contents('counter.txt', $counter);?> This is going to expire really quickly if it takes just a single visitor to make the first content unavailable forever.
  16. What are you seeing in the console? Perhaps their representation of the data is confusing you. Try this: console.log(links[0].nodeName);
  17. The padding is not being added to the text, it's being added to the box surrounding the text. <li> elements are blocks, they are invisible boxes (until you give them a background or border, then they are visible).
  18. Does it matter who has clicked on the link? That means: if person A clicks on the link, does person B from halfway across the world see the counter increase? Does this reset after each browsing session or is the change registered forever?
  19. The result of the crypt function is what you should store in the database. There is no need to remove anything from the value given by crypt, keep all of it. If you pass the very same parameters to crypt, it should yield the exact same result. You must use the same salt when comparing a password as you did when you created the one that's in the database. If the comparison is failing, print out both the database value and the user input to see why. Remove the location headers until you're done testing, otherwise you won't be able to see any output given by the script.
  20. Tutorials that are not listed on the left column of the front page are likely to be obsolete for one reason or another. W3Schools has changed a lot, adding, removing or merging tutorials. If you found a Web services tutorial it might be that they haven't yet removed the pages from their server. A few years ago it was linked from the front page, but it isn't anymore and there probably is a reason for it.
  21. Ingolme

    Problem using PDO

    What does "not working" mean? Are you getting any error messages? Maybe there is an error in the query. Use errorInfo() to find out. You should prepare the statement outside of the loop, it's much more efficient. Statements only need to be prepared once, they can be executed as many times as needed.
  22. Line-height adds space above and below the text. By setting the line-height to 1em you remove extra space between that element and the ones above and below it. You can add top and bottom padding to compensate. 0.5em of padding on each side should be enough.
  23. You can't put block elements inside a span. Give a class name to your <li> element: <li class="single_line_height"> You should use units for your line height: line-height: 1em;
  24. Bind_param is used for the input parameters, bind_result() is for the results of that query. I've fixed up your script: // Catch user details!$username = $_POST['username'];$password = crypt( $_POST['password'], '$2a$07$saltgoeshere$' ); // Make the salt unique for each password// Statement - Prepare & Bindings$query = "SELECT user_id, user_username, user_first_name, user_last_name, user_password FROM users WHERE username=? AND password=?";if ($stmt = $mysqli->prepare($query)){ // Input parameters that are put into the query before you execute it $stmt -> bind_param('ss', $username, $password); // execute statement $stmt->execute(); // Set output variables, these are the data from the database fields, user_id, user_username, user_first_name, user_last_name and user_password $stmt->bind_result($result_id, $result_username, $result_firstname, $result_lastname, $result_password); // Fetch data from the query $stmt->fetch(); // That's it, nothing more. // Use the variables however you like: echo "The data is: {$result_id}, {$result_username}, {$result_firstname}, {$result_lastname}"; // close statement $stmt->close();}// close connection$mysqli->close();
  25. Check this page: http://ca2.php.net/manual/en/mysqli-stmt.fetch.php Example #1 Object oriented style. First you execute the statement, but the execute() function does not return results. You need to use fetch() for that. Right from the example: /* execute statement */$stmt->execute();/* bind result variables */$stmt->bind_result($name, $code);/* fetch values */while ($stmt->fetch()) { printf ("%s (%s)n", $name, $code);}
×
×
  • Create New...