Jump to content
#FlattenTheCurve ×

Leaderboard


Popular Content

Showing content with the highest reputation since 03/08/2020 in all areas

  1. 2 points
    Why are you even attempting to store that duration. You can get it any time you need it with a query. Rule of DB design - don't store derived data. If you really insist on storing it, why do need two queries? UPDATE attendance_records SET duration = timediff(...) WHERE ... - a single update would do the job
  2. 2 points
    They aren't the same width because you don't have any sort of CSS in there that says anything about a width. It's not like the browser can read your mind about how you want it to appear... Have you tried giving the buttons a width?
  3. 1 point
    I thought I would present a modern solution based on Barand's that uses css grid. Same basic idea however, you need to replace the test output with your output loop. index.php <?php $output = ''; for ($i=1; $i<=28; $i++) { $output .= "<div class='entry'>Entry $i</div>\n"; } ?> <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="https://unpkg.com/purecss@1.0.1/build/base-min.css"> <link rel="stylesheet" type="text/css" href="styles.css"> <title>Grid Layout</title> </head> <body> <h1>CSS Grid Table</h1> <div class="grid"> <?= $output ?> </div> </body> </html> styles.css body { margin: 1em; } .grid { display: grid; padding 1em; grid-template-columns: repeat(5, 1fr); grid-column-gap: 1em; grid-row-gap: 1em; /* Start at 100px height, stretch if content in a cell exceeds the 100px; */ grid-auto-rows: minmax(100px, auto); } .entry { background: #eee; padding: 1em; } Here's the rendered html and css moved to a codepen if you want to experiment.
  4. 1 point
    Yes that is what I want This is the way i would like to do it how would i put in the select query into the code?
  5. 1 point
    It's much easier with CSS and divs than it is with a table. <?php $output = ''; for ($i=1; $i<=28; $i++) { $output .= "<div class='db-entry'>Entry $i</div>\n"; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-language" content="en"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> </head> <style type="text/css"> .db-entry { width: 18%; height: 50px; padding: 20px 2px; border: 1px solid gray; margin: 0 2px 2px 0; float: left; } </style> <body> <?=$output?> </body> </html>
  6. 1 point
    I think that was ginerjm is trying to say is that this may not be the easiest thing in the world for you, but even though there are some people here who don't know stuff like jQuery very well, I know we can help you out in one way or another. I'm sure he wasn't trying to gate-keep the world of software development and say that you had to give up. Right, ginerjm? What I mean is that we don't know anything about your code short of what you can post here and tell us about. As people who have never seen it before, you automatically know more about it (as a whole) than we do. It's not exactly like we can just jump right into the middle of all this and tell you exactly what needs to happen. It's good to know it works somewhere, but if you need help getting it to work someplace it does not then it'd be more helpful if we knew more about that, right? The PHP code is simple enough so any problem is likely to be with the Javascript side. Any errors in the browser console? And the general troubleshooting questions apply: what is it supposed to be doing and what is it actually doing?
  7. 1 point
    Well - how ARE you doing the delete? A PHP script, no? So use a form with a submit button and not a <button> and call the script that does the delete.
  8. 1 point
    Okay, that's what I thought. You cannot read registry settings from the client browsing the website. You can only access the registry from the server PHP is itself running on. And obviously only if it's a Windows machine.
  9. 1 point
  10. 1 point
    Can you show us some of your fpdf code? Just a sample of 20-30 lines from one of your routines that generates the pdf file? Just want to make sure of something since I'm still trying to help you.
  11. 1 point
    Assuming that you have written the code correctly and not made any typos, what is the problem with it? You aren't having success - so are there any messages coming back? For you to say it doesn't work sure can't help us to see what's wrong, assuming that it is written correctly.
  12. 1 point
    Your randomNr array contains 10 elements so foreach($randomNr as $number) will give 10 columns. You need to pick a random 6 numbers out of the 10. Separate the php code from the html. Use CSS for styling the output. Example <?php $randomNr = range(0,9); $bingokaart = display($randomNr); function display ($arr) { $result = ""; for ($row = 1; $row < 7; ++$row) { $rand6 = array_rand($arr, 6); $result .= '<tr>'; foreach ($rand6 as $n) { $result .= "<td>$row$arr[$n]</td>"; } $result .= "</tr>\n"; } return $result; } ?> <!DOCTYPE html> <html> <head> <title>Sample</title> <style type="text/css"> table { border-collapse: collapse; } td { padding: 2px; } </style> </head> <body> <table border='1'> <?= $bingokaart ?> </table> </body> </html>
  13. 1 point
  14. 1 point
    Read a SQL manual for the functions available to be used in a query. Research! Feeling magnanimous - here: https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_month
  15. 1 point
    From the code you presented - yes it is that simple.
  16. 1 point
    How about something altogether simpler and more user-friendly: <a href='www.11.com'>ABC</a> <a href='www.22.com'>ZXC</a> <a href='www.33.com'>CCC</a> No need for "error messages" at all. Only give the Users options for things that they're allowed to do. "What's the best way to prevent someone from shooting themselves in the foot? Don't give them a gun in the first place!" Regards, Phill W.
  17. 1 point
    Moving this to the PHP forum, even though it'll be SQL stuff for a bit. By website hits are you talking about something other than this download stuff? Then yes, you would have two separate tables for the two separate events. For the counter, don't use an actual counter in the database. Track individual downloads instead. You can get a counter by doing a count of matching records in the table - don't worry, it's fast. Also means you can do more than just total downloads, like downloads per month. Because as a rule of thumb, Data Is Good. Get as much as you can. I don't mean tracking users or anything sketchy like that. I mean, if you have information (like a download happening) then you should store everything you can about it. Even if it doesn't seem useful now. Because if you decide later that, say, you'd like to get an overview of where in the world people are downloading your stuff, you can't go back in time and fill in data for event that have already happened. So for downloads, create a table with: 1. An AUTO_INCREMENTing ID, because these sorts of things are handy to have around 2. The name of the downloaded file 3. The DATETIME of the download 4. The visitor's IP address, which can also help you deal with abuse problems (that hopefully won't happen) For best performance, create a UNIQUE index on the filename. You can also create a regular INDEX on the filename and the download time (both fields), which will allow you to run fast queries when looking at both fields in the same query. Tracking website hits will look very similar to that. If you want a counter for a specific file, and just that file, you do a query to SELECT COUNT(1) from the downloads table WHERE the name of the file is whatever file you want to check. But more often you'll want counters for all files, in which case you can do one query to get all of them at once by SELECTing the name of the file with its COUNT(1) and having the query GROUP BY the file name; pull that information out into a PHP array and you can reference it when creating your HTML markup.
  18. 1 point
    andSelf was deprecated back in 1.8. That was a number of years ago. Your book may be slightly out of date. As for this thread, leave it. It's fine. Maybe someone else will find it on Google and your follow-up will answer their problem.
  19. 1 point
    You need to use parameter binding rather than variable interpolation.
  20. 1 point
    Yes - forums (including this one) DO help people. But not with all of their tasks. Forums like this one help you address your code. Help you correct it or debug it or help you amend your solution. We are not here to just plain write it for you. We are here for people who are having difficulty but that means showing us the difficulty.
  21. 1 point
  22. 1 point
    There's two parts to this, so solve one then the other rather than doing both at the same time. First problem is saving your data. Create a function that you can call with your data and it will save it to your database. Use parameters for the function rather than accessing $_POST directly. For example: function bookmark_add($userId, $itemId){ //run INSERT statement } While getting that working, just use a normal form that will submit the data and refresh the page, eg: <?php if ($_SERVER['REQUEST_METHOD']==='POST'){ //Call your function with the data bookmark_add($_POST['userId'], $_POST['itemId']); } ?> <form method="page.php" action=""> <p>ItemID: <input type="text" name="itemId"></p> <p>UserID: <input type="text" name="userId"></p> <p><button type="submit">Save</button></p> </form> Once you have your function working exactly how you want it, then move on to your "without reloading the page problem." To do this without reloading the page, you need to use javascript to submit the values in the background using AJAX/XHR. Grab something like jQuery and use it's .post method to make this super simple. Now you create a javascript function which will gather your form data and submit it to a PHP page which then calls your PHP function to save it. For example: function submitBookmark(){ var postData = { userId: $('#userId').val() , //.... }; $.post('page.php', postData) .then(/* Success handler */) .catch(/* Failure handler */) ; } Finally setup that function to be executed whenever the user clicks your + image.
  23. 1 point
    Looks like you have a bit of reading to do regarding the use of FPDF. You can't just call the cell() function and output a PHP table into it. Don't mix the screen output code with FPDF code. Put the FPDF into a separate script. Display the web page and put a link to the pdf page EG <a href='attendance_pdf.php?oracleid=533349&sdate=2020-03-01&edate=2020-03-05'>Print version</a> Below is a sample FPDF script (read, learn and digest) to produce a report which looks like this ... attendance_pdf.php... <?php require('../fpdf/fpdf.php'); // ADD YOUR OWN PDO CONNECTION CODE // class attendPDF extends FPDF { protected $today; protected $headbase; protected $db; protected $sid; protected $name; protected $sdate; protected $edate; //constructor public function __construct($db, $staffid, $sdate, $edate) { parent::__construct(); $this->today = date('jS M Y'); $this->db = $db; $this->sid = $staffid; $this->sdate = new DateTime($sdate); $this->edate = new DateTime($edate); $res = $this->db->prepare("SELECT name FROM staff WHERE oracleid = ? "); $res->execute( [ $staffid ] ); $this->name = $res->fetchColumn(); } //Page header public function Header() { //Helvetica bold 12 $this->SetFont('Helvetica', '', 14); $this->Cell(0, 15, "Attendance Report", 1, 1, 'C'); //Title $sd = $this->sdate->format('l jS F Y'); $ed = $this->edate->format('l jS F Y'); $this->SetFont('Helvetica', '', 12); $this->Cell(60,15,$this->sid . ' - ' . $this->name,1,0,'L'); $this->Cell(120, 15, "$sd - $ed" , 1, 0, 'C') ; $this->Ln(); $this->headbase = $this->GetY(); } //Page footer public function Footer() { $this->setY(-22); $this->setX(15); $this->SetFont('Helvetica', '', 10); $this->Cell(0,5,'( '.$this->today.' )', 'T'); } public function attendanceReport() { $widths = [60, 60, 60]; $aligns = [ 'L', 'L', 'C' ]; $heads = ['Clocked In Time', 'Clocked Out Time', 'Duration']; $this->SetY(50); $this->SetFont('Helvetica', 'B', 12); $this->Cell(0, 10, 'Attendances', 0, 1); $this->SetFontSize(10); foreach ($heads as $k => $h) { $this->Cell($widths[$k], 10, $h, 1, 0, $aligns[$k], 1); } $this->Ln(); $this->setFont('', ''); $res = $this->db->prepare("SELECT date_format(clockingindate, '%a %d/%m/%Y %l:%i %p') as clkin , date_format(clockingoutdate, '%a %d/%m/%Y %l:%i %p') as clkout , timediff(clockingoutdate, clockingindate) as duration FROM attendance_record WHERE oracleid = ? AND DATE(clockingindate) BETWEEN ? AND ? ORDER BY clockingindate "); $res->execute([ $this->sid, $this->sdate->format('Y-m-d'), $this->edate->format('Y-m-d') ] ); while ( $r = $res->fetch(PDO::FETCH_NUM) ) { foreach ($r as $k => $v) { $this->Cell($widths[$k], 6, $v, 0, 0, $aligns[$k]); } $this->Ln(); } } public function absenceReport() { $this->SetY(50); $this->SetFont('Helvetica', 'B', 12); $this->Cell(0, 10, 'Absences', 0, 1); $this->SetFontSize(10); $this->Cell(0, 10, 'Dates Absent', 1, 0, 'L', 1); $this->setFont('', ''); $this->Ln(); // set up a temporary date table - each working day in the reporting period $this->db->exec("CREATE TEMPORARY TABLE date(date date)"); $incr = DateInterval::createFromDateString('next weekday'); $sd = clone $this->sdate; $ed = clone $this->edate; $sd->modify('+1 days'); // adjust for Islamic working week $ed->modify('+2 days'); // adjust for Islamic working week $range = new DatePeriod($sd, $incr, $ed); foreach ($range as $d) { $dt = $d->sub(new DateInterval('P1D'))->format('Y-m-d'); // adjust for Islamic working week $dates[] = "('$dt')"; } $this->db->exec("INSERT INTO date VALUES " . join(',', $dates)); // get days absent $res = $this->db->prepare("SELECT DATE_FORMAT(date, '%W %d/%m/%Y' ) as date FROM staff s CROSS JOIN date d LEFT JOIN attendance_record a ON s.oracleid = a.oracleid AND d.date = DATE(a.clockingindate) WHERE s.oracleid = ? AND a.oracleid IS NULL "); $res->execute( [ $this->sid ] ); foreach ($res as $r) { $this->Cell(0, 6, $r['date'], 0, 1); } } }# end class if (!isset($_GET['oracleid']) || !isset($_GET['sdate']) || !isset($_GET['edate'])) { exit; } // // GENERATE REPORT // $pdf = new attendPDF($db, $_GET['oracleid'], $_GET['sdate'], $_GET['edate']); $pdf->AliasNbPages(); $pdf->setAutoPageBreak(1,25); $pdf->setMargins(15,15,15); $pdf->SetDrawColor(102); $pdf->SetFillColor(220); $pdf->AddPage(); $pdf->attendanceReport(); $pdf->AddPage(); $pdf->absenceReport(); $pdf->output(); ?>
  24. 1 point
    That is no excuse to design db tables like spreadsheets. You can always create views for the technically challenged users. EDIT: For example there is a "fixture" table in the db in the tutorial on my site mysql> select * from fixture; +---------+----------+----------+-----------+-----------+--------+ | idmatch | hometeam | awayteam | homegoals | awaygoals | weekno | +---------+----------+----------+-----------+-----------+--------+ | 1 | 4 | 2 | 1 | 0 | 1 | | 2 | 2 | 4 | 2 | 2 | 2 | | 3 | 3 | 2 | 4 | 4 | 3 | | 4 | 1 | 3 | 1 | 1 | 1 | | 5 | 2 | 3 | 1 | 2 | 4 | | 6 | 3 | 1 | 1 | 3 | 2 | | 7 | 4 | 3 | 2 | 0 | 5 | | 8 | 2 | 1 | 0 | 3 | 5 | | 9 | 1 | 4 | 2 | 4 | 3 | | 10 | 4 | 1 | 4 | 4 | 4 | | 11 | 1 | 2 | 4 | 1 | 6 | | 12 | 3 | 4 | 1 | 4 | 6 | +---------+----------+----------+-----------+-----------+--------+ But to make it a bit friendlier, setting up a view gives mysql> select * from fixture_view; +---------+--------+----------+-----------+-----------+----------+ | idmatch | weekno | hometeam | homegoals | awaygoals | awayteam | +---------+--------+----------+-----------+-----------+----------+ | 4 | 1 | Laker | 1 | 1 | Jardine | | 1 | 1 | Cowdrey | 1 | 0 | Grace | | 6 | 2 | Jardine | 1 | 3 | Laker | | 2 | 2 | Grace | 2 | 2 | Cowdrey | | 9 | 3 | Laker | 2 | 4 | Cowdrey | | 3 | 3 | Jardine | 4 | 4 | Grace | | 10 | 4 | Cowdrey | 4 | 4 | Laker | | 5 | 4 | Grace | 1 | 2 | Jardine | | 7 | 5 | Cowdrey | 2 | 0 | Jardine | | 8 | 5 | Grace | 0 | 3 | Laker | | 12 | 6 | Jardine | 1 | 4 | Cowdrey | | 11 | 6 | Laker | 4 | 1 | Grace | +---------+--------+----------+-----------+-----------+----------+
  25. 1 point
    Perhaps $cartidOK = $_SESSION['cartid'] ?? 0; $cartitemOK = $_POST['cartitem'] ?? 0 $quantityOK = isset($_POST['quantity']) && is_numeric($_POST['quantity']); $lockedcard = $_SESSION['lockedcard'] ?? 0; $lockedpaypal = $_SESSION['lockedpaypal'] ?? 0; if ( $cartidOK && $cartitemOK && $quantityOK && !$lockedcard && !$lockedpaypal) { // do it }
  26. 1 point
    You would need to test for the oracleid in the staff table IE WHERE s.oracleid = ? AND a.oracleid IS NULL since it is doing a LEFT JOIN the attendance_records table (alias a) to find missing dates.
  27. 1 point
    Check the value of userid. Is it not a varchar? WHERE a.oracleid = '$userid' If you write code this way, you are using variable interpolation which opens your code up to SQL Injection. That is why I showed you the parameter passing method, which uses prepared statements and bound variables. You would not need the single quotes if you used the parameter, as it will determine the datatype from the type of the variable being passed.
  28. 1 point
    So it is now clear that ABSPATH is not being substituted the way you expect. How is it defined and where? I don't normally use constants but somewhere you must have a "define('ABSPATH',<whatever>);" but is not executed before that include.
  29. 1 point
    Hi Tony, Is this a symfony app? Are you getting incorrect ownership due to running command line as an OS user? My first suggestion is to stop doing that, as it's guaranteed to mess up your ownership in this type of scenario. I'm not seeing why you need ssh whatsoever. A bash or php script would do the job. Look at the various exec and related commands. I would have to question why you don't simply cron your bash script and run it every 5 minutes. Much simpler and less invasive. Write the script, put it in /usr/local/sbin or /usr/local/bin. sudo su - {appropriate user to run script}. crontab -e. Add an entry to run at the periodicity you desire. I don't know that you want to blindly delete the app/cache dir contents every 5 minutes if you don't have to. Bash is a relatively full programming language where you can do standard if-then-else logic. With that said, you can also write a command line php script and invoke it in a cron exactly as you would a bash script. Or you can call the php command line scripts from bash. None of these ideas require ssh, and I don't really see what you need to run this remotely for if you have it running under cron automatically for you. If you are convinced you need remote execution, you could exec a script from a php page, but of course that will run as the OS user, and if you need sudo to correct some problems, you certainly wouldn't expect the apache user to have either a shell or su or sudo. A sysadmin/Devops person would turn to Anisible or Puppet for on demand controlled execution and administration of a cluster of servers, vpc's or what have you, but Ansible could work for you as well. Of course it might not be possible for you to install these tools in a shared hosting situation.
  30. 1 point
    You need to set a few attributes when you create your PDO connection. $conn = new PDO("mysql:host=$servername;dbname=timeclock", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); Then you will be notified of any sql problems. Did you read my edit to earlier post about subtracting 1 day from the dates (to get Sun - Thu working week)?
  31. 1 point
    I thought you might be able manage that bit. Here's a fuller version <?php $month = 'March'; $start_date = new DateTime("first monday of $month"); $incr = DateInterval::createFromDateString('next weekday'); $period = new DatePeriod($start_date, $incr, new DateTime()); // create temporary date table $conn->exec("CREATE TEMPORARY TABLE date (date date not null primary key)"); // populate it foreach ($period as $d) { $dates[] = "('{$d->format('Y-m-d')}')" ; } $conn->exec("INSERT INTO date VALUES " . join(',', $dates)); // now get the days absent $res = $conn->query("SELECT s.oracleid , s.name , date_format(date, '%W %d/%m/%Y') as absent FROM attendance_staff s CROSS JOIN date d LEFT JOIN attendance_record a ON s.oracleid = a.oracleid AND d.date = DATE(a.clockingindate) WHERE a.oracleid IS NULL ORDER BY s.oracleid, d.date "); $tdata = ''; foreach ($res as $r) { $tdata .= "<tr><td>" . join('</td><td>', $r) . "</td></tr>\n"; } ?> <html> <head> <title>Example</title> <style type="text/css"> table { border-collapse: collapse; width: 600px; } th, td { padding: 8px; } th { background-color: black; color: white; } </style> </head> <body> <table border='1'> <tr><th>ID</th><th>Name</th><th>Absent</th></tr> <?=$tdata?> </table> </body> </html>
  32. 1 point
    I don't know whether you care or not about People with names like "Martin St. Louis" but obviously your code will not work correctly in that case. Of course you also can't tell if it's someone with a name like 'Sue Ann Smith'. Your code is biased towards Sue Ann Smith, but gets Martin St. Louis wrong. Without a separation of first name and lastname, there is no way to really do it reliably. With that said, you can boil this down to a one liner that doesn't use arrays. I'm fairly sure that your code would throw a runtime error if there was a single name in the string, but didn't test it. This could/should be coded around, which I do with a ternary. There is a lot of extra trimming I do, which could be avoided if the original string was simply trimmed prior to using this one liner, but I provided something that works with a variety of extraneous spaces, per the examples. Here's a one liner as a function for the purposes of illustration, that you might consider: $tests = array('Bob Jones', 'Sue Ann Smith', 'Martin St. Louis', 'Prince', ' Adam West', ' Fred R. Murray ', ' Skipper Van Dammage'); foreach ($tests as $test) { echo makeName($test) . PHP_EOL; } function makeName($name) { return false !== strpos(trim($name), ' ') ? preg_replace('/\s\s+/', ' ', rtrim(substr(trim($name), 0, strrpos(trim($name), ' ')))) . ' ' . substr(strrchr(rtrim($name), ' '), 1, 1) : trim($name); } Returns: Bob J Sue Ann S Martin St. L Prince Adam W Fred R. M Skipper Van D
  33. 1 point
    DATA +----------+----------+-------+ | entry_id | field_id | value | +----------+----------+-------+ | 1 | 5 | Curly | | 1 | 13 | bbb | | 1 | 16 | ccc | | 1 | 18 | ddd | | 2 | 5 | Larry | | 2 | 13 | eee | | 2 | 16 | fff | | 2 | 18 | ggg | | 2 | 43 | hhh | | 3 | 5 | Mo | | 3 | 13 | kkk | | 3 | 16 | mmm | | 3 | 18 | nnn | | 3 | 43 | ooo | | 4 | 5 | Tom | | 4 | 13 | ppp | | 4 | 16 | qqq | | 4 | 18 | rrr | | 4 | 43 | sss | +----------+----------+-------+ CODE $res = $conn->query("SELECT entry_id , field_id , value FROM wp_wpforms_entry_fields WHERE field_id IN (5, 13, 16, 18) ORDER BY entry_id "); $headings = [ 5 => 'Name' , 16 => 'Belt' , 13 => 'School', 18 => 'Events' ]; $temp_array = array_fill_keys(array_keys($headings), ''); // array for each attendee to be filled in from query results // process query results and place in array with attendee as the key $data = []; foreach ($res as $r) { if ( !isset($data[$r['entry_id']])) { $data[$r['entry_id']] = $temp_array ; } $data[$r['entry_id']][$r['field_id']] = $r['value'] ; // store answer in its array position } $theads = "<tr><th>" . join('</th><th>', $headings) . "</th></tr>\n" ; $tdata = ''; foreach ($data as $d) { $tdata .= "<tr><td>" . join('</td><td>', $d) . "</td></tr>\n"; } OUTPUT
  34. 1 point
    I'm confused. Are you installing a 3rd party application or trying to access a script from PHP that you wrote? Is this a CGI script?
  35. 1 point
    Check the permissions for /tmp. It should be (777): drwxrwxrwt. 22 root root 12288 Mar 21 14:01 /tmp Any user can write to /tmp. The 't' sticky bit handles the security issue. What ever user writes to /tmp is the only user that can access that directory/file (700) unless that user specifically chmod's something else. Also check session_save_path and its permissions.
  36. 1 point
    When you're using prepared statements you pass the query string to prepare(). You don't use query() at all.
  37. 1 point
    I believe I would convert the mm entrees to meters first then get the square meters. $dimension1 = 850/1000; $dimension2 = 1447/1000; $square_metres = $dimension1 * $dimension2; The results would be 1.22995 square meters. You can use number_format() if you need to limit the number of decimal places.
  38. 1 point
    Your RegEx for email addresses is already flawed. Use built-in methods unless, as @gizmola stated, you have a use case that is not supported). As to your second question, if the error message you are referring to is one that is thrown from the DB, then you should absolutely have logic to show the message you define. Never expose DB errors to the user. You should always capture those and show a "friendly" message to the user that does not expose any details they could use to infiltrate the system.
  39. 1 point
    the associative index for the COUNT(*) expression is actually something like $row['COUNT(*)']. to simplify this, add an alias name for the COUNT(*) expression in the query and use that alias name for the associative index. next, both of the query examples you have shown will/probably match at most one row. why you are using a loop to fetch the data. just fetch the single row without the loop.
  40. 1 point
    Why don't you do some good old experimentation and see where it works? Or you could look it up in a manual.
  41. 1 point
    Remember what I said about using a form? Use a form.
  42. 1 point
    By far the best php editor! Should probably clarify that the company is JetBrains. Here's a link to the PhpStorm version. Started out as a Java IDE (IntelliJ Idea), and it's essentially the same base editor across the line, but I'd still recommend that you buy the Php specific version. There's a 30 day trial you can use to check it out. Has a huge number of plugins and configuration options available, so you can configure your code style, apply rules from various codesniffers and standards. As for a free editor, I'd go with Eclipse PDT.
  43. 1 point
    By far the fastest way is to use the SQL statement LOAD DATA INFILE Specify FIELDS TERMINATED BY '\t'
  44. 1 point
    You should only be using one timezone in all your code and storage. UTC works well but pick whatever you want and use it. By using a single timezone and datetime types then most of this problem goes away. Regardless of what the users local timezone is, you store the date and time in your chosen timezone. Then whenever you want to compare to it you also compare the current time in your chosen timezone to that stored date and time. If you want users to view dates and times in their timezone then convert them from your chosen timezone to their timezone just prior to display. If your using generated times then things are pretty easy in general. If your taking user-submitted dates and times, then things can potentially get a little more complex. If you want users to deal with things according to their local time you'll need to convert their input from their timezone to yours before doing and processing. This is just something you need to decide as one of your business rules. You also need to decide if whatever date you pick is inclusive or exclusive. If I were to subscribe on 2020-04-17 @ 5:20, for one year then does my subscription run 2020-04-17 @ 5:20 -> 2021-04-17 @ 5:20? 2020-04-17 @ 0:00 -> 2021-04-17 0:00? 2020-04-17 @ 0:00 -> 2021-04-17 @ 23:59:59? Up to you to decide. If it were me, I'd probably go for for the last option as I think it's the most intuitive and what people would expect. People are not going to remember the exact minute they signed up, and on the scale of a year I wouldn't nit-pick a few hours.
  45. 1 point
    The basic process is, if you want literal backslashes in a regex then you need to double it to make PCRE happy, then double it again to make PHP happy.
  46. 1 point
    Either you did not follow the instructions correctly and you extracted the files to the wrong place, or the instructions are wrong and you need to contact whoever wrote them to fix them. Beyond that, I told you what to do.
  47. 1 point
    First, don't embed your PHP code like that. Separate your HTML from the PHP code. Second, don't use * in your select. Extract only those variables you plan to actually use. To do what you want, you need to create a form that submits your data when you click one of the buttons. See this article about using forms and passing data to PHP.
  48. 1 point
    I agree with Requinix. The better approach (if you really need to do this) is what cruise ships have been doing for years. When passengers come back on board they line up and go thru a metal detector (of course!) and a baggage check and they scan their id card that was created when they arrived for their trip. This card is linked to a photo taken by the registration staff and when the card is scanned a picture shows up so that the crew knows for sure that the person now boarding is the person who is registered to that card - just like what you want to know. The difference is they rely on a staff member doing the immediate supervision of this interaction, not a computer check in a back office. (I hope I made sense here)
  49. 1 point
    If someone doesn't want to be seen they'll just hide from the camera. Or worse, they'll take their own picture of the person they want to log in as and use that. Know that this is not real security. But as said, yes: you can use Javascript to get a still from the camera, then upload that like any other file.
  50. 1 point
    My 0.02 worth... Why are you "denormalizing" your data by creating several objects all with the same id and color code. Would it not be more sensible (and a lot easier) to create a merged data set like this... <PRODUCTINFORMATION> <PRODUCTS> <PRODUCT> <PRODUCT_NUMBER>53-03</PRODUCT_NUMBER> <PRODUCT_PRINT_ID>42</PRODUCT_PRINT_ID> <PRODUCT_NAME>ProductFirst</PRODUCT_NAME> <COLOR_CODE>03</COLOR_CODE> <PRINTING_POSITION> <ID>TOP BOX</ID> </PRINTING_POSITION> <PRINTING_TECHNIQUES> <PRINTING_TECHNIQUE> <ID>DL</ID> </PRINTING_TECHNIQUE> <PRINTING_TECHNIQUE> <ID>L2</ID> </PRINTING_TECHNIQUE> <PRINTING_TECHNIQUE> <ID>P4</ID> </PRINTING_TECHNIQUE> </PRINTING_TECHNIQUES> </PRODUCT> </PRODUCTS> </PRODUCTINFORMATION> Below is my solution to your original quest using SimpleXML. Hava a go at it on your own as requinix suggested first then peek only if you really get stuck
This leaderboard is set to New York/GMT-04:00
  • Newsletter

    Want to keep up to date with all our latest news and information?
    Sign Up
×
×
  • 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.