Jump to content

ginerjm

Members
  • Posts

    6,902
  • Joined

  • Last visited

  • Days Won

    99

Posts posted by ginerjm

  1. It is ALWAYS good programming practice to check the results of operations that can impact your own process. If you run a query you should always check the result of it before trying to use the query results (check the PHP manual for examples on how to use the query function). If you open an external file you should check that the open call actually worked (see the manual again for 'fopen' for examples). That way you avoid running into problems later on in your scripts.

     

    In this case when you make those calls to Google (an external source!) you should be checking the response to make sure it worked. And when it doesn't work you should know how the source is returning any important info that can help you (check your API instructions/manual). That is what scootstah is trying to tell you.

     

    Other things that you can do are to turn on PHP error checking during your development cycle (see my signature) and when really stuck look at the php error log file on your server for any messages that may be posted there (google 'php error_log').

  2. Dislike plus 1 here!

     

    So the user now has a slew of vars containing his data. Just what he wished for. Now what does he do with them? How does he find anything? Is this original array a static set of data - never to change or be re-sized? With all those var names what kind of (complex) code is he going to have to write to find anything? Moreso - with var names that have nothing to do with the specific value that they hold how WILL he find anything?

     

    With an array at least the data is easily accessible. It may still be unrecognizable as to its true meaning but at least it will be find-able.

  3. It appears that you have a series of numbers sorted ALPHABETICALLY and stored in groups of 6 values. What it is and why it is stored that way is a mystery, but apparently necessary.

     

    As for re-arranging it - do as Requinix said - don't! You already have a perfectly valid (tho limited) data structure so use it. Instead of $array1 you just reference $array[1] or to get individual values $array[1][0],$array[1][1] and so on. Read the manual on arrays to help understand arrays if you need to.

  4. At age 63 I have a lot to offer too. Unfortunately you don't seem to be reading what I'm saying. My questions/points are all valid and you don't get that I am trying to help you debug the problem. My first post was nothing but helpful, but you chose not to address my issues in a positive way.

     

    Since you have plenty of time to spare (as do I), I'll leave you to ponder your code and solve your problem now. I tried. Ho hum...

    • Like 1
  5. You want to copy someone's work? And you expect us to help you?

     

    If this was for a legitimate purpose I would expect you to have help from the author. Since you don't (obviously) then it appears to be illegitimate and therefore I will not offer you help. I hope other well-meaning forum members understand what they may be doing should they offer their two cents.

    • Like 1
  6. 1 - you still don't get what I asked about 'root'. Since you didn't say it was a PHP constant I have to say it is invalid code which should stop your script from working properly.

    2 - you copied "this" from the manual. What are you referring to - the function? If you know anything about functions then you know that it doesn't execute by itself. It has to be called. You should have tried to understand what you were copying and made sure to copy a call to that function.

    4 - Defeatist? How about "wasteful"? There's another term that could be used. You are switching because you think you have to. All I did was repeat what you have already been told and added my $.02. You don't have to recode this - and spend this time more fruitfully by trying to learn some basic php.

     

    If you haven't done so already, plagiarize my signature and add that code to your script. You should get a few more warnings and notices from your code. As in the use of $row for one of your query processing lines. $row does not exist. $Row does.

  7. 1 - What is "root"? You use it in your connect statement but what is it? A string? A constant? It's not a var.

    2 - As already said - you never call the function that you wrote.

    3 - The word is "deprecated", not depreciated. Two entirely different things.

    4 - As also said - if you have a working mysqli model you do not have to change a thing.

    5 - You are using a foreach to process your query and loop thru it. I find it very confusing to read and frankly am not even sure it works that way. A simpler way of doing this is to execute the query (and check the results for false before proceeding) and then to use a while loop as follows:

    $qrslt = $conn->query($Rel_Hol_sql);
    if (!$qrslt)
    {
    echo "Error running query";
    exit();
    }
    while ($row = $qrslt->fetch(PDO::FETCH_ASSOC))
    {
    (handle your row here)
    }
    

     

     

    Don't know what you are referring to when you said you downloaded and read a manual and found it to be too technical, but this business is all about being technical. If reading the manual is already too technical, you are in for a long tough row to hoe if you choose to continue this effort.

  8. Add a test on the query result to be sure it is True and not False. Also - your query selects some fields without a table qualifier. Are those fieldnames unique? Also - why would you want to retrieve the password? If this is a general query and not a logon query, why do you want to expose the password?

  9. The use of $_REQUEST is not recommended. It is far safer and better to use what you actually expect your data to arrive in. If the form uses method='POST', then use $_POST. Same if it is a GET request. Use $_GET. Hackers could do something with a get while your script expects a POST and by using $_REQUEST they can still get into your script. Why use the ambivalent $_REQUEST when you know what it should be?

     

    If English is your primary language, why do you write such poorly composed posts?

  10. Like mac_gyver says - learn what you are copying before you try to use it. If you "find" some piece of code, look up every part of it in the manual to see what it is doing and to LEARN from it.

     

    Can I ask: Is English not your primary language?

  11. Do you not even know how to write plain text to communicate?

     

    Of your last 4 posts above this one, the first 3 make no sense at all! And the latest one is fraught with errors even while trying to teach something. Are you trying to tell the Forum about the dangers of trusting user input? I think most people here already know that and try to impart that to those that don't.

     

    PLEASE try and learn this: Do Not Use $_post. It is not what you think it is! One of the first things about PHP that you will learn if you ever really try to learn it is that the language is CASE-SENSITIVE.

  12. Well the anchor tags are the natural way to do it. How else are you going to generate a click?

     

    As for your concern about resource usage - a simple glob will tell you what the contents of a dir are and how many entries there are so what is the concern? As for the 'complex structure' you are only going to load one dir for a click - any dirs below that one will still show up as anchor tags with no details beneath them - yet.

  13. Checking if $_POST is empty is a pretty meaningless check. What are you hoping it will tell you? Upon receiving posted input one usually checks for the button value that was checked and then proceeds to handle the input data that that button should be providing. You're checking if there is anything at all in $_POST and then immediately proceeding to use the input provided without checking if all (or any) of the inputs are valid or even present.

     

    As for your first statement that Cronix disputed - it seems correct to me. You ask if 'active' is NOT 1 and if 'active' is NOT 0 and if true you prepare an error message. Seems valid to me!

    • Like 1
  14. Is there some reason behind using dom to build your page instead of just echo'ing the html you need to display this? And why does it have to be ajax?

     

    As for the clickable things - output your list elements as simple text values but when one of them is a directory name output it as an anchor tag inside of a list element.

  15. As mentioned before - you REALLY need to read something to learn about PHP. Your last code sample is still a MESS. Two opening form tags, but only one closing one that I can see. You've invested an awful lot of time in layout but very little in designing the simple mechanics of html and form input handling.

     

    1 - Turn on php error checking. It will help you. (See my signature)

    2 - Hint - there is no such variable as $_post. A little bit of php knowledge will teach you that.

    3 - Proper array syntax is $variable['index'] which you are not doing.

    4 - You are doing a form POST so why the use of (incorrect) $_get references?

     

    If my question puzzle you and make you think that I'm being unfair, consider it your first lesson in how to learn to program. You think this is easy? It CAN be -if you do your homework.

  16. Untested but s/b pretty close.

    
    $site= (dns_get_record( "example.com", DNS_ALL);
    ShowArray($site);
    //***********************
    function ShowArray($arg)
    {
    foreach ($arg as $idx=>$val)
    {
    if (is_array($var))
    {
    echo "<br>Array is<br>";
    ShowArray($var);
    }
    else
    echo "$idx is $val<br>";
    }
    }
    

  17. Did you fix the problems I pointed out? When you do how about isolating the new problem area(s) and posting those snippets of code for us to address? I, for one, will not be going to your external post no matter where it is hosted, so I won't be any help until you do the necessary work to get close to your problem and ask a pertinent question.

×
×
  • 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.