Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. Yes, as long as on both sides of the / there's a number it will be interpretted as a division. The code you show here works.
  2. If you set the opacity of the table to 90%, then the entire table, including text and images that belong to it, will have 90% opacity. If you want a background color that's transparent, use the rgba() color codes.
  3. Then you should be able to know when the tiles are in the order you want them to be.
  4. If you want to know whether the tiles[] array is [0, 1, 2, 3] then just make the matchb[] array equal to [0, 1, 2, 3] and use that code.
  5. You need to do all the validation before putting the data into the database. After all the validation is done, if no errors were found, then you run the query.
  6. Where is the code that writes to the database?
  7. By opening the file in "a" mode you're appending new data onto the file which causes it to not be real JSON anymore. This is JSON: {"property":"value"} This is not JSON {"property":"value"}{"property":"value2"} If you want to actually add more to the data, you'll have to decode the JSON, add the data, then encode it again before writing it to the file. When you do write to the file, set the file mode to "w" to overwrite what's already in the file. JSON is usually dynamically generated upon request, not stored in a file. If you had a database, you would get PHP to retrieve the data from there and encode it in JSON before sending it.
  8. Moving the function test_input() outside of the if() statement solves the problem. I am getting some other errors. Some errors are probably not showing up for you because they're a lower level. To make sure all errors are visible, add this at the top of your page: error_reporting(E_ALL); The first error I'm getting is that you forgot to define $passwordErr and instead defined $password twice. The other one is that the variable $picErr wasn't defined.
  9. I did a quick search for your first error message and this is what I found: http://stackoverflow.com/questions/10759334/headers-and-client-library-minor-version-mismatch As for the error on line 36, you need as many characters in the string ("ssss") as you have variables. In your case it would be "ssssssss", unless you want one of the variables to be an integer, floating point number or binary data.
  10. I'm not entirely sure what your specifications are. Pretty much anything can be done if you use the right tools. Javascript on its own probably won't be enough to do it, but a desktop application or online form involving a server-side language can. It depends on where you want the information to go. You can leave this thread here in case somebody wants to take on your project. I'm not doing freelance work since I have enough to do at my job.
  11. There must be more code that you're not showing. If you put that code right between <script> tags it will work. If it's inside a function, you have to make sure that the function is being called at some point.
  12. Ingolme

    Mysql

    http://www.w3schools.com/php/php_cookies.asphttp://www.w3schools.com/php/php_sessions.asp
  13. Your server is set to not display PHP errors. If you put this at the beginning of your file you should see error messages that tell you why the code isn't working: ini_set('display_errors', 1); The reason it's not working is that this if() statement doesn't have a closing brace: if ($_SERVER["REQUEST_METHOD"] == "POST") { Another problem in your code is that you've misspelled "password" in this section of your code: if (empty($_POST["pasword"])) { $paswordErr = "Pasword is required";} else { $paswrod = test_input($_POST["lname"]); // check if last name only contains letters and whitespace if (!preg_match("/^[a-zA-Z0-9]*$/",$pasword)) { $paswrodErr = "Only letters and numbers allowed"; }}
  14. I don't think a single quote is a string delimiter in VB.NET. I believe a single quote begins a comment.
  15. If this page is being used in response to an AJAX request, then output a JSON string. If it's handling the forum submission on its own then you'll have to output an HTML page. If you want to have the same page to do both, just add a parameter to the query string when you make the request using AJAX so that PHP can know what type of response to give. In your Javascript, add ?ajax=1 to the URL, then PHP can test for that: if(isset($_GET['ajax'])) { // Show JSON} else { // Show HTML}
  16. XHTML 1.0 is outdated and none of the new HTML 5 tags are supported by it. If you want to use HTML 5 elements, then you must use HTML 5.
  17. Ingolme

    Mysql

    No, it doesn't create the password. The define() function creates a constant. A constant in PHP is just like a variable except that it can't be changed.
  18. This is the W3Schools example of how to loop through an array: for (i = 0; i < cars.length; i++) { text += cars[i] + "<br>";} The variable i refers to the index of the array that is currently being used. The .length property indicates how many elements are in the array. If you're comparing two arrays, you just need to make sure that element i of one array is the same as the element i of the other array.
  19. You should have the order of the solution in an array. Every time a piece is moved, compare the current order of the pieces to the solution array. You can use a for() loop to compare the arrays. If the two arrays are the same then you know the puzzle is solved and you can load a new puzzle.
  20. If there are only seven and you already know the index then you don't need a loop. The code would be something similar to this: if(is_numeric($arr[0])) { ... }if(is_numeric($arr[1])) { ... }if(is_string($arr[2])) { ... }if(is_numeric($arr[3])) { ... }if(is_string($arr[4])) { ... } It's more efficient than a loop. Loops in general are less efficient than a long list of instructions, programmers often use a technique called "loop unrolling" to reduce the number of loops or the number of times a loop has to execute.
  21. The question is: How do you know which ones you're testing as numeric and which ones you're testing as a string?
  22. What exactly are you trying to do with that code? None of it is proper Javascript syntax and I can't read your mind. You really should go back to the Javascript tutorial and read and practice with the examples there. I could, if I knew what you were trying to do, write some code for you, but it would be pointless because you would still have no idea why it worked.
  23. No, I can't. I don't know what the cannon does or how it works. I need a clear specification of what your program is meant to do.
  24. If you represent the number in binary you'll get a series of 0s and 1s. The >> and << operators move the 0s and 1s to the right and left, respectively. 5 in binary is 00000101. If you shift them to the right by 1 the result is 00000010 (in binary) which is 2 in our system. The last 1 disappeared because it's outside of the bits that belong to the number. If you shift 5 to the left by 1 it would be 00001010 in binary (empty spaces get filled in with zeroes), which is 10 our system. Shifting to the left or right is equivalent to multiplying and dividing by two, except the computer can do the operation much faster.
×
×
  • Create New...