-
Posts
15,227 -
Joined
-
Last visited
-
Days Won
427
Community Answers
-
requinix's post in Css not loading despite linking to it correctly was marked as the answer
Take a look at these two lines:
<link href="https://fonts.googleapis.com/css?family=Handlee" rel="stylesheet"> <link rel="stylesheet" src="../css/stat.css" type="text/css" media="screen" />The first one works and the second one doesn't. There are three differences between them and one of them is the source of the problem. Can you find it? -
requinix's post in New Website Dashboard was marked as the answer
It's great that you want to be proactive about features, but ultimately it should be up to the client. You can certainly propose ideas to them like "Hey, would X be useful to you?" but don't go changing the specs because you want to do more.
If the dashboard currently meets requirements then move on to the rest of the project: having everything finished on time and on budget will be better than having some parts of it looking great but other parts not done yet. You can always add more dashboard stuff later.
-
requinix's post in checking query execution in foreach loops was marked as the answer
Then you need transactions. Start a transaction at the start, monitor each operation for success and failure, then commit if everything was successful or rollback if anything failed.
-
requinix's post in jquery select elements inside bootstrap inactive nav tab? was marked as the answer
Then I'd say you can forget about the nav thing. That only shows and hides content - it still exists on the page, so you can certainly manipulate it whenever and however you want.
-
requinix's post in Extracting specific data from xml was marked as the answer
Try not to rely on something being the first or last in a set: that could change at any time (probably won't) and your code would break.
What you really want is the final upgrade for the unit, right? The with the highest ?
$level = 0; $upgrade = null; foreach ($units->upgrade as $unitsUpgrade) { $l = (int)$unitsUpgrade->level; if ($l > $level) { $upgrade = $unitsUpgrade; $level = $l; } } -
requinix's post in if ftp_get does not find the file to download echo error message and exit script was marked as the answer
Make your code smart enough to know if the file exists: use ftp_nlist to get the contents of the parent directory, then check that the file requested is in there.
You should also change your production environment (the php.ini/whatever settings) to log errors (set error_log if not already set) instead of displaying them (turn off display_errors).
-
requinix's post in SimpleXML addChild won't accept $_SERVER['REQUEST_URI'] was marked as the answer
addChild has an annoying quirk where you have to encode ampersands. Just ampersands. It issues a warning, and if you're not seeing it then you don't have your environment properly set up for development.
As an alternative you can not specify the value in the method call and instead assign it manually.
$entry->addChild('title')->value = chop($_GET['city'] .' - '. $_GET['title']) .' for '. $_GET['price'] .' from @'. $dir_auth1); -
requinix's post in Exploding data and putting it through an IF loop... was marked as the answer
Not only is it possible, it's downright likely.
Adjust the delimiter to explode().
-
requinix's post in help with ftp_get I can connect to the server but not sure hot to get to the folder named "Outbox" was marked as the answer
-
requinix's post in Delete files with same prefix name but different extensions-php was marked as the answer
I don't believe unlink() works with patterns, so glob + loop + unlink.
-
requinix's post in Using php sessions with while loop to display specific content in another page. was marked as the answer
Don't use a session for this. Sessions are for storing data that lasts while a user visits your website and are not appropriate for passing temporary bits of data between a couple pages.
Just use normal variables for displaying the product information, like the $row you already have. Use a query string to pass the product ID to productdetails.php.
-
requinix's post in Using an array() from Within a Private Function Within a Class was marked as the answer
class Calendar { public $heights; private function dayLoop($cellNumber) { $heights = []; //array $block_count = 0; //counter while(mysqlrowdata) { // code for mysql operations $block_count++; //increment the count } $day_height = ($block_count * 16) + 18; //do some math specific to my application $this->heights[] = $day_height; //commit calc'd value to array //array_push($heights, $day_height); //this was a previosu attempt, i dont think i should use array_push here..?? } } You're mixing $heights and $this->heights.
You don't need the local $heights variable. Make $this->heights start as an empty array
public $heights = [];then append to it in the method
$this->heights[] = $block_count;Don't do the math there: the calendar should not have to care about how the calendar is displayed and should only focus on the data itself.
Those two changes are more or less what you already had. You were seeing an empty array because of that line you had commented out, and/or because the $heights in the method is not the same $heights you were dumping (I can't tell from what you posted).
After the calendar is set up you can get the heights, find the maximum, and do the math:
$calendar = // set up calendar $maxheight = max($calendar->heights) * 16 + 18; // mathIs that in pixels? Use it inline with each , which is where the cell height is managed.
<li id="li-2017-09-29" style="height:<?=$maxheight?>px;"> -
requinix's post in Unable to attach an external RDS instance to Elastic Beanstalk using CLI was marked as the answer
The UI is what they call the "console"... and that ambiguity is why I called it the UI. You know, the main website for managing stuff.
- Document root is a configuration thing. Or just say /var/www
- Auto-generated security group? Don't. Make a standalone security group for these instances and have each use it.
- Copy database is a configuration thing. Should be just a matter of a post-installation command to dump the RDS data into the local MySQL like
mysqldump --options... and -h -u -p for the rds instance | mysql -h -u -p for the local instance- Hostname and credentials are also a configuration thing
The CodeDeploy settings go into their own file, your application settings go into their own file(s) however they're supposed to work.
-
requinix's post in getting data from multiple tables with sum in a single result set was marked as the answer
Well now you're changing the requirements, but okay.
First we have to fix your query to be better and more suitable for a view. A view makes it much easier to use this query, and in other places.
SELECT r.invoice_id, r.customer, r.paid_amount, r.mode, r.ref_no, r.paid_date, r.comments, l.company, 'Income' AS IncomeOrExpense FROM receipt r INNER JOIN leads l ON r.customer=l.id UNION ALL SELECT p.invoice_id, p.vendor, p.paid_amount, p.mode, p.ref_no, p.paid_date, p.comments, v.name, 'Expense' FROM payments p INNER JOIN vendor v ON p.vendor=v.id UNION ALL SELECT e.eid, e.user, e.paid_amount, e.mode, e.ref_no, e.paid_date, e.comments, ???, 'Expense' FROM expense e INNER JOIN ??? Then put it into the view.
CREATE VIEW pick_a_name AS SELECT...Now make a new query to select from the view and do the grouping and sorting.
SELECT YEAR(v.paid_date) AS Yr, MONTHNAME(v.paid_date) AS Month, SUM(IF(v.IncomeOrExpense = 'Income', v.paid_amount, 0)) AS Income, SUM(IF(v.IncomeOrExpense = 'Expense', v.paid_amount, 0)) AS Expense FROM pick_a_name v GROUP BY Yr, Month ORDER BY Yr DESC, Month DESC -
requinix's post in SQL DB Sending old results was marked as the answer
Add a little bit to the code:
<?php $query = $conn->prepare("SELECT ID, username, fname, lname, email, tokens, NOW() FROM `users` WHERE ID = ?"); $query->bind_param("s",$_SESSION['ID']); $query->execute(); $query->bind_result($ID, $username, $firstname, $lastname, $email, $tokens, $now); $query->fetch(); $query->close(); ?> <p class="my-account-p-padded"> <br> Username: <?php echo $username; ?><br> First Name: <?php echo $firstname; ?><br> Last Name: <?php echo $lastname; ?><br> Account Tokens: <?php echo $tokens; ?> <a href="javascript:void(0)" onclick="showlightbox();" id="addmoretokensbtn">Add More</a><br> PHP Time: <?php echo date("Y-m-d H:i:s"); ?><br> DB Time: <?php echo $now; ?><br> <span id="explain" style="display: none;">(Scroll Up to see screen)</span> </p>Do you see the two times changing? -
requinix's post in Apache/2.4.27 (Win64) PHP/7.1.8 PDO was marked as the answer
Seems fine. Any startup errors? What is "blank"?
-
requinix's post in Insering Multple files was marked as the answer
> yes I am trying to use that
Well you can't. There is nothing in $_POST that can help you with file uploads. Everything is in $_FILES.
-
requinix's post in running another client side program with in my HTML was marked as the answer
To the question you asked, kinda. To the question I think you're trying to ask, no.
It is possible for a web server to run things like "programs". They run on the server itself. It is not possible for the server to cause a program to run on the client. That would be really, really bad.
There are workarounds for very specific environments, like Windows domains when people are using Internet Explorer/Edge, not to mention completely unrelated mechanisms like a network-local server remotely running commands on the client machine itself, but that's something else.
-
requinix's post in A Function Parameter That Takes In A Constant, Can It Always Take In A Variable Unless It Needs A Handle ? was marked as the answer
The only difference that matters here between a variable and a constant is that a variable can be modified and a constant cannot. If something does not need to modify a value then it doesn't matter which one you use.
-
requinix's post in What Is An Element In Php ? was marked as the answer
That's right.
I was responding to the "3 could mean anything" comment. It does not mean anything. The manual specifically says the function tells you "the number of elements in array_or_countable".
I mean exactly what the words themselves mean. In code you could say
count(array_keys($array)) == count(array_values($array))A bit of a recursive definition, admittedly. -
requinix's post in Relinquishing memory in WHILE loop was marked as the answer
In general you want a buffered query: it's much faster, frees up your connection for another query, and releases database resources. An unbuffered query is the opposite of that, but uses far less memory for large resultsets.
The second point in there is where the closed cursor comes in. Basically, a resultset needs to reach the end* so that both sides of the connection know the data is read and the server can do other stuff. IIRC closeCursor()-type functionality guarantees that the resultset was fully read and then immediately releases some client resources (which would have been freed normally eventually anyways).
fetchAll() reads everything (either from memory or from the server) and gives you an array, so one way or another the resultset is fully used up. fetch() gives you just one row so you're still subject to un/buffered query rules.
And yes, a distinction between buffered and unbuffered resultsets is common in client APIs for databases. (The server doesn't know or care either way.)
* Past the end, actually. The client doesn't know it's at the end until it fails to read another row. The row count is actually maintained by the client as a counter from it reading rows - it's not sent by the server with the results.
-
requinix's post in htaccess hotlink filter with remote "readfile" was marked as the answer
Whoever wrote those didn't quite understand what they were doing. You only need one for a domain.
RewriteEngine on RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mydomainhere/ [NC] RewriteCond %{HTTP_REFERER} !^https?://(www\.)?otherdomain/ [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteRule \.(gif|jpg|png)$ - [F]The third line is to allow direct access in the browser, ie. copying and pasting the URL into the address bar directly. -
requinix's post in Why Did Session Object Destruction Failed ? was marked as the answer
It happens when the session data could not be deleted. You're probably using regular session files, so that means the file couldn't be deleted: it may have been already (somehow), or maybe permissions were messed up, or perhaps the file was locked because PHP was still using it (I don't know about that one).
Adding session_regenerate_id() will only cover up the problem by switching the session ID to something else just before you delete it. Extra work for no gain.
-
requinix's post in Dealing with Triggers... was marked as the answer
Yeah, that's not even close to valid syntax. I linked the docs in the other thread.
If your original query was
update a_players p join wp_terms t set p.wpID = t.term_id where t.slug = p.wpSlugand NEW.term_id and NEW.slug are both things, then
update a_players set wpID = NEW.term_id where wpSlug = NEW.slugSince wp_terms.term_id is an auto_increment-ed primary key you'll have to run this AFTER the insert so you can get its value.
If you describe it that simply, yes. What I'm saying is that if you describe it precisely, as we've both done a few times now, it no longer is what you want. The end result is correct but the process to get there is not. -
requinix's post in file system performance; how many files in one dir was marked as the answer
Depends on the filesystem. ext4 (most common?) doesn't have a limit per directory. However directories themselves take space to store a list of their contents, and unless the system sorts directory entries (?) looking for a file requires scanning the directory list for it.
It might be antiquated now but if you know the filename from another source then I'd partition. I tend to generate hex filenames and take the first two bytes' worth as two subdirectories.
/01/23/0123456789abcdef.extAssuming an even distribution, by the time you've filled each second-level directory with 256 files you've stored 16M total. More than enough.