Jump to content

Barand

Moderators
  • Content Count

    21,393
  • Joined

  • Last visited

  • Days Won

    542

Everything posted by Barand

  1. @Cor4Flez Let sleeping posts lie. This one is two years old.
  2. @Hendz I recommend you use PHP's password_hash() and password_verify() functions.
  3. This should get you started (if you haven't already) ... $array = array ( 'data' => array ( '0' => array ( 'latitude' => 22.934566, 'longitude' => 79.08728, 'type' => 'county', 'distance' => 44.328, 'name' => 'Narsinghpur', 'number' => '', 'postal_code' => '', 'street' => '', 'confidence' => 0.5, 'region' => 'Madhya Pradesh', 'region_code' => 'MP', 'county' => 'Narsinghpur',
  4. 0 out of 10 for formatting. What have you tried so far? What was the outcome?
  5. You could, except that does the exact opposite of what is required in this instance.
  6. It certainly wasn't how to read replies and take advice 🙂 , so again, in case you missed it, here's the 1 line solution with no SQL required echo round($pop / (date('z')+1));
  7. Alternaltive method... mysql> SELECT * FROM users; +--------+--------------+-----------+----------+ | userId | fullname | firstname | lastname | +--------+--------------+-----------+----------+ | 1 | Peter Dowt | NULL | NULL | | 2 | Laura Norder | NULL | NULL | | 3 | Tom DiCanari | NULL | NULL | | 4 | Scott Chegg | NULL | NULL | +--------+--------------+-----------+----------+ mysql> UPDATE users -> SET firstname = SUBSTRING_INDEX(fullname, ' ', 1), -> lastname = SUBSTRING_INDEX(fullname, ' ', -1);
  8. The missing quotes around $password aren't helping either, but when you do it correctly, using a prepared statement, then that problem will disappear.
  9. You will actually need both the id and the name The label/for attributes use the id, POST variables use the name.
  10. I gave you a one line PHP solution in my first post Your code works for me. It could be a conection problem. Check for mysql errors using mysqli_report() (EG this is my mysqli connection code)... mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $db = mysqli_connect(HOST,USERNAME,PASSWORD,$database); $db->set_charset('utf8');
  11. Show your current code that gives that result. Why do you insist on usng SQL for this?
  12. Do you charge per line of code, or are you of the school of programming that thinks "Why use one line of code when you can do it with several?" Anyway, here's a mysqli version $pop = 54321; $result = $donnees->query("SELECT DAYOFYEAR(CURDATE()) as dayno"); $row = $result->fetch_assoc(); echo round($pop / $row['dayno']); //--> 1006
  13. The main point is the query. Use DAYOFYEAR to get the number of days from start of year, it's easier and doesn't produce a zero value. (and you can use that same query just as well with MySqli) Yours will fail (div by 0) if you run it on the 1st Jan. Also note the use of SQL is overkill when you can do what you want with a simple one liner in PHP.
  14. Alternatively $pop = 54321; $res = $pdo->prepare("SELECT ROUND( ? / DAYOFYEAR(CURDATE()))"); $res->execute([$pop]); echo $res->fetchColumn(); //--> 1025 or (no database required)... echo round($pop / (date('z')+1)); //--> 1025
  15. You can do with a single INSERT SELECT statement. INSERT INTO Images (name, person_id, filename, description, medium) SELECT name , table_id , image_name , description , medium FROM tbl_person_data; Doing it with a prepared statement, as you are, requires either execute with a numerically indexed array and ? as placeholders, or execute with an associative array and named placeholders matching the array keys
  16. If you are so error-prone, use your form which maintains those answer_group/answer tables to validate. If you create a group for 5, only show 5 answer rows. If editing and you accidentally have 6 answers, display the sixth in say, red, to flag the error.
  17. try foreach ($array as $k => $d) { if ($k > 0) { if (strtotime($d) > strtotime($array[$k-1])+6) { $new[] = "-------------------"; } } $new[] = $d; } $new = Array ( [0] => 2021-02-10 09:04:48 [1] => 2021-02-10 09:04:54 [2] => 2021-02-10 09:05:00 [3] => 2021-02-10 09:05:06 [4] => 2021-02-10 09:05:12 [5] => 2021-02-10 09:05:18 [6] => ------------------- [7] => 2021-02-10 09:06:18 [8] => 2021-02-10 09:06:24 ) [edit...] Alternative solution... $new = []; $ne
  18. In PHP, string indexes for arrays should be quoted. I am talking about the HTML in your form. You are naming the input field as "['title']" instead of "[title]"
  19. name="1['title']" ^ ^ remove those single quotes in all inout names
  20. I wouldn't bother. It's not as though your users will be creating these "answer" records. It's completely under your control and testing will show any "accidents". And what if it really is a 5-answer group but you accidentally enter "4" or "6" in the group table? It's equivalent to storing a derived total instead of getting the total from the data. Let the number of answers dictate the group size.
  21. print_r() doesn't normally put quotes around keys, just [..]. EG Array ( [fname] => joe [lname] => bloggs ) If you have them, your form must be adding them to the input field names. Show your form code.
  22. Are you sure it isn't referring to line 64 in a different file? It's not like the error reports to quote an empty line number.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.