Ingolme

Moderator
  • Content count

    12,892
  • Joined

  • Last visited

  • Days Won

    307

Everything posted by Ingolme

  1. The problem is that in MySQLi, fetch_assoc() doesn't work with prepared statements. To get results in MySQLi you have to use bind_result() and then fetch(). I've found that store_result() is necessary too. This is why I prefer PDO to MySQLi.
  2. This is from the page you just linked to The query here is a SELECT statement.
  3. In object-oriented programming objects are composed of properties and of methods. Properties contain information about the object and methods are actions that the object can do. In your code the GameGuess object has a Send () method. Your do...while loop is not inside a method, but in Java, all logic has to be inside methods. If you have changed your code, please post your new code.
  4. Your code is not inside a method. In Java, all the code must be inside methods. What program are you using to write Java? It should be highlighting those syntax errors. if you don't know what a method is, you'll have to start learning the very basics of object-oriented programming.
  5. Link directly to the file, the browser will prompt them to download it, or will display it right in the window if it has PDF reading support. There is no better way, PDF documents cannot be embedded in a page.
  6. Your loop isn't inside a method, I don't believe this code will even compile.
  7. That is PDO, it won't work with your MySQLi connection. See an example for opening a PDO connection here: https://www.w3schools.com/php/php_mysql_connect.asp
  8. Yes, that's secure. I don't believe rowCount() works like that in PDO, though. Just remove the rowcount part and check that you were able to fetch a row instead: if($row = $stmt->fetch(PDO::FETCH_ASSOC) { $id = $row['id']; $name = $row['name']; $age = $row['age']; } else { echo 'No data available'; }
  9. Have you verified that the image was loaded? Open the developer tools (Pressing F12 on the keyboard) and make sure that "DAVIS LOGO_0.png" is getting a 200 status in the network tab.
  10. That's a bootstrap example. It doesn't help with CSS.
  11. The correct HTML for a text area is <textarea> Block elements are displayed with a new line before and after them, keeping them on their own line. The correct document type declaration for HTML 5 is <!DOCTYPE html>. In the generalized document type definition the keyword that follows "DOCTYPE" is the name of the root node of the document. Since HTML 5 <svg> elements can be placed right in the HTML document. Audio files are embedded into the page using the <audio> element. There's the <meter> element to display a scalar measurement within a range, but Internet Explorer 11 and under don't support it. The <header> element is used to indicate the header of the page, section or article. The <head> element just contains metadata about the page.
  12. Can you not remove it from the HTML? That would be the ideal solution. In CSS, you can give a class name to the object or you can use the :nth-child selector. .responsive-menus-simple li:nth-child(2) { display: none; }
  13. I don't see the issue you're talking about, but perhaps you're referring to the fact that two different tables have differing column widths. The width of a table and its cells is calculated by the width of the content within it. You can set the width of the left cells to a specified value and that will work as long as the content fits inside the cell.
  14. That sounds like a browser quirk. The permitted values for list-style-type are here: https://www.w3schools.com/cssref/pr_list-style-type.asp Usually when a browser encounters an unknown CSS value it ignores the rule, but in this case it seems to be using numbers instead. I would not rely on this behavior because it's not standard so it's not guaranteed to work like that on all browsers.
  15. canvas

    There's a "Report Error" at the bottom of the page, but if you test the code in this editor you'll see that it works: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_canvas_createpattern That's because the fillStyle property is used by the fill() method, not the rect() method. The fill() method fills shapes that were created earlier in the code.
  16. First, find your limits: var leftLimit = init_pos[0] - 100; var rightLimit = init_pos[0] + 100; Then store the currently calculated position: var newX = init_pos[0] + e.pageX - drag_start [0]; If the position is within the limits, use that position, otherwise use the limit. if(newX < leftLimit) { newX = leftLimit; } if(newX > rightLimit) { newX = rightLimit; } Finally, set the style of the element: drag_target.style.left = newX + "px";
  17. You didn't specify that you were talking about W3.CSS. Since this is in the CSS forum I thought you were talking about plain CSS. I don't use CSS frameworks, myself, so I haven't really looked at W3.CSS. If there's something the framework doesn't offer, you can write some of your own CSS to override it.
  18. What's a "color library"? You have a range of over 16 million colors to choose from in CSS
  19. The comma is used to separate selectors. If you want descendants of the .nav element, just separate them with a space: .nav ul { /* Rules */ } .nav li { /* Rules */ }
  20. When using prepared statements you don't have to worry about SQL injection, MySQL escapes the data for you. It doesn't matter whether it's INSERT, SELECT, UPDATE, DELETE or anything else. Just put placeholders anywhere where variables would have been used. Here are examples of different queries with placeholders in them: INSERT INTO table (field1, field2) VALUES (?, ?) SELECT * FROM table WHERE id = ? UPDATE table SET field1 = ? WHERE id = ? DELETE FROM table WHERE id = ?
  21. You will need to change your code. As of PHP 5.5, the server will show warning messages if you're using the mysql library and in PHP 7 the mysql library will no longer be supported. If you're interested in keeping your code working on newer platforms you will have to update it to use a newer library.
  22. Which element are you setting the height for? Setting the height of .first will affect the height of the background image. You can also set the padding of .first (not margin) to give more space for the background within the element.
  23. The form attribute only applies to form control elements. It doesn't exist on elements like <div> or <p>. What kind of element are you referring to when you say "non-form element"? This is regarding the form attribute from the MDN page for the <input> element: When the element is a descendant of a <form> element the form attribute is not needed. If the element is not inside a <form> then the form attribute will indicate which form the element belongs to so that when the form is submitted the element's value is added to the data that is sent. I'm not certain how fieldset elements behave, I would guess that the fieldset's children would belong to the same form that the fieldset belongs to, but it can be easily confirmed with an experiment. Experiments can be done with the form attribute by submitting the form and seeing which values get sent to the server. My guess before doing experiments is that a child of one form that has a form attribute from a different form will be added as a value when either of the two forms are submitted.
  24. The mysql library is deprecated for security reasons, use PDO or MySQLi. To stop injection, escaping is no longer the correct solution, the proper solution is to use prepared statements. W3Schools has a tutorial page about prepared statements.
  25. You can use scandir() to list files in a directory and generate the HTML for the images. The line breaks exist, but HTML doesn't render line breaks unless you specifically put a <br> element. You can use nl2br() to show line breaks in the text provided by users. You can't choose the size of a file, but you can give a size limit in the file uploader. There are plenty of PHP file upload tutorials, you should look at some of them. The W3Schools tutorial has sections explaining how to limit the file size and file type. You can use str_replace() to change substrings into something else, such as in the following example: <?php $string = str_replace(':)', '<img src="smiley.gif">', $string); ?>