Jump to content

ginerjm

Members
  • Posts

    5,543
  • Joined

  • Last visited

  • Days Won

    78

Community Answers

  1. 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.
  2. 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' ?
  3. 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.
  4. 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?
  5. 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
  6. 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.
  7. 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....
  8. 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.
  9. 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.
     
  10. 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.
  11. 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?
  12. 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.
  13. 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));
  14. 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
  15. 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....
  16. 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.
  17. ginerjm's post in Get "true" from multiple "if" was marked as the answer   
    You should do a little reading on the use of the if/else statement. Any php reference can help you understand how they are used. Especially the official PHP manual at php.net
  18. ginerjm's post in rearrange info copied and change data pulled was marked as the answer   
    Step 1 - change the line that has $emp['city_name'] to something that has your group price value :  $emp['group_price'] .  I used 'group_price' since I don't know what you actual "group price" field is called.
     
    As for the rest of the code you posted - why?
     
    As for the whole thing in general - I can understand why the author is un-reachable.  Hope you didn't pay too much.
  19. ginerjm's post in Checking for available rows while navigating to next or previous element in the database was marked as the answer   
    If your row count is 0 then don't create the anchor tag.
  20. ginerjm's post in Form Issue was marked as the answer   
    Try using an input element for your submit instead of the button one.
  21. ginerjm's post in PHP script, selecting and inserting into mysql without duplicates was marked as the answer   
    Doing queries inside of loops is definitely to be avoided.  Your situation does not necessitate breaking the rules here.
     
    If you modify the structure of your prod. server's table to eliminate the AI setting on the PK, then you can simply do the query I suggested earlier since the keys from the phone server data will not conflict with the production server's db structure.  
     
    Get your Sql query writer to write your queries for you.
     
    1 - Either keep track of (somehow) the id that was last added to your prod server.  That or do a query on it to get the max value of id there.
    2 - Write a query to insert into the prod server using the sub-query results that a query against the phone server where id > the last id inserted into the prod server (from #1)
     
    That's all there is.
     
     
    // first get the last id on the prod table $q1 = "select max(SESSIONID) as last_id from proddb.tablename"; $q1_ans = $pdo->query($q1); if (!$q1_ans) {     echo "Could not get last inserted id from proddb";     exit(); } $row = $q1_ans->fetch(); $last_id = $row[0];   //  now do the insert query $q2 = "INSERT into proddb.tablename (specify every column name in the order of the phone server's table structure here)                 SELECT *  FROM phonedb.tablename                   WHERE phonedb.SESSIONID > $last_id"; $q2_ans = $pdo->query($q2); if (!$q2_ans)     echo "Could not do insert query"; else    echo "Insert query ran successfully";  
    Note:  not exactly sure about the syntax of the #2 query.  You may have to specify all of the phone server fidnames in the sub-query instead of the *.
    Plus - I have never done queries that access separate servers before.  Don't know how that is done but this is how it would work if using separate dbs on a single server.  There may have to be some research into that.  If it can't be done, then you could output the results of a query on the phone server to a table and use it in your #2 query after getting it to the prod server.
  22. ginerjm's post in Piped email suddenly not working was marked as the answer   
    Well, while waiting for some input on this, I backed off all my edits on one of my 'offending' scripts and the problem went away.  I have no idea what line(s) was/were the culprit.  If anyone does have a good idea of what I may have done (hah!) I'd appreciate hearing about it.  But - if you don't have a sure answer, then don't waste your time on my now-resolved problem.
  23. ginerjm's post in 'Guess a number' - Help with hidden fields and arrays was marked as the answer   
    When you say it doesn't work, how do you know?  Are you getting error messages?  Is php error checking turned on (see my signature)? 
  24. ginerjm's post in special trim ? was marked as the answer   
    Solved.
     
    While looping thru the number lists I was not properly recognizing the results.  I was looking for a False result to indicate an error/bad value when I should have just checked the "corrected" value and replaced the original/bad one with it.
     
    Now that I am doing that my process works.
     
    Thanks for your interest!
  25. ginerjm's post in Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in ... on line 42 was marked as the answer   
    The prepare will fail if the query is not formed properly.  Any invalid column names, any missing parms ie, a mismatch in the number of values and fields.  It's up to you to debug it.  Remember that you cannot use a parm for the table name.
×
×
  • 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.