Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. PHP or server configuration would make sure it works for everybody. The following is an HTML solution but might not work in all browsers: http://w3schools.com/tags/att_a_type.asp <a href="file.php" type="application/octet-stream">File download</a>
  2. In object-oriented style, num_rows is a property, not a method, so it doesn't use the parentheses () Since PHP didn't throw any errors, I suppose that's not the problem. If the query says that no rows were returned that means that your query didn't return anything- Try to check the database through other means.
  3. Are you sure the field name is "<username>" rather than "username" and the table is "<accounts>" ? To count the rows, try $rows = $stmt->num_rows
  4. What you have there is an array with two elements: Object { prob2=23.5} Object { prob1=23.375} So to access the elements you would need to use data[0].prob2 and data[1].prob1
  5. I don't see any Javascript there. Make sure your text editor is saving the HTML file as UTF-8
  6. I can't see how Javascript could cause that problem. What does your code look like?
  7. Making sure that the website works for as many users as possible is a good idea. I wouldn't call that code messy.
  8. There are examples here: http://es1.php.net/mysqli_prepare http://es1.php.net/manual/en/mysqli-stmt.execute.php Here's the example from the PHP manual, edited to show where you could put $_POST variables. <?php$mysqli = new mysqli("localhost", "my_user", "my_password", "world");/* check connection */if (mysqli_connect_errno()) { printf("Connect failed: %sn", mysqli_connect_error()); exit();}$mysqli->query("CREATE TABLE myCity LIKE City");/* Prepare an insert statement */$query = "INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)";$stmt = $mysqli->prepare($query);$stmt->bind_param("sss", $val1, $val2, $val3);$val1 = $_POST['city_name1'];$val2 = $_POST['country_code1'];$val3 = $_POST['district1'];/* Execute the statement */$stmt->execute();$val1 = $_POST['city_name2'];$val2 = $_POST['country_code2'];$val3 = $_POST['district2'];/* Execute the statement */$stmt->execute();/* close statement */$stmt->close();/* retrieve all rows from myCity */$query = "SELECT Name, CountryCode, District FROM myCity";if ($result = $mysqli->query($query)) { while ($row = $result->fetch_row()) { printf("%s (%s,%s)n", $row[0], $row[1], $row[2]); } /* free result set */ $result->close();}/* remove table */$mysqli->query("DROP TABLE myCity");/* close connection */$mysqli->close();?>
  9. The <script> tag. If you want HTML elements to show up only if script is enabled, it is one of the few valid uses for document.write. Or you can use document.createElement and append them to something. <script> document.write("<p>Javascript is enabled.</p>");</script> <div id="script"></div><script> var p = document.createElement("p"); p.innerHTML = "Javascript is enabled."; document.getElementById("script").appendChild(p);</script> A third method: <div id="script" style="display: none">Javascript is enabled</div><script> document.getElementById("script").style.display = "block";</script>
  10. Technically there's no security difference between mysqli_real_escape_string and prepared statements, but prepared statements ensure that you don't forget to escape a particular string leading to a potential security problem.
  11. That's a large amount of code, a sample page would be easier to work with. But from the screenshots, I'd say that one of your stylesheets isn't being loaded.
  12. Ingolme

    Browser support

    It's been a while since I made a site but for now I'd support Internet Explorer 8 and up. Other browsers, it's hard to keep track of versions, but the last time I was supporting Firefox 3.6. Generally, I look at what features are exclusive to HTML 5 or CSS 3 and I try to make the page acceptable without those features. If you're using border-radius, I don't see it a major problem to show rectangular boxes to older browsers. For HTML 5 semantic elements, I give them a default style. Usually display: block with no margin, padding or borders. Older versions of Internet Explorer need to create the elements with Javascript in order to be able to style them. With Javascript, I test for features and if there are workarounds for missing features, I implement them for older browsers. If there's no way to get things to work in older browsers (for example, if <canvas> is being used), I check if the feature is available and display a message to the user if it's not, letting them know to upgrade their browser.
  13. <div> is just a container used for styling. It will behave just like a <span> or other inline element simply by using "display:inline" The <base> tag affects all relative URLs (URLs that aren't prepended by http:) in a page, whether it's links, images or embedded content. The base tag can be used to make all links open in a new tab but only if you set the target attribute. See more about <base> element attributes here: http://w3schools.com/tags/tag_base.asp I believe the href attribute stance for "hypertext reference" indicating where the hypertext refers to ("hypertext" means text that links to other locations), but there may be an explanation in the W3C HTML specification. I'm not sure why <a> and <link> were given their names. <a> means anchor, I guess it's a metaphor for leaving an "anchor" in another page. <link> is currently used to link files together in a semantic way. You use <link> to link a website to a CSS stylesheet or an RSS feed. You can even link it to other HTML pages. If you have pages that are meant to be in a sequence you can tell certain browsers which is the next page in the sequence, as in this example: <link rel="next" href="page3.html"><link rel="prev" href="page1.html">
  14. Hmm, that can be misleading. But I think when they say "(in order)" they mean that the property names are in the same order as the example is.
  15. I don't think it's trying to suggest that. The arguments can be put in any order, so they just happened to put it in a different order than their border example.
  16. As long as there are no echo statements and there's nothing outside <?php ?> tags then you won't get the error. This would give you a headers already sent error <?phpsession_start();// The following three line breaks are considered output// Headers cannot be sent after output is sent to the client.?> <?phpheader('location: http://www.google.com');?>
  17. Math.ceil() will round up to the next number, but 1.00001 will round up to 2 as well. It's up to you to decide a threshold and create a function that chooses Math.ceil() or Math.floor() depending on what value it has.
  18. Strings always preserve the line breaks that are in them, just alert() the string and you'll see them there.
  19. The XHTML standard has been dropped in favor of HTML 5 which is designed for the modern web. At a time there were two competing upcoming standards: HTML 5 and XHTML 2.0, but XHTML 2.0 was scrapped. HTML 5 is already "standardized" and the W3C and WHATWG encourage its use, saying that the sooner developers are using it the faster it will be fully implemented in all browsers. A large amount of HTML 5 features are fully functional and those that aren't can fall back to other methods. DHTML is a 90s term that just means a combination of HTML, Javascript and CSS to make interactive pages. The term hasn't been used in forever so I would just forget about it if I were you. If you want your website to be compatible with XML readers, it's totally fine to write HTML 5 with XML syntax, this is known as XHTML 5. Don't forget to put the <?xml?> declaration
  20. The law states that any creation is automatically copyrighted to its creator without need of any paperwork at all. It's even copyrighted to you if you don't put a notice on your site.
  21. If you know what == is, === is similar, but it also makes sure that the type of the two variables is the same: $a = 1;$b = "1";if($a == $ { // This statement evaluates to true because $a and $b are both 1 echo "A and B are both 1";}if($a === $ { // This statement evaluates to false because $a is a number and $b is a string echo "A and B are both 1 and are both the same type";}
  22. Good websites only use Javascript for validation to make things faster for the user, on the server-side the data is being validated again by PHP. If Javascript is disabled a website should still validate the data.
  23. There is no native PHP function called "render()", it's part of Drupal, and it's probably explained in their documentation. I wouldn't recommend trying to understand large web applications until you're more fluent with PHP.
  24. An AJAX request doesn't have to send anything. You can see some of the examples in the W3Schools tutorial that simply request data. An AJAX request will open the file as if it had been opened in the browser, there's no difference from the server side. Just for security, I wouldn't make it so easy to delete the account, I would request the user for his password, at least.
×
×
  • Create New...