-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Now you know why you get an error when you try using $current_user['role_status']
-
According to that connection code, you should be using $link->prepare()
-
It would appear that your $database variable contains a string and not a PDO object. Your use of GLOBAL is incorrect.
-
https://www.php.net/manual/en/domdocument.loadhtml.php
-
-
-
It's telling you that it isn't the correct place to define variables as "private".
-
https://enb.iisd.org/_inc/simple_html_dom/manual/manual.htm
-
PHP Mailer don't function, SMTP Error: Could not authenticate
Barand replied to DaryllB's topic in PHP Coding Help
You have one comma too many. -
Is your query definitely finding a matching record?
-
I don't accept links from strangers, nor will many others here.
-
Something along these lines (I don't know your data) ... SELECT DISTINCT username FROM messages WHERE message_type = 'email'
-
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());
-
Easier with PDO $stmt = $pdo->prepare($sql); $stmt->execute($SearchValues);
-
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?
-
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 ] );
-
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.
-
You think two lines of code is an over-complicated solution?
-
If you need more detail, there is a manual for that explanation of foreach
-
Sorry about the spelling mistake. "foreaach" should (of course) be "foreach".
-
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>
-
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.
-
Beacause in this case, the "needle" is at position 0 evaluates to "localhost:8888" ^ pos 0
-
Looking up strpos() in the manual would have explained exactly what your problem is, and the first example gives you the cure.