-
Posts
24,605 -
Joined
-
Last visited
-
Days Won
831
Everything posted by Barand
-
BTW,, the fopen() and fclose() are redundant if you are using file_get_contents()
-
convert GET to POST (and AVOID $_SESSIONS !!! )
Barand replied to ChenXiu's topic in PHP Coding Help
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 -
convert GET to POST (and AVOID $_SESSIONS !!! )
Barand replied to ChenXiu's topic in PHP Coding Help
Perhaps use AJAX to get the referred SKU so you you don't leave the page? -
Object of class mysqli_result could not be converted to string
Barand replied to yami's topic in PHP Coding Help
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. -
php Compare two text files and output NON matching records
Barand replied to increase's topic in PHP Coding Help
Try swapping $file1 and $file2 echo '<pre>' . print_r(array_diff($file1, $file2), 1) . '</pre>'; -
Undefined variable error but that variable has been declared
Barand replied to webdeveloper123's topic in PHP Coding Help
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 -
Where has all the site's activity gone?. It is telling me there is none and there never has been any
-
php Compare two text files and output NON matching records
Barand replied to increase's topic in PHP Coding Help
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. -
Undefined variable error but that variable has been declared
Barand replied to webdeveloper123's topic in PHP Coding Help
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 -
php Compare two text files and output NON matching records
Barand replied to increase's topic in PHP Coding Help
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>'; -
How can I make php display errors and hide warnings?
Barand replied to SLSCoder's topic in PHP Installation and Configuration
I would recommend that, while developing, you should use E_ALL with no suppression of the other levels. -
How can I make php display errors and hide warnings?
Barand replied to SLSCoder's topic in PHP Installation and Configuration
If you have the settings that you want in the ini file, why override them with E_ALL in your webpage? -
Undefined variable error but that variable has been declared
Barand replied to webdeveloper123's topic in PHP Coding Help
If your query returns no results then the while() loop doesn't execute. $table is defined only when the loop does execute. -
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>
-
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']}\">
-
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
-
how to insert auto current date inside this tag please help?
Barand replied to Ronel's topic in PHP Coding Help
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. -
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)); }));
-
This is when reading the manual comes in useful php.net/array_values php.net/array_unique php.net/sort
-
You could add these two lines foreach ($combinations as $k => &$a) sort($a); $combinations = array_values(array_unique($combinations, SORT_REGULAR));
-
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
-
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>
-
Searching and Calculating Minimum Years of experience
Barand replied to michelle1404's topic in MySQL Help
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; -
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.