Jump to content

requinix

Administrators
  • Posts

    15,286
  • Joined

  • Last visited

  • Days Won

    435

Community Answers

  1. requinix's post in How to execute a mySQL subquery in php? was marked as the answer   
    I hope it's noticeably different from that because what you posted will run but certainly will not work well.
    $sql = "SELECT s.Name, sc.CID, sc.Grade FROM Student s RIGHT JOIN XS_Course sc ON s.SID=sc.SID WHERE sc.CID LIKE 'IT%' AND sc.Date>= ("select date(max(sc2.Date)) from XS_Course sc2;")";Please familiarize yourself with how strings work in PHP. 
    Same problem as the other one. Fix the other and this one will go away.
  2. requinix's post in How do I get specific values from a json encoded string? was marked as the answer   
    array_keys
  3. requinix's post in Recover DB after HDD crash was marked as the answer   
    Did you copy all the files? Each table has 2-3 files, and InnoDB has other stuff. Did you do mysqlcheck with

    --all-databases --extended --verboseCopy literally everything from the old data/ directory to the new one.
  4. requinix's post in PHP and CSS- how to style comment site was marked as the answer   
    You have a much larger problem than just the styling of the comments: people can execute PHP code on your site, let alone put HTML (and Javascript) on your site.
     
    Do you want people to write HTML? Please say no because allowing that is painful. Replace

    with
    and
    fwrite($handle,"" . $name . ":
    " . $content . "

    ");with
    fwrite($handle,"" . htmlspecialchars($name) . ":
    " . htmlspecialchars($content) . "

    ");Now go into your comments.html and make sure there isn't anything bad in it. 
    With that taken care of, find and fix the problem with your starting
    tag. I expect the browser was able to recover gracefully from it, though, as you would have noticed otherwise. 
     
    Anyways,
     
    If you need help with the appearance of your site then we need to see the HTML (your PHP isn't complicated so that's okay) and the CSS. Preferably with a link to the site, but don't provide a link until you do the comment thing I said above.
  5. requinix's post in XML Date Conversion was marked as the answer   
    How to reformat it? Parse it with either strtotime() or DateTime, then format the result with date() or ->format() respectively.
  6. requinix's post in Parse Months In cyrillic letters to numbers was marked as the answer   
    Try

    $formatter = new IntlDateFormatter("bg_BG.UTF-8", null, null, null, null, "MMM yyyy"); $dt = $formatter->parse("Май 2017"); echo date("Y-m-d", $dt);It does require you knowing what date format the filename uses, though.
  7. requinix's post in Gameserver script, Strict standards Non-Static method error was marked as the answer   
    I partially take that back: looks like the author made a mistake. Code's still old though.
     
    Go into class.core.php and make the getObject method be static.
  8. requinix's post in spaces/lines after php close ?> was marked as the answer   
    Given that you're outputting an image, it would be best not to output anything else but the image data.
     
    Best practices are to leave the final ?> out. This is a good reason why.
  9. requinix's post in Cookie errors: with error reporting it fails, without - works was marked as the answer   
    Okay, so since we've already explained the thing about if and {}s and indentation then I guess your problem is not understanding the error message? Maybe you didn't know what the isset was doing in the first place?
     

    $_COOKIE['lastVisit']If "lastVisit" is not a key in the $_COOKIE array then PHP will give you a warning. Happens any time you try to use it - except in a couple situations, like an isset(). 
    So in this code

    if (date('d-m-Y', $_COOKIE['lastVisit']) != date('d-m-Y')) {if the "lastVisit" doesn't exist then PHP will give you a warning. You are getting the warning so that means it does not exist. You have to fix your code so that you don't try to use the lastVisit value in the cookie if it does not exist. Much like in the rest of the code. 
    Most likely the problem is that you do not, in fact, understand the thing about if and {}s and indentation, because if you did then I would hope that you would realize the bug in your code and could fix it. We're talking literally adding a { and a } each in one place, but for you to do it right you have to (ahem) learn the thing about if and {}s and indentation.
  10. 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?
  11. 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.
  12. 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.
  13. 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.
  14. 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; } }
  15. 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).
  16. 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);
  17. 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().
  18. 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.
  19. 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.
  20. 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;">
  21. 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.
  22. 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
  23. 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?
  24. 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"?
×
×
  • 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.