Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Community Answers

  1. kicken's post in How do you hide multiple DIVs when hovering over one? was marked as the answer   
    Yes, really.
  2. kicken's post in Why do display:inline for radio and checkbox label only when already each label is set to inline-block? was marked as the answer   
    As you noted,
    Adding display: inline prevents the width: 25% from having an effect on those elements.
  3. kicken's post in how to update a users collumn based on the time returned by a countdown. was marked as the answer   
    You shouldn't be trying to save a "time remaining" value at all.  That's a value you'd want to calculate on the fly when you need it based on the current time.
    Either save the sub_date and the amount of time they are allowed, or save an expiration date for the subscription and calculate the difference between now and that expiration date to determine the time remaining.
  4. kicken's post in how do I set curl POST method with PHP? was marked as the answer   
    Probably you should talk to the company hosting the API as it seems your request is going through fine so if there's a problem it's likely with the data you are sending not being what they expect.  They are the only ones that can really tell you for sure if there is a problem with the data.
    If I had to take a guess, it would be that you seem to be trying to post multiple records when they probably only expect one.  If you decide you're query string, you'll see you are posting data like this:
    0[id]=6653&0[participacion]=6936&0[beneficio]=cine&0[fecha]=2018-04-16+14:41:59&0[promo]=33&1[id]=6654&1[participacion]=3318&1[beneficio]=payp That seems unusual to me.  What would seem more likely is that you'd send one at a time with data such as this:
  5. kicken's post in SUM not working in Codeigniter was marked as the answer   
    Because you're asking for the number of rows, not the actual data.
    You want to fetch the row data and use that.  Some searching suggests that you'd do that using this code:
    return $query->row()->total_paid_amount Also, if you're trying to get a sum of all payments, you probably don't want to be using GROUP BY, and should remove p_id from your select list.
  6. kicken's post in Making Composer provide untagged git file was marked as the answer   
    You can tell composer to pull a specific commit by adding #hash after version.
    "api-platform/core": "3.0.x-dev#14c7cba" Normally just doing 3.0.x-dev would pull the latest version, but I think because both the main branch and 3.0 branch use this alias it causes an issue and for some reason composer prefers the main branch.
  7. kicken's post in Avoid multi directory structure for userbase was marked as the answer   
    It sounds like what you're describing / debating is a how to create a multi-tenant application, is that right?  Essentially you have an application that is dynamically configured and has separate data for each user instance (ie, several different wordpress blogs sharing the same code base).  I'm not sure I see the need for such complexity based on what is mentioned.
    That just sounds like basic user management / access to me.  You have your users table and a files table and associate the files with their users.  How you physically store the files on disk isn't really that relevant. Just ensure you code your editor so it can only load files the user has access to.
    Is there some public aspect to this where you need to isolate the user's files based on just the URL and not the user being logged in?  Last time I did something like this, it was based on the host name, but a URL directory would work as well.  Using the host name could have allowed the end-users to apply their own domain name to application instead of having to use mine (though that was never actually done).
    Based on the info provided so far, I'd probably just be doing essentially what I think you're already considering, just without the creation of separate folders for users bit.  I'd just store all the files for all users in one directory structure somewhere with random names.  The database would contain the original file name/mime type and user association information.  I'd use either mod_rewrite or FallbackResource in apache to handle public access to the files and normal login procedure for the editing/uploading bits.
  8. kicken's post in Why didn't position:sticky work? was marked as the answer   
    Seems like it's working fine for me.  However, you should not be using tables for layout.
  9. kicken's post in Did PHPFreaks get hacked? was marked as the answer   
    There was an incident a few years back.  You can read about it here.
  10. kicken's post in What is wrong in my code - wrong strokeStyle applied? was marked as the answer   
    You need to use beginPath() before you start to draw something.  Add a call to beginPath after you save the context.
  11. kicken's post in Best way to get an array slice starting from 'current' was marked as the answer   
    Just looking for a name element and then taking the next N elements is not really a good solution.  Unless you've previously sorted the array into a specific order, you can't guarantee the next N elements are actually the ones you want.
    If your structure is name0 matches with date0 then the thing to do would be build a new array that maps the name entries to the date entries and then you will have a simple array of date entries that you can slice off what you want.
    Even better if you can would be to rename your form elements so that PHP will essentially do that mapping for you.  Give your form elements names like name[0] and date[0][A], then you could just match the indexes between the name and date arrays.
  12. kicken's post in How can I pass class object to onclick function ? was marked as the answer   
    Don't use setAttribute to attach your onclick handler.  Use addEventListener.  Combine that with a closure that calls your select function and you can just pass the current object as a parameter the same as you would anything else.  Looking at your select function, I don't think it's necessary though.
    this.cbox.addEventListener('click', () => { this.setSelect(this.cbox.checked); });  
  13. kicken's post in How to enchance the table by displaying an alternate background color of “pink” and “white” for each table cell? was marked as the answer   
    Your code is incorrect.  You're not echoing your table cells, you storing them in a variable that is never used.  Your opening <td> tag is missing it's >.
    You cannot do an expression inside a string.  Either do it outside the string and save the result to a variable then embed the variable, or use concatenation.
    Lastly, you can do alternating colors with simple CSS and just create your table normally.
    td { background-color: white; } td:nth-child(2n){ background-color: pink; }  
  14. kicken's post in simple PDO insert sql insert form was marked as the answer   
    The parameter names in the query and the keys in your array need to match.  You've defined your parameters for the name as first_name and last_name, but in your array you used fname and lname.  Also post_code vs postcode, birthdate vs birthday.
  15. kicken's post in store jpg in mssql was marked as the answer   
    You need to use bindParam().  Set the type as PDO::PARAM_LOB so you can bind a file resource and stream the data (rather than as a big string), and use the $driverOptions parameter to set the data type to binary.
    $dbStatement = $db->prepare('INSERT INTO uploads (file_application_id, file_type, file_name, file_data) VALUES (?, ?, ?, ?);'); $dbStatement->bindValue(1, $appid['appid']); $dbStatement->bindValue(2, $attachment['type']); $dbStatement->bindValue(3, $fname); $fp = fopen('c:\\uploads\\'.$attachment['name'], 'r'); $dbStatement->bindParam(4, $fp, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); $dbStatement->execute();  
  16. kicken's post in Reverse proxy pass websocket request with PHP in apache was marked as the answer   
    As an alternative to making your own proxy server (or finding one) you might be able to simply configure Nginx to authenticate the request for you by making a sub-request to your PHP script.  I don't use Nginx so not sure if that would work but it sounds promising.
  17. kicken's post in Displaying only limited amount of pages in php pagination? was marked as the answer   
    You are currently looping from 1 to $number_of_pages when displaying your page numbers.
    What you want to do is loop from $page - 2 to $page + 2, taking care not to go below 0 or above $number_of_pages in the process.  Get your range of pages to loop over with some simple math and the help of the min/max functions then loop over that range. 
    $start = max(1, $page - 2); $end = min($number_of_pages, $page + 2); for ($p=$start; $p<=$end; $p++){ //... }  
  18. kicken's post in I'm getting a Forbidden error on my local server was marked as the answer   
    From PHP's include_path configuration.
    The error message you show doesn't match the code you posted.  The error shows '../php' but the code shows '../../php'.
    You need to get your path fixed, whatever you have is incorrect.  When it comes to requiring files, it's usually best to use __DIR__ and build a path from there.  For example, if your code file is /var/www/foxclone/public_html/index.php and you want to include the file /var/www/foxclone/php/PDO_Connection_Select.php, you'd do this:
    require __DIR__.'/../php/PDO_Connection_Select.php'  
  19. kicken's post in I'm getting a Forbidden error on my local server was marked as the answer   
    From PHP's include_path configuration.
    The error message you show doesn't match the code you posted.  The error shows '../php' but the code shows '../../php'.
    You need to get your path fixed, whatever you have is incorrect.  When it comes to requiring files, it's usually best to use __DIR__ and build a path from there.  For example, if your code file is /var/www/foxclone/public_html/index.php and you want to include the file /var/www/foxclone/php/PDO_Connection_Select.php, you'd do this:
    require __DIR__.'/../php/PDO_Connection_Select.php'  
  20. kicken's post in jquery-UI and NPM question was marked as the answer   
    The npm package doesn't provide a compiled single-file to use.  If you want to use it, you'd probably need to use something like webpack to compile everything into a single file for use on your site.
    Alternatively, there is a jquery-ui-dist package that contains the compiled output and you can just include it like you normally would.
  21. kicken's post in How to perform an action after some minutes was marked as the answer   
    Create a script that you can run every minute and it will check if there are any expired requests.  If there are it will do the "move on to the  next rider" stuff.
    Once that is working, create a cron job/scheduled task to execute that script every minute.
  22. kicken's post in Javascript Draw SVG with Filters to Canvas? was marked as the answer   
    Wrapping the call to drawImage in a setTimeout fixed the problem in my tests.  I'd guess you need the delay to give the browser a chance to render the image before you can draw it.
  23. kicken's post in PHP curl GET request with Parameters was marked as the answer   
    Yes.  CURLOPT_POSTFIELDS is only for doing POST requests.  For GET you just include the parameters in the URL's query string.  You do that by adding a ? followed by the parameters in name=value&name=value2 format with proper url encoding applied.
    PHP has a function to build the appropriate string from an array of parameters: http_build_query.  Use that and concatenate the result to the URL.
  24. kicken's post in Filling Undefined values in an array with a null value was marked as the answer   
    You can simply use the null coalescing operator when reading the values from your array to remove the warning.
    $num = $leaddata[$status][$title] ?? null; $contacts = $leaddatastatus[$status][$title][$sub_status] ?? null;  
  25. kicken's post in Method call working in one place but not the other was marked as the answer   
    Yes.  You're loading your existing comments in the constructor of the Comments class, so all your data gets loaded here:
    $comment = new Comment(Input::get("post_id")); The data you load at that point is what you'll end up displaying later on when you call display() and count().  Whether or not $message is true isn't really relevant to how this functions.
    That's wrong from a syntax perspective.  If that's what you have, you should be getting a syntax error I would think.  You don't use <?php ?> tags to embed variables into strings.  You use concatenation and/or interpolation.
    Redirect::to("single_post.php?post_id=$post_id&related=$related"); With the syntax fixed, replace your $message = true; line with the redirect.  You'll need to use an alternate means of determining whether or not to show your message, such as by adding a message=true parameter to the URL or storing something in the session.
    This is possibly related to the bad syntax of the redirect.  Notice in the stack trace it shows the php tags as part of the parameters:
    Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /opt/lampp/htdocs/qcic/assets/class/DB.php:35 Stack trace: #0 /opt/lampp/htdocs/qcic/assets/class/DB.php(35): PDOStatement->execute() #1 /opt/lampp/htdocs/qcic/assets/class/DB.php(121): DB->query('UPDATE posts SE...', Array) #2 /opt/lampp/htdocs/qcic/assets/class/Post.php(227): DB->update('posts', '<?php echo 86; ...', Array) ------------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^ #3 /opt/lampp/htdocs/qcic/newsnet/single_post.php(16): Post->viewCount('<?php echo 86; ...') ---------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^ #4 {main} thrown in /opt/lampp/htdocs/qcic/assets/class/DB.php on line 35  
  • 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.