Fork me on GitHub

pnVarCleanFromInput - truly baffling!  Bottom

  • Consider this URL:

    /modules.php?op=modload&name=lessons&file=index&req=edit_exercise_form&lesid=58&exid=112

    In my index.php file under the edit_exercise_form function I have the command

    Code

    list ($lesid, $exid) = pnVarCleanFromInput('lesid', 'exid');


    It works just fine. $lesid and $exid are returned correctly. Now consider this URL:

    modules.php?op=modload&name=lessons&file=index&req=edit_lesson_form&lesid=58

    In index.php under the edit_lesson_form function I have the command

    Code

    list ($lesid) = pnVarCleanFromInput('lesid');


    Here is where it gets weird and where I need some major expertise from someone in here. What gets returned as $lesid is always just the first digit. So if $ lesid is 58 then it gets returned as 5 even though the first URL correctly returns it as 58.

    The two urls come right after one another and use the same variable for creating the URL.

    One URL is

    Code

    <a href=\"$urlinsfunc=edit_lesson_form&amp;lessonid=$lessonid\">


    and the other is

    Code

    <a href=\"$urlinsfunc=edit_exercise_form&amp;lesid=$lessonid&amp;exid=$exid\">




    What could be happening here??? I am running .764.

    thanks,

    brian
  • There's nothing wrong with pnVarCleanFromInput()...

    The php language construct list() expects an array which is what pnVarCleanFromInput() returns when handed more than one variable. If pnVarCleanFromInput() only gets one variable passed to it it returns a single variable making list() inappropriate for that situation. So for single vars just do:

    Code

    $lesid = pnVarCleanFromInput('lesid');


    --
    Under Construction!
  • Thanks!! That fixed it!!!
  • Brian,

    The key thing to understand is that, from a programming perspective, a string is an array of characters hence list breaks a string up like it does.

    -Mark

    --
    Visit My homepage and Zikula themes.

This list is based on users active over the last 60 minutes.