Jump to content

ginerjm

Members
  • Posts

    6,322
  • Joined

  • Last visited

  • Days Won

    94

Community Answers

  1. ginerjm's post in Undefined array key at curl POST method was marked as the answer   
    What is the second line above supposed to be doing for you?  It is not a usable statement.  If you had error checking enabled you would probably get a message.  Add this to the start of your script, right after the session_start:
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
     
  2. ginerjm's post in Need Help in order to dump Excel Sheet Record into MYSQL from one sheet to three Tables. was marked as the answer   
    Obviously this data needs to be normalized in order to build a database.  You have all different data arrangements in a single sheet and probably multiple of those sheets in your workbook.  Sounds like more of a manual effort to break this down into several csv files that you can then easily import into a properly structured set of table in your new db.
  3. ginerjm's post in PHP filename in sub-directory not allowed to be number w include was marked as the answer   
    Basically it's telling you that there rules to filenaming.
    What's wrong with naming them 'page1.php' and 'page2.php'?  Too hard to program?
  4. ginerjm's post in How do I retain the content entered into textarea after submitting, so that I can continue to add content? was marked as the answer   
    How long do you want this 'session' to go on for?  You are setting up for a post session to send the input to your script and then you apparently send the screen to be re-displayed, but after doing what?  Are you planning on saving the input in a table or in a text file?  Plus your current code seems out of order since you are displaying the form before you have retrieved the "name" contents so it won't be displayed, if it even executes.
    PS - don't use 'name' as your name field.  Give the text are an actual name - not what is possibl a reserved word.
    Question - what are all of the BLB lines about?
    And your statement about "it is a simple thing to do".  Where did you learn that to be true?  Obviously it is not since you're here, no?
    Let's start with a decision on my first question.  Where are  you keeping this data to be re-used?
  5. ginerjm's post in some help using glob and foreach loop was marked as the answer   
    Don't know why the printf is needed.  Here is how I would tackle it, no testing of course.  I'll leave that to you.
    $files = glob("images/*.{jpg,png,gif,svg,jpeg,bmp,webp}", GLOB_BRACE); $cnt = count($files); $i = 0; foreach ($files as $filename) { $i++; echo " <div class='mySlides fade'> <div class='numbertext'>$i / $cnt</div> <img src='$filename' style='width:100%;'> </div> "; } Not sure what $filename actually contains but you can easily append anything needed to the src= attribute clause if it's not already there
  6. ginerjm's post in Leon's PHP/MySQL project Q/A thread was marked as the answer   
    You have $pdo and $PDO.   What do you think?
  7. 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.
  8. 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.
  9. 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.
     
  10. 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.
  11. 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?
  12. 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 
  13. 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.
  14. 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.
  15. 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
     
  16. 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.
  17. 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' ?
  18. 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.
  19. 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?
  20. 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
  21. 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.
  22. 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....
  23. 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.
  24. 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.
     
  25. 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.
×
×
  • 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.