Jump to content

Barand

Moderators
  • Posts

    24,609
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. Your $_POST values do not match what is posted. Try a very simple piece of code from "Debugging 101" echo '<pre>' . print_r($_POST, 1) . '</pre>'; so you can see what is being posted
  2. Where to start? If those fields (page_url, link_anchor_text etc) all exist in the form then after the form is posted all those POSTed values will be set. In particular, $_POST['page_url'] will be set so no others will be checked. If $_POST['page_url'] is empty then your SESSION variable will be empty. It needs to contain a valid column name, hence your sql error. You need to be setting the SESSION value to column name, not the content of the form field.
  3. Which of those 34 lines is line 97?
  4. By referencing the file system path to the file or by defining an included files folder in your php.ini file.
  5. Yeah, must be tough. I was only in my 50s when I started learning PHP.
  6. Post the code that's giving the problem. We are not clairvoyant.
  7. You have a couple of options 1 ) Re-format the date in the SQL query when you retrieve the records. EG SELECT DATE_FORMAT(invoice_date_created, '%d.%m.%Y') as invoice_date_created 2 ) Re-format after retrieval in the array $transaction['invoice_date_created'] = date('d.m.Y', strtotime($transaction['invoice_date_created']));
  8. Not quite. var_dump($delta) gives float(0), therefore the first branch needs to be either if ($delta === 0.0) { or if ($delta == 0) {
  9. $templatePrimaryColor = '555555'; echo '<pre>',print_r(hexToHsl($templatePrimaryColor)).'</pre>'; -> Warning: Division by zero in C:\inetpub\wwwroot\test\winuser\noname3.php on line 14
  10. Yes, if all 3 components are equal then $delta is zero, giving a division by zero error.
  11. Your method has a fatal problem with greys (ie when R = G = B)
  12. Restrict your db query with a where clause so you only retrieve the records you want SELECT ... WHERE datecol BETWEEN input_date AND CURDATE() - INTERVAL 1 DAY
  13. Change your query to retrieve the extra item and restructure the $data array to store it. $data = []; $res = $conn->prepare("SELECT name , email -- extra item , month(month) as mno , paid FROM fee WHERE month >= ? ORDER BY name, month "); $res->execute([$start]); foreach ($res as $row) { if (!isset($data[$row['name']])) { $data[$row['name']] = [ 'email' => $row['email'], 'pays' => $empty_array ]; } $data[$row['name']]['pays'][$row['mno']] = $row['paid']; }
  14. It's neither a PHP thing nor a HTML5 thing - it's a plain, old HTML <select> thing. By default, if none of the options have their selected attribute set, the first option is shown as selected.
  15. So the user doesn't have to guess which radio button is for "Male" and which is for "Female" of course.
  16. No. \ is the escape character so needs to be \\ in a dir path. The final \ also needs to be \\ as it is currently escaping the quote at the end of the string. Easier is to use / in paths (even on windows)
  17. When you use <label for="xxx"> then the xxx should be the id of the object being labelled. This is useful with radio buttons or checkboxes and enables the user to click either the object or the label to check or uncheck. In your examples, <label for="yes"> is wrong since "yes" is not an id of anything.
  18. When you get a keyboard that adds indenting and line breaks I'll read your code.
  19. I prefer option 4. EG mysqli_report(MYSQLI_REPORT_ALL|MYSQLI_REPORT_STRICT); $conn = mysqli_connect('localhost', 'someuser', 'wrong_password', 'test');
  20. You actually have choice of mysqli or PDO to replace your mysql.* functions. Don't be fooled into thinking the easier route must mysqli because it's spelt almost the same. PDO is the simpler of the two interfaces.
  21. DATA TABLE: mongoose +----+---------+ | id | testcol | +----+---------+ | 1 | 1 | | 2 | 2 | | 3 | 3 | | 4 | 2,3 | | 5 | 1,4 | | 6 | 2,5 | | 7 | 1,3 | | 8 | 2,4 | +----+---------+ Find records in mongoose where testcol contains 1 or 3 ... mysql> SELECT DISTINCT id, testcol -> FROM mongoose -> JOIN ( -> SELECT 1 as n -> UNION SELECT 3 -> ) nums ON FIND_IN_SET(n, testcol) -> ; +----+---------+ | id | testcol | +----+---------+ | 1 | 1 | | 3 | 3 | | 4 | 2,3 | | 5 | 1,4 | | 7 | 1,3 | +----+---------+ edit: The subquery effectively gives you a temporary table "nums" ... TABLE: nums +---+ | n | +---+ | 1 | | 3 | +---+
  22. $hours_per_day = 6; $total_hours = 20; $days = floor($total_hours / $hours_per_day); $hours_remaining = $total_hours - $days * $hours_per_day; echo "$days days and $hours_remaining hours" ; //--> 3 days and 2 hours
  23. @Jokeh There's a good chance that the question is no longer relevant after nearly 2 1/2 years
  24. Ensure users have to log in before they can vote so you know their user_id. When they vote, store the poll_id and user_id. Put a unique constraint on (poll_id, user_id) so that combination can not be added twice.
×
×
  • 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.