Jump to content

NeoMarine

Members
  • Posts

    73
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

NeoMarine's Achievements

Member

Member (2/5)

0

Reputation

  1. Wow I didn't know of that array version of the function. Many thanks! It works
  2. Anyway, this would be fine but its not what I'm referring to. I haven't got a problem telling how many parameters are passed into the array. I'm just trying to call my function which is stored in a database field in the structure: functionName# var1# var2# etc... and I then explode this string by the "#" and then I know how many vars/parameters there are.. then I want to call it using call_user_func() - but to do so without using eval to "assemble" the function string to be executed
  3. Ok let me explain a bit further... In my database I store the function name and its parameters (which can be a variable amount of parameters). I then do: sizeof($Parameters) - and know from this how many parameters to put into call_user_func() - the only problem is I don't want to have to do "switch" statement based on the number of parameters... I'd like to do, if possible: call_user_func($functionName, $field1 (if field 1 exists), $field2 (if field 2 exists))
  4. I don't want to do it that way as I mentioned. No using func_get_args - for me to do that I'd have to change my functions structures site-wide which, for me is a lot of functions.
  5. Hello, How to do this more efficiently, without using eval(); and without passing the parameters as an array into the function - I need to call the function in its usual structure: $functionName = "functionName"; $field1 = "firstFunctionParameterValue"; $field2 = "secondFunctionParameterValue"; $numberOfParameters = 2; switch ($numberOfParameters){ case "1": call_user_func($functionName, $field1); break; case "2": call_user_func($functionName, $field1, $field2); break; } So, based on "$numberOfParameters" I'd like to call_user_func() WITH that number of paramaters. Clues? Ideas? Thoughts?
  6. nevermind.. I found this code which does it: $strFromDB = "fcall1();"; eval("\$line = " . $strFromDB); echo $line;
  7. Note: If I try using: eval("echo $mysqlValue"); it only echo's the string of the variable and results in echoing to screen: "myfunction($param1value="1",$param2value="2",$param3value="3");"
  8. $mysqlValue='myfunction($param1value="1",$param2value="2",$param3value="3");'; eval("$mysqlValue"); This works fine... BUT, I want to do: $myfunctionResult = eval("$mysqlValue"); echo $myfunctionResult; ..and it doesn't work??
  9. Hello, In my database I have a field where I store a value such as "myfunction($param1value="1",$param2value="2",$param3value="3");" What I want to do, is to basically use that value and execute the function on a php page, like: $mysqlValue="myfunction($param1value="1",$param2value="2",$param3value="3");"; $mysqlValue(); // only with the parameter values and everything in otherwords, I want to get the following to execute: <?php myfunction($param1value="1",$param2value="2",$param3value="3"); ?> ANY IDEAS? Is this possible? I am aware of variable functions but that doesn't seem to support parameter values in the string(variable)-to-function.
  10. I'm curious, how can I basically set up something like: if (HTTP_HOST!="http://www.alloweddomain.com"){ die("You're using an illegal copy of this script."); } To help protect my scripts. I realize I would need to hide that section of code and even obfuscate it, which I probably can do, but I'm trying to make a "kill switch" for anyone attempting to pirate my scripts.
  11. I hold two statistics in my database, one for "Thumbs Up" and one for "Thumbs Down". Based on the ratio of Thumbs up/down, I want to display a message to the user such as: "You are generous" (mostly thumbs up) or "You are ungenerous" (mostly thumbs down). I have the following math done: $thumbsCombinedTotal=$thumbsUpCount+$thumbsDownCount; $thumbsUpPercentage=round(($thumbsUpCount/$thumbsCombinedTotal)*100,2); However, if the user has thumbs up = 1, and thumbs down = 0 - this will generate a value of 100% so I would say "you are extremely generous". But what I really would like to say is, "you are generous", because they have only voted on 1 thing altogether. Can you think of some more detailed math so I can determine a more accurate description of their "favor in the ratio" (ie. how generous they are actually being?) I need some kind of gradual scale in the math, which means, the more COMBINED thumbsup+thumbsdown they have, the more it will influence the severity of their generousity/ungenerousity. I hope I am clear enough. Thanks a lot to whoever can help me.
  12. sasa you rock, it works! I really appreciate this!
  13. Does anyone have any idea how? I really need to figure it out
  14. Thanks premiso, I had planned to use the database field as the fall-back idea. I just wasn't sure if it was possible to determine anothers session. The DB solution is the best option, I agree.
×
×
  • 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.