Jump to content

Barand

Moderators
  • Posts

    24,572
  • Joined

  • Last visited

  • Days Won

    824

Everything posted by Barand

  1. Using your posted code but with $bnm = null , I get BI-IN0020 Which is pretty similar to what you want. (Except I can't see how you are getting IK from the first 2 chars of "INSECT KILLER")
  2. For the benefit of the non-clairvoyant among us, what are you wanting it to look like when there are NULL values?
  3. Welcome
  4. Where does $filePath get its value from?
  5. That was intended as a hint. Make them both the same and you should then be able to create your foreign key.
  6. Is the column UNSIGNED in both tables?
  7. Syntax for host and port is host:port try $conn = mysqli_connect("$servername:$db_port", $username, $password,$db_database);
  8. Having agreed with the solution that @requinix suggested, and which I showed you how to implement, why are you still persisting with your "ON DUPLICATE ... CONCAT" ? Or do you want to end up with... +---------+-----------------------------+ | user_id | flavor | +---------+-----------------------------+ | 1 | chocolate, chocolate | | 1 | vanilla | +---------+-----------------------------+
  9. Wht the connection class to call a connection class? Why not just... $db = new PDO( .... ); Job done.
  10. You seem to have missed the plot. CREATE TABLE `mytable` ( `user_id` int(11) NOT NULL, `flavor` varchar(45) NOT NULL, PRIMARY KEY (`user_id`,`flavor`) ); Add 3 records, 1 vanilla and 2 chocolate insert ignore into mytable (user_id, flavor) values (1, 'vanilla'), (1, 'chocolate'), (1, 'chocolate'); View the table mysql> select * from mytable; +---------+-----------+ | user_id | flavor | +---------+-----------+ | 1 | chocolate | | 1 | vanilla | +---------+-----------+ 2 rows in set (0.00 sec)
  11. Do you mean like this UPDATE category a JOIN category b ON a.parent = b.id JOIN product p ON p.category = a.id SET a.parent = b.parent , p.category = b.parent WHERE a.parent = ?;
  12. In that case you have broken referential integrity rules by removing the products' category Options: Change the category of those products to a new one before deleting category 16. Don't allow the category deletion in the first place Delete the products too, as that category of item is no longer sold. Set the category of those products to NULL to show they are now orphans Those lst 3 options can be set in the foreign key cascade setting.
  13. What do want to update if there is a duplicate key?
  14. Since you want to filter an array, I suggest array_filter() $times = [ '2021-06-02T19:40:00Z', '2021-06-03T02:10:00Z', '2021-06-03T01:10:00Z', '2021-06-02T23:05:00Z', '2021-06-02T23:05:00Z', '2021-06-02T23:07:00Z', '2021-06-02T23:20:00Z', '2021-06-02T18:20:00Z', '2021-06-03T00:10:00Z', '2021-06-03T00:40:00Z' ]; $d = new DateTime('23:59:59', new DateTimeZone('Z')); $newtimes = array_filter($times, function($v) use ($d) { return new DateTime($v) <= $d; });
  15. When you pass a variable to a function it passes a copy of that variable. You are changing those copies. You need to return the cleaned value and assign that returned value to the variable. $firstname = clean_name($firstname)
  16. I don't see why that should be necessary. If your product were in in category 16 before the update it remains in catgory 16. It's just that 16 has moved a different parent, but the product remains unchanged..
  17. try UPDATE category a JOIN category b ON a.parent_id = b.category_id SET a.parent_id = b.parent_id WHERE a.parent_id = 9; DELETE FROM category WHERE category_id = 9; (Moving to MySQL forum)
  18. foreach() and is_array() might be useful
  19. To check if the query failed or not. If query() fails it returns false.
  20. Try removing the "?>" from the end of dbconfig.php
  21. For the benefit of those others looking for a solution to a similar problem, why not post your solution.
  22. The way to get to know it is to use it.
  23. First step is to check if there is an easier way. For example, the UK National Lottery provides a facility to download results in a CSV file.
×
×
  • 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.