Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Define "it's not working". Are you getting a PHP error, or a MySQL error message? Why are you ordering by stat twice? As an aside, your case statement looks weird in that you give numeric vlue to all statuses to sort on but as a default you have the string value "Cancelled". Have you considered making the stat column type ENUM? Or, perhaps ORDER BY FIELD(stat, 'Checked in', 'Booked', 'Deposit Confirmation', 'Email/phone', 'Checked Out', 'Cancelled')
  2. Here's one way. When you send a payment confirmation write a record (forename, surname, email) to "confirmation" table CREATE TABLE `confirmation` ( `confirm_id` int(11) NOT NULL AUTO_INCREMENT, `forename` varchar(45) DEFAULT NULL, `surname` varchar(45) DEFAULT NULL, `email` varchar(45) DEFAULT NULL, `time_confirmed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `tips_sent` datetime DEFAULT NULL, PRIMARY KEY (`confirm_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Set up a cron job to run every 5 minutes. This would SELECT confirm_id, forename, surname, email FROM confirmation WHERE tips_sent IS NULL AND NOW() - INTERVAL 10 MINUTE > time_confirmed; foreach record returned Send welcome tips email UPDATE confirmation SET tips_sent = NOW() WHERE confirm_id = ?
  3. Use square brackets for arrays, parentheses for for functions IE $person_id = $_SESSION['person_id'];
  4. Then your query failed and returned "false" instead of a valid result. Check mysqli error message.
  5. Perhaps <?php $res = $pdo->prepare("SELECT Sold FROM Products WHERE idProducts = ?"); $res->execute([ $_GET["id"] ]); $sqlSold = $res->fetchColumn(); function productOptions($current) { $products = [ 'True' => 1, 'False' => 0 ]; $opts .= ''; foreach ($products as $txt => $val) { $sel = $val==$current ? 'selected' : ''; $opts .= "<option value='$val' $sel>$txt</option>"; } return $opts; } ?> <html> <body> <select name="Sold"> <option selected="selected">Choose one</option> <?= productOptions($sqlSold)?> </select> </body> </html>
  6. I prefer to keep WordPress at least a barge-pole's length away. There is is a "Job Offerings" section these forums. You should post your requirements there, along with contact details so prospective developers can reply direct to you.
  7. I mentioned next year beacause the VBSA site lists events for 2022 Your posted form is only capable of entering events for the current year. It also doesn't contain any dates information (ie start, finish, closing date). If it had, the tourn_year column would be redundant as the year component of the start date would dictate the tournament year. This raises the question of "How did the above fixtures get into the system?"
  8. Or you could use HTML "required" attribute E.G. <!DOCTYPE html> <html> <head> <meta http-equiv="content-language" content="en"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> </head> <body> <form> Username*:<br> <input type="text" name="username" required autofocus><br> Email*:<br> <input type="email" name="email" required><br> <br> <input type="submit" value="Submit"> </form> </body> </html> You still need to validate in your PHP code as there is no guarantee that the input came came from your form.
  9. I'm surprised it's even displaying the id. You are setting $location = $row['location'] before you have retrieved any rows from the query. Inside the while loop you don't do anything, just putting a string inside some quotes.
  10. Because your form shows the fixed current year (2021) and the sql inserts the currrent year. How will you enter fixtures planned for 2022 (without waiting until next January)?
  11. Out of curiosity, how are you planning to insert events for next years schedule? * * * * * That's one, but I was referring to things like this (line 396) align="left"><?php $newDate = date("Y", strtotime($row_tourn2['tourn_year'])); * * * * * It is an alternative code library to mysqli. Much easier and more streamlined. * * * * * Prepared statements remove the user-provided values from the query. Instead placeholders are placed in the query and the values passed as parameters. Here's a PDO example of the code I posted earlier. (The tournament name is passed as a parameter) $stmt = $pdo->prepare("INSERT INTO tournament (tournament_name, tourn_year) VALUES ( ? , CURDATE() )"); $stmt->execute( [ $_POST['tourn_name'] ] ); or you can have named placeholders $stmt = $pdo->prepare("INSERT INTO tournament (tournament_name, tourn_year) VALUES ( :name , CURDATE() )"); $stmt->execute( [ 'name' => $_POST['tourn_name'] ] );
  12. It appears you have a hidden input field called tourn_year. Your php code is also trying to reformat the tourn_year field as though it were still a datatime type field. You also have an update query which requires change. Do yourself a favour and drop all the "GetSQLValueString()" stuff and use prepared query statements. While you're at it, seitch to PDO - much better.
  13. "site_visible" clearly contains "Yes" and not null, so don't know why it objects. "tourn_year" is empty because there is no input field on the form for it (and there shouldn't be if you always insert the current year)
  14. Or, conversely, a none-required closing bracket.
  15. This is the cause of your syntax error Look at the rror message closely
  16. Engage brain before pasting.
  17. Your tourn_year is now just a YEAR. The is no need to use any datetime functions to reformat or extract the year (in fact they will probably return NULL as it is no longer a date or datetime type) mysql> SELECT YEAR(tourn_year) as tyear FROM tournament; +-------+ | tyear | +-------+ | NULL | +-------+ 1 row in set, 1 warning (0.01 sec) mysql> SELECT date_format(tourn_year, '%Y') as tyear FROM tournament; +-------+ | tyear | +-------+ | NULL | +-------+ 1 row in set, 1 warning (0.00 sec)
  18. What RDBMS are you using? (If it's MySQL, boolean is stored as tinyint) Try $products = [ 'True' => 1, 'False' => 0 ]; then foreach($products as $txt => $val){ echo "<option value='$val'>$txt</option>"; }
  19. Have you checked what $_POST['site_visible'] actually contains when you get that error? echo '<pre>' . print_r($_POST, 1) . '</pre>';
  20. use ... WHERE tourn_year = YEAR(CURDATE()) ...
  21. Why is that line in your PHP code? It was a suggestion for the column definition in your table.
  22. You don't execute any queries and you don't have anything in your query string that references the 'sold' column. Nor do have a form or any form submission. So what are you expecting it to do?
  23. try `tourn_year` year(4) NOT NULL DEFAULT '0000', then when inserting records, always write CURDATE() to the tourn_year column. INSERT INTO tournament (tournament_name, tourn_year) VALUES ( ?, CURDATE() ); E.G. mysql> INSERT INTO tournament (tournament_name, tourn_year) VALUES ('Wimbledon', CURDATE()); Query OK, 1 row affected (0.05 sec) mysql> select * from tournament; +---------------+-----------------+------------+ | tournament_id | tournament_name | tourn_year | +---------------+-----------------+------------+ | 1 | Wimbledon | 2021 | +---------------+-----------------+------------+ 1 row in set (0.01 sec)
  24. You don't insert if it is an automatically populated timestamp. https://dev.mysql.com/doc/refman/5.7/en/year.html
×
×
  • 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.