Jump to content

requinix

Administrators
  • Posts

    15,066
  • Joined

  • Last visited

  • Days Won

    414

Community Answers

  1. requinix's post in Database implementation suggestion was marked as the answer   
    If you moved done, valid, and file into the visitas table then rel_visitas_utilizador would not be needed anymore.
  2. requinix's post in prepared statement vs mysqli_query was marked as the answer   
    It means somewhere you did an unbuffered query and didn't read all of the rows and/or didn't ->close the statement. It was probably earlier in your code.
     
    Switch to buffered queries, which won't have that problem and are generally better for everyone involved.
     
    [edit] 2 minutes.
  3. requinix's post in PHP Image Button if Statements was marked as the answer   
    Hidden inputs are all sent with the form when it's submitted. However submit buttons ( and ) and image buttons () will only send themselves when they are used to submit the form - and only one of those can happen at a time.
     
    So what you need to do is figure out what image button was clicked.
     
    1. Remove the hidden inputs since they're not helping you.
    2. Give names to the image buttons (eg, "toner").
    3. Look for each button to tell which was clicked. Note that there will not be a "toner" but instead "toner_x" and "toner_y" values.
  4. requinix's post in How to handle a " in PHP files / LOAD ATA IN FILE was marked as the answer   
    You don't know about backslashes? How do you not know about backslashes?

    echo "String with a " quote"; // nope echo "String with a \" quote"; // winner
  5. requinix's post in Question about var_dump($object) output was marked as the answer   
    That's right, and I don't know. It's quite possible - likely, even - that I don't know the full story behind what the number is and how it works.  

    Only when debugging.  

    Right.  

    Nope.
  6. requinix's post in Modifying a file before upload was marked as the answer   
    You can't. You're the one who talked about resizing before the upload, which I took to mean you were doing something manually. It doesn't make sense but that's the only logical conclusion I could make. That resize class runs in PHP, which is on the server, which means you would have to use it to resize after the upload.
     
    And by "upload" I mean the technical mechanism of a user using their browser to submit a form containing a file-type input, wherein the file data gets sent to your server and processed by your PHP code.
  7. requinix's post in Passing Variables into auto loaded class files was marked as the answer   
    Variables defined outside functions are not available inside functions.
     
    Pass $db as an argument to the method.
  8. requinix's post in Get Object Variable was marked as the answer   
    That output is for $my_coupon, right?
     
    $my_coupon

    Array (is an array
    [test]with a "test" key
    => WC_Coupon Objectwith a WC_Coupon object as the value
    [coupon_amount]which has a "coupon_amount" property
    => 10with the value 10. 
    So

    $my_coupon["test"]->coupon_amountDoing it this way means you need to know the coupon code. Do you?
  9. requinix's post in [Ajuda] @fwrite criando arquivo .php com conte�dos $variabes $rows was marked as the answer   
    The code is suspicious but I'll give the benefit of doubt.
     
    http://php.net/manual/pt_BR/language.types.string.php#language.types.string.parsing
    $script = "<?php \$conecta = mysql_connect('HOST', 'LOGIN', 'SENHA') or print (mysql_error()); mysql_select_db('BANCO', \$conecta) or print(mysql_error()); print 'Conexão e Seleção OK!'; mysql_close(\$conecta); ?>" . $script;
  10. requinix's post in How can users save a PDF which I'm loading with readfile()? was marked as the answer   
    If you don't mind forcing a download instead of presenting it in the browser then you can do

    header('Content-Disposition: attachment; filename="quote-123.pdf"');Otherwise make the URL to the PDF be something that ends in /quote-123.pdf. You can use URL rewriting (nicer) or change your /path/to/script.php to be like /path/to/script.php/quote-123.pdf which should still invoke your PHP script (easier).
  11. requinix's post in PHP JSON Encode was marked as the answer   
    You also need a line of code that adds the month category into the array. Outside of the loop.

    $out[$element['category']]['category'] = $element['category'];Take a look at the documentation for array_values. Do you see what it does to arrays? It strips off the custom keys and replaces them with regular numeric keys. You need to do that to your array before you json_encode() it - those custom keys vs numeric keys are what makes the difference between getting {} objects or [] arrays in the JSON.
  12. requinix's post in Query Not Returning As Expected was marked as the answer   
    Searching through serialized data... ugh.
     
     
    AND has higher precedence than OR, just like how multiplication has higher mathematical precedence than addition. That means writing

    a OR b AND c 2 + 4 * 5is equivalent to
    a OR (b AND c) 2 + (4 * 5)Applying that to your query we discover you've effectively written
    matches q1 OR matches q2 OR (matches q3 AND is not shop manager AND is subscriber)Use parentheses to force evaluation the way you want:
    (matches q1 OR matches q2 OR matches q3) AND is not shop manager AND is subscriberBut I fear you may discover other problems.
  13. requinix's post in sticky list box was marked as the answer   
    Oh, I missed something that would have been nice to point out.
     
    Remember how you made joke_text sticky? "If the joke_text is present in $_POST then output it"? Start with the same concept except with the author

    if(isset($_POST['author'])) { echo $_POST['author']; }
    then add a condition that the POSTed author matches the author in $data (remembering that what's in $_POST will be the author ID and not the name)

    if(isset($_POST['author']) && $_POST['author'] == $data['id']) { echo $_POST['author']; }
    then change the output to be not the value from $_POST but "selected".

    if(isset($_POST['author']) && $_POST['author'] == $data['id']) { echo 'selected'; }
  14. requinix's post in Is it possible to change my username? was marked as the answer   
    Turns out only the username is supported, not both as I thought. So that's the second lie I've told.
     
    I changed your username.
  15. requinix's post in Problem creating objects dynamically was marked as the answer   
    $modelName[strlen($modelName) - 1] = "";Don't do that. You cannot use [] to remove characters - only replace. What the code above actually does is replace with a \0. 
    I don't know what character you're trying to remove but I suggest looking at rtrim.
     
    [edit] The character is 's'. Which should be obvious given the code and output above. Eh.
  16. requinix's post in Variable not updating was marked as the answer   
    What's $m->get/set? Caching? Is that working correctly? It doesn't look like the ->get is setting any sort of TTL or expiration time...
  17. requinix's post in MYSQL IN working like AND was marked as the answer   
    I'm going to ignore the SQL injection and go for the question itself. In a case like this I would do a GROUP BY + HAVING COUNT

    SELECT id FROM fruit WHERE fruit_name IN ("apple", "banana", "orange") GROUP BY id HAVING COUNT(1) = 3Make sure the id + fruit_name pair is unique, even if the two aren't individually.
  18. requinix's post in Help hide private information was marked as the answer   
    Turns out to be a user group restriction that applies to new users. I've moved you to the regular member group - check that one page again.
  19. requinix's post in png images do not display was marked as the answer   
    Then what does it display? Comment out the header() - do you see any error messages?
  20. requinix's post in How to reference the id of the body tag was marked as the answer   
    1. The PHP is irrelevant. Only the HTML it outputs matters. 2. Actually it kinda does. Those three selectors are all essentially "if"s: if this matches, or if that matches, or if the other one matches, then...
  21. requinix's post in using set_time_limit() was marked as the answer   
    Anecdotally and without any sort of source to back me up, you shouldn't do an indefinite timeout on a blocking function. I think that's from personal experience. Do a "long" timeout of less than a minute, then worst case your loop just jumps back to the start and it starts blocking again immediately.
  22. requinix's post in Searching is very slow was marked as the answer   
    Oh no, it wasn't you. I was stuck on an issue that needed changes at the VM layer for our instance.
     
    But that's just been dealt with, so I've finished the switchover. We're now (back to) running with Sphinx.
  23. requinix's post in Composer autoloading inconsistencies? was marked as the answer   
    That's just the way the author(s) designed and wrote their code: ImageManager uses namespaces, FirePHP uses a singleton pattern, and mpdf doesn't use namespaces. Sometimes there's history behind the decisions, sometimes there's history to the project itself that predates some PHP features or best practices.
     
    Not really much you can do about it.
  24. requinix's post in How do I handle database entry dependent on PayPal payment? was marked as the answer   
    Don't do anything simply based on the user returning from PayPal. It's just a URL. Anybody can visit a URL.
     
    You have to verify the transaction was successful. Personally I prefer to use IPN: PayPal submits a request to your server directly, including information, you verify the information (sending a request back to them in the process), and if everything is good then you consider the payment as being completed.
  25. requinix's post in ssl niginx error was marked as the answer   
    Make sure the bundle has the certificates in the right order: nginx expects yours at the top and the rest of the chain after.
×
×
  • 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.