Jump to content

Barand

Moderators
  • Posts

    24,599
  • Joined

  • Last visited

  • Days Won

    829

Everything posted by Barand

  1. That error means your query returned false (failed) instead of a valid result. My guess would be that the column names in my example are not the same as those in your table.
  2. You need to call session_start() before any out put is sent to the browser. (Top of the script is best place). In check_login you hava an echo before the session_start().
  3. If we just get the data straight from the table we get SELECT name , comment , date FROM date_example; +-------+--------------------------------------------------------+------------+ | name | comment | date | +-------+--------------------------------------------------------+------------+ | Peter | Lorem ipsum dolor sit amet | 2005-05-21 | | Paul | Nunc viverra imperdiet enim | 2005-06-22 | | Curly | Suspendisse dui purus, scelerisque at, vulputate vitae | 2006-11-01 | | Larry | Etiam eget dui. Aliquam erat volutpat. | 2006-11-02 | | Mo | Etiam at ligula et tellus ullamcorper ultrices. | 2019-09-28 | +-------+--------------------------------------------------------+------------+ However, formatting the date as I showed gives SELECT name , comment , DATE_FORMAT(date, '%d/%m/%Y') as date FROM date_example; +-------+--------------------------------------------------------+------------+ | name | comment | date | +-------+--------------------------------------------------------+------------+ | Peter | Lorem ipsum dolor sit amet | 21/05/2005 | | Paul | Nunc viverra imperdiet enim | 22/06/2005 | | Curly | Suspendisse dui purus, scelerisque at, vulputate vitae | 01/11/2006 | | Larry | Etiam eget dui. Aliquam erat volutpat. | 02/11/2006 | | Mo | Etiam at ligula et tellus ullamcorper ultrices. | 28/09/2019 | +-------+--------------------------------------------------------+------------+ So exactly what does "not working" mean? PS How are you currently storing your dates? It should be TYPE DATE (or DATETIME) with a format of YYYY-MM-DD
  4. True by default when no keys specified. $letters = ['a', 'b', 'c']; echo $letters[0]; //--> 'a' echo $letters[1]; //--> 'b' echo $letters[2]; //--> 'c' // but $months = [ 1 => 'Jan', 'Feb', 'Mar' ]; echo $months[0]; //-> Notice: Undefined offset: 0 echo $months[1]; //-> 'Jan' echo $months[2]; //-> 'Feb'
  5. Look at the data in the mail headers. For example, an email from a friend of mine in Kentucky (timezone EST) had this in the header Date: Sun, 28 Feb 2021 16:13:50 -0500 ^^^^^ ||||| GMT - 5 hrs
  6. Stop using "SELECT *" and specify the fields you need. Use mysql DATE_FORMAT() give the required format, or format it in php with date() function SELECT name , comment , DATE_FORMAT(date, '%d/%m/%Y') as date FROM tablename
  7. This appears to work script <script type='text/javascript'> $(function() { $( "#location" ).autocomplete({ source: 'autosearch.php', select: function(event, ui) { event.preventDefault() $("#location").val(ui.item.label) $("#location_phone").val(ui.item.value) } }); }); </script> autosearch.php if (isset($_GET['term'])) { $res = $conn->prepare("SELECT concat(user_firstname,' ',user_lastname) as label , user_phone as value FROM users WHERE concat(user_firstname,' ',user_lastname) LIKE ? "); $res->execute([ $_GET['term'].'%' ]); $data = $res->fetchAll(PDO::FETCH_OBJ); exit(json_encode($data)); }
  8. Try this. It doesn't appear to impact performance. Unmodified : 2987 rows in set (1.53 sec) Modified : 2987 rows in set (1.48 sec) I had to use GROUP BY to get a single row with 1234 1 1 otherwise, if both matched, it gave 1234 1 0 1234 0 1 Query SELECT id , SUM(match_email) as by_email , SUM(match_phone) as by_phone FROM ( SELECT `a1`.`id`, 1 as match_email, 0 as match_phone FROM ( ( `customers` `a1` JOIN `customers` `b1` ON ( ( (`a1`.`email` = `b1`.`email`) AND(`a1`.`id` <> `b1`.`id`) AND( `a1`.`email` <> '[email protected]' ) AND( `b1`.`email` <> '[email protected]' ) ) ) ) JOIN `quotes` `q1` ON ( ( (`q1`.`customer_id` = `b1`.`id`) AND(`q1`.`purchased` = 1) ) ) ) UNION SELECT `a`.`id`, 0 as match_email, 1 as match_phone FROM ( ( `customers` `a` JOIN `customers` `b` ON ( ( (`a`.`phone` = `b`.`phone`) AND(`a`.`id` <> `b`.`id`) ) ) ) JOIN `quotes` `q` ON ( ( (`q`.`customer_id` = `b`.`id`) AND(`q`.`purchased` = 1) ) ) ) ) all_matches GROUP BY `id`
  9. That dzone link advocates some really bad practices. Ignore.
  10. Every element in an array has a key and a value A value may itself be an array So your would probably look something like this $questionnaire = [ 'title' => 'questionnaire one', 'intro' => 'Synopsis goes here', 'sections' => [ '1' => [ 'intro' => '', 'questions' => [ '1' => 'question 1 text', '2' => 'question 2 text' ] ], '2' => [ 'intro' => 'Some text here', 'questions' => [ '3' => 'question 3 text', '4' => 'question 4 text' ] ] ] ]; which could come from data like this +---------------------+ | questionnaire | +---------------------+ | quaire_id |-----+ | title | | | intro | | +---------------------+ | +-----------------+ | | section | | +-----------------+ | | section_id |------+ +-------<| quaire_id | | | section_no | | | intro | | +-----------------+ | +-------------------+ | | question | | +-------------------+ | | q_id | +----------<| section_id | | q_number | | q_text | +-------------------+
  11. Cold, cloudy, wet and in covid lockdown. Apart from that everything's great.
  12. The bit I gave you a fix for in my first reply.
  13. Looks like you still have name='$productID' instead of name = 'productID'
  14. Not from what you've posted. I get no sense of structure or sequence so I don't know how it all hangs together.
  15. Then the form data isn't being submitted (to upload2)
  16. put this at the top of upload2.php so you can see what's being posted to it echo '<pre>' . print_r($_POST, 1) . '</pre>';
  17. If $productID contains '123' and $filename contains 'abc.txt' then upload2 will receive $_POST['123'] with a value of 'A' $_POST['abc.txt'] with a value of 'B' It looks like you need <input type='hidden' name='productID' value='$productID'> <input type='hidden' name='filename' value='$flename'>
  18. Yes, you do. You are using a database, not a spreadsheet. Don't repeat multiple like columns in a single row. You should put them in separate rows along with the id of the parent record as a foreign key. Each row in a database table table should contain data about a single entity (in this case, an image). Read up on "Data normalization" +----------------+ | tableA | +----------------+ | id (PK) |-----+ | etc. | | +----------------+ | +----------------+ | | list | | +----------------+ +---<| tableA_id (FK)| | image | +----------------+ You can't rely on the file extension to be an accurate indication of the file type (You could rename a text file to "mytext.png" but that wouldn't make it an image.) The mime type is in the $_FILES array.
  19. Don't lose any sleep over it
  20. Hmm! I would have expected your original code to throw a syntax error. Apparently it doesn't. Very odd..
  21. The settings are in you "php.ini" file. I have highlighted the settings you want for development. On a production site you would log errors instead of displaying them.
  22. Too many "="s. $stmt = $dbo->prepare = ("SELECT * FROM products WHERE ProductName = ?"); ^ REMOVE EDIT: Turn on your error reporting.
  23. Have you remembered the "[]" in the file input field name? <input type='file' name='filestoupload[]' multiple>
  24. Perhaps this is why
  25. Have you considered defining email and phone columns as UNIQUE then trapping dupe key errors on insert? That should be far better than searching for potential dupes before inserting. (You would have to cleanse your data of current duplicates first, however) Yes thanks. The ~3000 duplicates in my last post are from your data. Perhaps, for a single search, you could mysql> SELECT id -> FROM customers -> WHERE email = '[email protected]' -> UNION -> SELECT id -> FROM customers -> WHERE phone = '612-772-4311'; +-------+ | id | +-------+ | 11902 | +-------+ 1 row in set (0.00 sec)
×
×
  • 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.