Jump to content

Barand

Moderators
  • Posts

    24,605
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. BTW,, the fopen() and fclose() are redundant if you are using file_get_contents()
  2. Or maybe opening your referral links in a new tab would help ... <a href="https://myWebsite/link.php?Referer=RefererCompany&SKU=XYZ" target="_blank">Sell Here</a> ... so that the page isn't replaced. As Gizmola stated, we have no idea of your user interface and processes so we can only stumble around in the dark
  3. Perhaps use AJAX to get the referred SKU so you you don't leave the page?
  4. Your problem is with $iduser It is the result of the first query yet you are attemping to insert it as a value in the second query. You need to fetch the id from the resultset to use its value.
  5. Try swapping $file1 and $file2 echo '<pre>' . print_r(array_diff($file1, $file2), 1) . '</pre>';
  6. In that case why is there a SELECT query again? All you need to do is UPDATE from the post data. You are posting data but trying to get the id from GET - put the id in a hidden form field and get it from the POST data
  7. Where has all the site's activity gone?. It is telling me there is none and there never has been any
  8. My code is the whole script to compare 2 text files and show the differences. Run it on its own but you will have to adjust for the names of your text files.
  9. At what point in the above process is the form supposed to be displayed to the user for editing? You have a SELECT query presumably to get the data to display for editing. You then launch immediatley into updating with the posted data
  10. Perhaps... FILE 1 FILE 2 --------------------------------- --------------------------------- Twas brillig and the slithy toves Twas brillig and the slithy toves did gyre and gimble in the wabe. did gyre and gimble in the wabe. All mimsy were the borogoves All mimsy were the borogoves and the mome raths outgrabe. and the mome raths outgrabe. additional line 1. additional line 2. then $file1 = file('file1.txt', FILE_IGNORE_NEW_LINES); $file2 = file('file2.txt', FILE_IGNORE_NEW_LINES); echo '<pre>' . print_r(array_diff($file2, $file1), 1) . '</pre>';
  11. I would recommend that, while developing, you should use E_ALL with no suppression of the other levels.
  12. If you have the settings that you want in the ini file, why override them with E_ALL in your webpage?
  13. If your query returns no results then the while() loop doesn't execute. $table is defined only when the loop does execute.
  14. I created an "images" table like yours. Here is basic working code sample. The folder containing the script has a subfolder "images". <?php include 'config.php'; $res = $db->query("SELECT file_name , game FROM images "); ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Test</title> <style type='text/css'> .wrapper { text-align: center; padding: 20px; border-bottom: 2px solid gray; } </style> </head> <body> <?php foreach ($res as $row) { echo "<div class='wrapper'> <img src='images/{$row['file_name']}' alt='Game image'> <br> {$row['game']} </div> "; } ?> </body> </html>
  15. Perhaps the path to the image is missing (we can't see your data). Does this work... <img class='w-100 mb-2 bg-dark' src=\"images/{$row['file_name']}\">
  16. Also, you have a button element inside a form. That will cause the form to be submitted and your page to reload when the button is clicked. Remove the <form> tags, or change the button element to a span element styled to look like a button, or suppress the default action when the button is clicked
  17. The biggest obstacle to that approach is that PHP does not have a CURRENT_DATE() function - it's a MySql function. If you had error reporting on, or used the reference manual, that would have given you a clue. date('Y-m-d') will use the current date by default so all the extra code above is redundant - which takes us back to the original solution you were given, yet ignored.
  18. Plan B Use this line instead of the two I gave earlier $combinations = array_values(array_filter( $combinations, function($v) { return count($v) == count(array_unique($v)); }));
  19. This is when reading the manual comes in useful php.net/array_values php.net/array_unique php.net/sort
  20. You could add these two lines foreach ($combinations as $k => &$a) sort($a); $combinations = array_values(array_unique($combinations, SORT_REGULAR));
  21. Alternative sans-regex solution... Input (test.txt) Large toolbox (metal) for sale (hammer is required) serious inquiries only. All employees are required to attend. Meeting scheduled for Tuesday (Formal attire required) otherwise call (or email) us. Code $data = file('test.txt', FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); foreach ($data as $line) { if ($p = parens_and_req($line)) { $line = str_replace($p, "<span style='color:red;'>$p</span>", $line ); } echo "<p>$line</p>"; } function parens_and_req($str) { $k = strlen($str); $p2 = 0; while (( $p1 = strpos($str, '(', $p2)) !== false ) { $p2 = strpos($str, ')', $p1); if ($p2 === false) { $p2 = $k-1; } $parens = substr($str, $p1, $p2-$p1+1); if (strpos($parens, 'required') !== false) { return $parens; } } return false; } Output
  22. There are errors in your HTML markup. Put the table inside the form, instead of the form inside the table. The cell containing your textarea has a <td> but no closing </td>
  23. Use DATE type columns for your dates, not varchar. Have your leaving dates either a valid date or NULL. SELECT eemp_id , fname , lname , AVG(timestampdiff(MONTH, joining_date, coalesce(leaving_date, curdate()))) as av_mths FROM employee_details ed JOIN employee e ON e.empid = ed.eemp_id GROUP BY eemp_id HAVING av_mths >= 36;
  24. My guess would be that you didn't find a matching record in candidate_paye in your second query. Don't run two queries, use a single query with a JOIN.
  25. Good. Your php.ini file is the correct place for them. It saves you having to put them in every script.
×
×
  • 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.