Jump to content

ginerjm

Members
  • Content Count

    4,898
  • Joined

  • Last visited

  • Days Won

    63

Posts posted by ginerjm


  1. The braces are required when embedding complex variable names (an array element) inside other things.  Without them you would get a syntax error.  You could use concatenation (dots) to avoid this but with the braces you can skip the concatenating and just compose one contiguous string here.  

    The thing I wanted you to note was the quotes on the array indices.  A Key thing!

    • Great Answer 1

  2. I think I know what you are trying to do and that is to modify a block of code that exists in several files.  So - my suggestion is to stop and re-think your actions here.  Why not alter all those lines to one call to a function passing in a variable?  Then write a stand-alone module that contains this function and have it do the work.  This way if you need to change this once again, you would only have to worry about one existence of this code.


  3. NO I didn't look at the code.  People who post reams of code without thought for the people unfamiliar with the thoughts, ideas and processes being used and expect it to be resolved for them just aren't thinking.

    If you want help try and make it possible for others to help you - that is my point.  Do some debugging; isolate the location of the problem and dig into it and only then post  it and ask for help.

    PS - judging from the timbre of your own post I have to wonder how miserable you must be to write that.  Tsk, tsk....


  4. On 1/17/2020 at 4:16 AM, Silent-B said:

    when there is a value(name) in "_POST" you cant use echo $GLOBALS["name"]

    You are making a tutorial?  Really?  And you don't understand what is wrong with the quote of yours above?

    The Globals array contains all defined variables of your current session.  Even your current running process.  So - if you have defined something such as $name that is defined in the Globals array.  Thus if you reference $name it already IS known as $GLOBALS['name'].   

    Of course I don't understand your syntax when you mentioned "value(name)" so my assumption of defining a var called $name may be totally wrong.  Perhaps you could clarify what you meant by the use of "value(name)"?

    And as others have said.  $GLOBALS is not something that anyone uses.  It's just not.  That and the $_REQUEST array are not preferred even tho they still exist.  If you want to reference something, do it properly, i.e., look for php vars such as $name or $x or $arr, blah,blah,blah or $_POST or $_GET instead of $_REQUEST.  And if you want to make a local script var known inside one of your functions, either pass it in as an argument or declare it as global using the global construct inside each function that you want it known in.


  5. Quote

    when there is a value(name) in "_POST" you cant use echo $GLOBALS["name"]. 

     

    You are making a tutorial?  Really?  And you don't understand what is wrong with the quote of yours above?

    The Globals array contains all defined variables of your current session.  Even your current running process.  So - if you have defined something such as $name that is defined in the Globals array.  Thus if you reference $name it already IS known as $GLOBALS['name'].   

    Of course I don't understand your syntax when you mentioned "value(name)" so my assumption of defining a var called $name may be totally wrong.  Perhaps you could clarify what you meant by the use of "value(name)"?


  6. I know it sounds like a fun project to emulate something that already exists.  But - just exactly why do you think it necessary?  There is already a $_SESSION array (RTFM) and the ability to make specific local vars global for your entire script (see 'global') .  So what design of yours is going to need your own new version of this?

    Besides - good programming practice does not include making everything globally available.

    • Like 1

  7. Specifying an index without quotes makes php do a tedious evaluation of that unknown value and assuming that it is a constant of some kind.  Definitely not the already-defined var name that you have in mind.

    Indices need to be quoted string values or defined php vars (which don't need quotes).


  8. Your tables have some problems for joined queries?  That sure sounds like a poor design.  Perhaps addressing that would solve not only this problem but a lot of future ones?  And then it would allow you to collect all of your data in one query results set and that would make your output algorithm easier.

    And please don't say that you can't make time to fix this problem or that you only want to get this one thing working.  You have done something wrong and for people here to help you work around it would not only be a bad use of their time, it would encourage you to continue to do things in less than appropriate ways.  You have made a misstep here and you should step back and learn from it and gain the knowledge that comes with that.


  9. You ask what to do with "non-included" scripts.  Well - if they are not being used as includes then it sounds like they are what I called major scripts, meaning that they start a process.  So - yes, do a session start.

    A notice is a notice.  As I also said - if you see a notice, fix that script.


  10. You are using an array for your inputs.  Why?  Why not simple variable names for each input field.

    You say that you want to search for the name of a game.  Is that stored in a field called "id"?  Seems more like it belongs in your "game" field.  Plus - you should enclose that in quotes since it is a string value.  And you may need braces around the variable name as well.


  11. I"m sorry.  I wrote the code and tested it out and it worked great.  Only after I posted it did I realize that I could not "copy" it to anywhere where the visual structure remained the same.  So perhaps someone smarter than me knows how to take a web page image of this output and insert it somehow into a post (perhaps) without losing the proper formatting.

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