Jump to content

ginerjm

Members
  • Posts

    5,986
  • Joined

  • Last visited

  • Days Won

    86

Community Answers

  1. ginerjm's post in Return vs Echo was marked as the answer   
    An echo is an 'output' statement which is why you actually see something.  A return is not.  It is simply a method to pass a value back to another that is waiting to receive it.
  2. ginerjm's post in Simple SQL select query not pulling any data was marked as the answer   
    Try dropping the quotes on the args in the query.  The PDO prepare will correct what is necessary
    And what are you outputting when there are rows?  It looks like a string of the word 'this' repeatedly.
  3. ginerjm's post in Getting error on php contact form was marked as the answer   
    The above line makes an array having one element (0) whose value is 'nospam'.
    What are you planning to do with that array? I don't see it referenced but it still seems like a funny thing to be doing.  You are doing a check for the entry in this field but not with the array you have created.  Perhaps you simply want to create it near the top of your script as a simple static variable and not an array?
    and then maybe you want to change this
        if ($post['secretcode'] != 'nospam')
    To be 
    if ($post['secretcode'] != $secretcode)
    BTW - You seem to be doing this thing with your own version of the $_POST array for no good reason.  Is this something you read about somewhere that is supposed to be of help to your algorithm?  Why not just use $_POST?  It's a global array that you control and is accessible from your entire script.
     
  4. ginerjm's post in PHP Parenthesis? - totally new at this was marked as the answer   
    As I said first thing -- the style of this code is not allowed at all.  It has to be re-written.  These new lines are not the same as the one you have the error on.  They do not follow the same format as the bad one.
    I have no idea what the app is supposed to do for you but it is written rather tediously and I would have definitely found another way to do this that the mind-numbing way that the original code chose.  I'm guessing that he/she too was a noob when writing it.
    Try this:
    $coronavirus_notice_banner_color = @$_POST['action']=='save_coronavirus_notice_plugin' ? $coronavirus_notice_banner_color : (get_option('coronavirus_notice_banner_color') ? esc_html(get_option('coronavirus_notice_banner_color')) : '#CC0000'); And I really don't like the use of the @ in this code.  It is not a good practice.
  5. ginerjm's post in Why setted cookie variable needed twice click to hyperlink? was marked as the answer   
    Not sure what "setted" means but when you do set a cookie in your current script, it is not available until you refresh the page you are on.  Cookies are loaded when the server sends a page to the client.   Does that help?
  6. ginerjm's post in Delete data error was marked as the answer   
    I believe that your JS should be in the admindashboard script not the delete script.  
    <script type='text/javascript'> function confirmDelete() { if (confirm('Are you sure you want to delete this record?')) return true; else return false; } Use the above function like this:
    <input type="submit" name="search_by_roll_no_for_delete" onclick='return confirmDelete()' value="Delete"> You can use shorter names for your fields.  Saves on typing 
  7. ginerjm's post in md5sums wrong on downloaded files was marked as the answer   
    And as Kicken has already asked you - where is the part concerning your posted topic title?  Can not see the fact that there is nothing related to anything 'md5 ish' in this code?  
    PS - suggestion.  Do your includes at the top of any script so that you know right away what the script has to work with.  Dont bury your requires inside functions.  It's kind of like burying a function inside a function.  Calling one is ok - including one is not a good practice.
  8. ginerjm's post in Wrong md5sums when downloading from web host was marked as the answer   
    Well if it is EXACTLY as copied then I don't know what it is doing.  If you are trying to ask "is $ext equal to .deb" then you are not doing that.   Try 2 equal signs...
    As for your concern about the md5sums - since there is no code present showing us what is or is not happening, we can't help you.
  9. ginerjm's post in Simple PHP Include Question - I think my host changed something was marked as the answer   
    What is the name of the file you are executing?  If it is showing raw php code you are not running a php file and make sure that if you are that the opening tag is a full php tag as in: <?php
     
  10. ginerjm's post in Deciding which page to load was marked as the answer   
    Follow-up
    If the class you posted is EXACTLY the same as what you are executing I think you either botched the html that references it or you messed up the css portion of your script.  I pasted it into my script (that I gave you) and the submit tags show up nicely formatted.
  11. ginerjm's post in form input read only for multiple fields was marked as the answer   
    A little cleaned up version of your code and my notes on it.
    echo "<form method='POST'>"; foreach ($assetx as $key => $value) {     echo "<label>" . ucfirst($key) . " ";     $ro = ($key === 'id') ? 'readonly' : '';     echo "<input type='text' name='$key' id='$key' value='$value' $ro>"     echo '</label><br>'; } echo "<input type='submit' name='submit' value='Submit'>"; echo '</form>'; 1. One doesn't have to keep going into and out of php mode.  It especially makes it easier to comprehend if one doesn't.  
    2. I can't find any mention of an 'escape' function in my php manual.  Can you explain what you are trying to do with your use of it?
    3  Your foreach is processing an array I assume.  If that is so, how do you expect to have 2 keys having the same value of 'id' ?
  12. ginerjm's post in Uploading Image with PHP from non-root folder was marked as the answer   
    Root to the rest of us is a specific term that is related to the domain or the html web root.  So I am assuming that your root myprojects folder is under the true html root folder.  So if you want your php commands to locate the folder you want you need to probably specify $_SERVER['DOCUMENT_ROOT']  as I mentioned along with the /MyProjects/../...... path to your desired folders.  
    $_SERVER['DOCUMENT_ROOT'] . '/MyProjects' would position in what you are calling root.  If you other folders are beneath that then add them to it with a leading backslash of course.
     
    Hope this is what you are looking for.
  13. ginerjm's post in bind_result inside of a function was marked as the answer   
    Return the vars as arguments of the function with the & on each.
    "function xyz(&$a, &$b)"
    Call the function with "function ($a, $b)"
    and then use $a & $b in your following code.
    And - how does using an array of your two values cause duplication of code?
    Anyway - your question is either how do I return the values or how do I echo the values?  Which do you want to do?
  14. ginerjm's post in Put values to text fields after submit was marked as the answer   
    They are local to the function.  Pass them or make them global
  15. ginerjm's post in Passing variables from function was marked as the answer   
    So?  You write the array and save it as its own file.  Then you include it in every script that needs to use it.  The really smart thing would be to include the function there too and use an arg to feed it and accept a result when you call the function.
    function GetGreeting($time) { $greetings = array( '0'=>'Good morning', '5'=>'You are late' '10'=>'you are real late' ); $str = (string) $time; return $greetings[$str]; } In your other scripts you do an "include 'getgreetings.php;'" and then call it with:
    $greeting = GetGreeting($time);
    and then output $greeting.
  16. ginerjm's post in Integrate some code into another was marked as the answer   
    Show us what you mean.  A lot of us do not click on random links....
  17. ginerjm's post in Notice: Undefined offset: , CSV Fileupload PHP was marked as the answer   
    Your query is trying to insert 5 values into 4 columns.
  18. ginerjm's post in cron jobs was marked as the answer   
    The original idea was to have my php script do this thing.  I have no access to do windows things on my host's server which is probably not a windows one.  Anyway - I think we've beat this topic to death.
     
  19. ginerjm's post in Using <select><option>?</option></select> to display text. was marked as the answer   
    Try this instead
    $select_tag = "<select onchange='reload(this.form)'>"; $select_tag .= "<option>test one</option>"; foreach ($data as $output) { $select_tag .= "<option>" . $output['header'] . "</option>"; } $select_tag .= "</select>"; Now - in your html area simply place the $select_tag var where you want this html to show up.
  20. ginerjm's post in unlink first, then file_put_contents() is behaving weird was marked as the answer   
    Have you done a search of your script for another call to unlink?
  21. ginerjm's post in Displaying Data to Specific User was marked as the answer   
    That would be "an extra column".
     
    Now you need to revert this query back to a prepared one so you avoid un-filtered input being used.
  22. ginerjm's post in md5 sum help was marked as the answer   
    There's probably more elegant ways but I would do a strpos on the string looking for a space.
     
    Then I would grab the beginning part up to that position for the hash and then grab the part after that position for the filename.
     
    Do a trim on each to get rid of any other chars.
     

    $pos = strpos($string,' '); $value = trim(substr($string,0,$pos)); $filename = trim(substr($string,$pos));
  23. ginerjm's post in Token Authentication - Cookie question was marked as the answer   
    ???
     
    You simply create a cookie FROM THE SERVER in the script that authenticates the access. Then wherever you need to check for a proper signon, in each script you simply check for the existence of that cookie. You can also store (perhaps) a value or two in the cookie if you need to know something about the user. DO NOT STORE any sensitive info in the cookie
  24. ginerjm's post in Scope of calling exit was marked as the answer   
    Placing the exit() call following the function DOES make it as "readable as possible". Imagine you are looking at someone else's code where you see a call to a function and nothing after it and you wonder where the code is supposed to go next....
  25. ginerjm's post in Left joins not being implemented correctly? was marked as the answer   
    Use different result names for your two different results. If you assign the name to both "opt_value"s, it's not going to look good coming out.
     
    Ie, Tbla.opt_value as Opt_a, Tblb.opt_value as Opt_b
     
    I didn't notice this in the code I myself posted for you.
×
×
  • 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.