Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
pnVarCleanFromInput - truly baffling!
  • Posted: 06.01.2007, 09:18
     
    bhuether
    rank:
    Helper Helper
    registered:
     February 2003
    Status:
    offline
    last visit:
    27.03.08
    Posts:
    152
    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
  • Posted: 06.01.2007, 21:58
     
    Topiatic
    rank:
    Professional Professional
    registered:
     November 2003
    Status:
    online
    Posts:
    1678
    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!
  • Posted: 06.01.2007, 22:33
     
    bhuether
    rank:
    Helper Helper
    registered:
     February 2003
    Status:
    offline
    last visit:
    27.03.08
    Posts:
    152
    Thanks!! That fixed it!!!
  • Posted: 07.01.2007, 17:26
     
    rank:
    Moderator Moderator
    registered:
     March 2002
    Status:
    offline
    last visit:
    26.08.08
    Posts:
    7720
    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

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula