Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Now you know why you get an error when you try using $current_user['role_status']
  2. According to that connection code, you should be using $link->prepare()
  3. It would appear that your $database variable contains a string and not a PDO object. Your use of GLOBAL is incorrect.
  4. https://www.php.net/manual/en/domdocument.loadhtml.php
  5. Believe it or not, it finds all images and anchors that have a "title" attribute.
  6. Example from php manual:
  7. It's telling you that it isn't the correct place to define variables as "private".
  8. https://enb.iisd.org/_inc/simple_html_dom/manual/manual.htm
  9. And in future ask questions in one thread only - this question duplicates your last post in your other recent thread.
  10. Is your query definitely finding a matching record?
  11. I don't accept links from strangers, nor will many others here.
  12. Something along these lines (I don't know your data) ... SELECT DISTINCT username FROM messages WHERE message_type = 'email'
  13. A couple of ways to handle this situation where you want name from from first record only and message from all records. 1 ) Use a variable so you know you are on the first record $first = 1; foreach ($row2 as $r) { if ($first) { // output name header here $first = 0; } // output message here } 2 ) fetch first record then use a do..while loop $r = $stmt->fetch(); // output name header here do { // output message here while ($r = $stmt->fetch());
  14. Easier with PDO $stmt = $pdo->prepare($sql); $stmt->execute($SearchValues);
  15. Since you found that this... $query->bind_param($CharTypes, ...$SearchValues); works, why are you using without the "..." to expand the array into a comma separated list?
  16. I would use a single query which checks if the code is used in one table or the other, or both. Test data TABLE: tsc TABLE: candidates +----+-----------------+ +---------+-------+--------+ | id | transactioncode | | regcode | name | last | +----+-----------------+ +---------+-------+--------+ | 10 | 1 | | 2 | Alma | Geddon | | 11 | 2 | | 4 | Scott | Chegg | | 12 | 3 | | 5 | Sarah | Tonin | | 13 | 4 | +---------+-------+--------+ +----+-----------------+ The query and results mysql> SELECT a.transactioncode as tsc -> , coalesce(b.regcode, 'NO') as candidates -> FROM tsc a -> LEFT JOIN -> candidates b ON a.transactioncode = b.regcode -> UNION -> SELECT coalesce(a.transactioncode, 'NO') as tsc -> , b.regcode as candidates -> FROM candidates b -> LEFT JOIN -> tsc a ON a.transactioncode = b.regcode; +------+------------+ | TSC | CANDIDATES | +------+------------+ | 1 | NO | | 2 | 2 | | 3 | NO | | 4 | 4 | | NO | 5 | +------+------------+ Because you are interested in one code at a time, just add WHERE clauses to each half of the UNION. I.E.... SELECT a.transactioncode as TSC , coalesce(b.regcode, 'NO') as CANDIDATES FROM tsc a LEFT JOIN candidates b ON a.transactioncode = b.regcode WHERE transactioncode = ? UNION SELECT coalesce(a.transactioncode, 'NO') as TSC , b.regcode as CANDIDATES FROM candidates b LEFT JOIN tsc a ON a.transactioncode = b.regcode; WHERE regcode = ? Note that the the inputted code is used twice, so your execute command would be $stmt->execute( [ $code, $code ] );
  17. Change session_start(); $conn = mysqli_connect("localhost", "root", "root", "reglog"); to session_start(); mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $conn = mysqli_connect("localhost", "root", "root", "reglog"); Ensure error reporting is ON. You should then see error messages if your SQL is incorrect.
  18. You think two lines of code is an over-complicated solution?
  19. If you need more detail, there is a manual for that explanation of foreach
  20. Sorry about the spelling mistake. "foreaach" should (of course) be "foreach".
  21. Easiest way is to treat $query as an array and just iterate through the results <table> <?php foreaach ($query as $row) { echo "<tr><td>" . join("</td><td>", $row) . "</td></tr>"; } ?> </table>
  22. This is exactly the same code and problm that you posted on Saturday morning and which was answered by @ginerjm telling precisely wht was wrong nd giving you the correct code... Stop repeating questions and ignoring replies.
  23. Beacause in this case, the "needle" is at position 0 evaluates to "localhost:8888" ^ pos 0
  24. Looking up strpos() in the manual would have explained exactly what your problem is, and the first example gives you the cure.
×
×
  • 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.