Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Community Answers

  1. 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?
  2. 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
  3. 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.
  4. 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....
  5. 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.
  6. 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.
     
  7. 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.
  8. 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?
  9. ginerjm's post in PHP looping issue was marked as the answer   
    Have you attempted to do any reading/learning of php so that you might glean some knowledge of your own?
     
    This is how it s/b written.

    $select_var = "<select name='size' id='size'>"; while ($lrow = mssqlfetchassoc($tres)) {    if ($row['tsdescription'] == $info['size'])        $selected = 'selected';    else        $selected = '';   $select_var .= "<option value='" . $lrow['ts_id'] . "'  $selected>" .  $row['description'] ."</option>"; } $select_var .= "</select>";

    Always try and stay in php mode until you finally output your entire html doc.  Here you build the necessary dropdown into a var.  Down lower in your script where you assemble the bulk of you static and dynamic html, insert this var where it needs to be and your page will display it properly.  Don't keep spitting out pieces of html and then doing some php and then spit out some html.  It's confusing and hard to follow and even harder to maintain later on.
  10. ginerjm's post in SQLSTATE[HY093]: Invalid parameter number: parameter was not defined was marked as the answer   
    The message says you have a discrepancy in the parameters you setup for your query. Take a look at it again. It's pretty simple.
  11. ginerjm's post in IMAP functions was marked as the answer   
    Problem solved. Found some new material and after a bit more experimenting got it all working.
     
    For those interested:
     
    To make an ssl connection using IMAP with no 'real' certificate use this:

    $host = "{domain.net:993/ssl/novalidate-cert}INBOX"; $mailbox = imap_open($host, $emailaddr, $emlaccess);
     
    I was using this in a script that was handling forwarded emails on STDIN so the following got me the current message #

    $imap_obj = imap_check($mailbox); $msg_cnt = $imap_obj->Nmsgs; // get last msg no. that we just processed
     
    With the messge number I could then move the message out of the inbox to a specific destination folder that
    I wanted to archive these emails in:

    imap_mail_move($mailbox,$msg_cnt,$dest);
     
    Note that my dest folder had to be named as follows:
     
    INBOX.subfolder.subfolder
     
    rather than how some parts of the manual said it had to be formatted.
     
    Last but not least and as the manual did tell me, when you do a move like this the original message still sits in the inbox. You have to turn on the flag in the imap_close function to cause this message to be removed once the inbox is closed
     

    imap_close($mailbox,CL_EXPUNGE);
     
    Note the value is a Constant and needs no quotes.
     
    This all had to be done as IMAP since one cannot do folder moves using POP3 apparently.
  12. ginerjm's post in Undefined index error where it should not be was marked as the answer   
    You apparently have produced this variable (a query result perhaps?) before trying to create the new object. But like so many people who are new to PHP (and/or programming) you fail to check the result of that query(?) to see if you have something in that array. Do that and you won't run into this situation. Or you could add some more code to the constructor to allow for an empty argument if that actually makes sense to do, ie, creating the object when you don't have the input for it.
  13. ginerjm's post in i have a problem: "Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output... was marked as the answer   
    It is telling you exactly the problem. Look at line 3. You can't send a header once you have sent ANYTHING at all to the client. Wherever you are trying to send after a header(line 3?) needs to be moved up above whatever you have already output.
  14. ginerjm's post in PHP IF NOT VARIABLE THEN DO was marked as the answer   
    Is the ID a number or a string? Be sure you are comparing correctly.
  15. ginerjm's post in new to mysqli and putting it into a Function was marked as the answer   
    Does $column contain any spaces?
     
    One should really wrap associative indices in quotes to ensure there is no problem in determining the correct element of the array it is used on.
     
    $row["$column"] would be correct.
     
    BTW - you are doing a query that selects all rows but only returning the first row's value. Is that what you want?
  16. ginerjm's post in Edge not recognizing my accesskey settings was marked as the answer   
    Well, I solved my accesskey problem. I simply installed IE10 on my W10 laptop and ran my website on it and no problem. So it's not W10 giving me the problem and it's not my appl since that works on the same laptop that has Edge on it. It's simply Edge not recognizing an accesskey attribute inside an anchor tag.
     
    I hope somebody else has already reported this failure to M$.
  17. ginerjm's post in preventDefault handling? was marked as the answer   
    Ok - solved my own problem. Instead of my html calling a routine to validate the input with an onchange call and then handling an Enter key as a Tab with an onkeypress event I consolidate my activities.
     
    With an onkeydown I call my edit routine. In there I check for a tab or enter key. If it's not one I simply ignore it and return. IF the key is an Enter or Tab I perform my editing and if that fails I manage to do either a preventDefault or stopPropagaion and return false. If it passes the tests, I call my routine to handle an Enter as a Tab and then return true.
     
    So now - user can do d/e and hit enter or tab when done. The screen will edit my entry and either keep me on the field or move to the next tabstopped field. Just what I need.
  18. ginerjm's post in Confused Need Help Please was marked as the answer   
    Not a good solution to do a query inside a loop, let alone two of them! Why aren't you writing an all-inclusive query to avoid all that? That said - please define 'broke'. Programmers need precise information to help solve problems.
  19. ginerjm's post in Cancelling an event? was marked as the answer   
    Ok - never mind. Made a change to use onBlur instead of onChange and it works better than expected!
  20. ginerjm's post in Need help to create dynamic php next content page. was marked as the answer   
    Glad we could get you on the right track. Learning how to program is not just copying someone else's hard work. It's about learning which involves reading and understanding and practice. Kind of like everything in this world.
  21. ginerjm's post in Help with navigation site was marked as the answer   
    You've lost me. I have no idea what you want. Good luck.
  22. ginerjm's post in Email not sending with PHP was marked as the answer   
    What doesn't work? The mail never arrives or never gets sent? Do you get a response from your script? Is error checking turned on?
  23. ginerjm's post in MySQL update subtracting 2 instead of 1 was marked as the answer   
    You probably don't realize that your first call to query() runs the query and so does your second.  The if statement is a wise thing to do to evaluate if your query runs, but don't run it the first time because the if is going to run it again.  Dump the first call.
     
    And of course, as Mac_gyver says, one doesn't maintain a total in a database.  One designs it to record the details and than obtains a count/total/sum when on needs it by doing a quick summary query.  Does your system register the occupants of the seats in each class?  If so, then you already have your answer for total seats used.
  24. ginerjm's post in PHP Listing Non Existent Error was marked as the answer   
    Highlight the entire script and look for colored areas with no visible chars in them
  25. ginerjm's post in bold font in php email was marked as the answer   
    You have formatted the email properly as an html one, correct?  Have you altered your to address to send the email to yourself to see what you actually get?
×
×
  • 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.