SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Undefined variable: query in......

    I don't know how to fix this --

    -- Undefined variable: query in c:\domains\clickonmyspace.com\wwwroot\poll\includes\functions.php on line 109 --

    the line in funtion.php is

    -- <form name=\"sondaggio\" method=\"post\" action=\"".$currentFile.$query."\">
    <table style=\"border: ".$border."px solid #000000; width: ".$width."px; padding: ".$cellpadding."px ".$cellpadding."px ".$cellpadding."px ".$cellpadding."px; background-color: ".$bgColor.";\">
    <!-- QUESTION -->
    <tr><td colspan=\"2\" style=\"text-align: ".$questionAlign."; background-color: ".$questionBgColor."; font-family: ".$font.",Arial; font-size: ".$questionSize."px; color: ".$questionColor.";\">$question</td></tr>"; --

    and I have the same problem in admin -

    -- variable: currentFile in....

    The line is this one -

    -- <div class=\"menu\"><strong>.: MainMenu /strong>&nbsp;&nbsp;<a href=\"$currentFile?flag=wizard\">new poll</a> | <a href=\"$currentFile?flag=cp\">view/edit current poll</a> | <a href=\"$currentFile?flag=help\">help</a> | <a href=\"$currentFile?flag=about\">?</a></div> --

    Please help

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    It appears you aren't defining the variables before calling them.
    Can you post more of the code and put it in [ php ] [/ php ] tags (without the spaces.

    CHeers

    Spike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how I do that?
    I'm new here

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [ php ]


    your php code goes here

    [ /php ]

    but make the tags without spaces....like [php]



    where do these variables come from?
    $currentFile
    $query

    php is telling you they dont exist.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is functions.php

    PHP Code:
    function pollForm(&$dbTXT) {

        global 
    $border,$width,$cellpadding,$questionAlign,$questionBgColor,
               
    $font,$answerSize,$optionColor,$optionsAlign,$bgColor,$oddBgColor,
               
    $evenBgColor,$questionSize,$questionColor;

            
    $currentFile$_SERVER["SCRIPT_NAME"];
            if ( isset(
    $_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']!="" $query="?".$_SERVER['QUERY_STRING'];

            
    $numAnswers $dbTXT->get('numAnswers''MAIN');
        
    $question $dbTXT->get('question''MAIN');
        
    $totVoti votiTotali($dbTXT);
        
           if ( isset(
    $_COOKIE['poll4all']) && $_COOKIE['poll4all']==) print "<div style=\"text-align: center;\">- Cookie resetted -</div>";

            echo 
    "<!-- Poll Form Table -->
              <form name=\"sondaggio\" method=\"post\" action=\""
    .$currentFile.$query."\">
                  <table style=\"border: "
    .$border."px solid #000000; width: ".$width."px; padding: ".$cellpadding."px ".$cellpadding."px ".$cellpadding."px ".$cellpadding."px; background-color: ".$bgColor.";\">
              <!-- QUESTION -->
              <tr><td colspan=\"2\" style=\"text-align: "
    .$questionAlign."; background-color: ".$questionBgColor."; font-family: ".$font.",Arial; font-size: ".$questionSize."px; color: ".$questionColor.";\">$question</td></tr>";

            for (
    $i=1$i<=$numAnswers$i++) {
            
    $anKey "an".$i;
            
    $answer $dbTXT->get($anKey'ANSWERS');
                    if ( 
    $i&$bgColor $oddBgColor;
                    else        
    $bgColor $evenBgColor;

            echo  
    "<!-- Answers -->
               <tr><td style=\"width: "
    .($width-10)."px; text-align: ".$optionsAlign."; border-style: solid; border-width: 0px; margin: 0px 0px 0px 0px; font-size: ".$answerSize."px; background-color: ".$bgColor.";\">$answer</td>
               <td style=\"width: 10px; border-style: solid; border-width: 0px; margin: 0px 0px 0px 0px; background-color: "
    .$bgColor.";\"><input type=\"radio\" name=\"voto\" value=\"$i\" /></td>
               </tr>"
    ;
            }
                  
            echo 
    "<!-- Submit Button -->
              <tr><td colspan=\"2\" style=\"text-align: center; width: "
    .$width."px; padding: 5px 5px 0px 5px;\">
              <input type=\"submit\" name=\"submit\" value=\">> cast my vote <<\" /></td>
              </tr></table></form>"


  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is on admin.php

    PHP Code:
    function stampa_header() {


                    echo 
    "  
                    <div class=\"boxHeader\">

                    <!-- titolo -->
                    <div class=\"logo\"><a href=\"http://www.code4fun.org\">POLL4ALL</a><br /><span class=\"testo\">[v.1.1]</span></div>

                    <!-- Menu -->
                    <div class=\"menu\"><strong>.: MainMenu :</strong>&nbsp;&nbsp;<a href=\"
    $currentFile?flag=wizard\">new poll</a> | <a href=\"$currentFile?flag=cp\">view/edit current poll</a> | <a href=\"$currentFile?flag=help\">help</a> | <a href=\"$currentFile?flag=about\">?</a></div>

                    </div>"
    ;




  7. #7
    SitePoint Addict CommanderZ's Avatar
    Join Date
    Apr 2006
    Location
    Czech Republic
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess browser could not get the value from QUERY_STRING, Try to put

    PHP Code:
    if(empty($query)) $query=""
    command next to the line where you are getting the value from QUERY_STRING

  8. #8
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    variables do not exist inside a function until you either:
    -manually define them
    -import them into the functions scope using the global keyword

    superglobals are available inside a function though($_GET, $_POST etc..)

    http://us2.php.net/variables.scope

  9. #9
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where do these variables come from?
    $currentFile
    $query

    php is telling you they dont exist.
    I don't know whrere they come from, this is a free source I am trying to install in my website, but I don't know to much about PHP or programing.....

  10. #10
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It worked thanks...
    But I still have the two in admin.php which I think are Undefined variable:$currentFile

    Thanks...

  11. #11
    SitePoint Addict CommanderZ's Avatar
    Join Date
    Apr 2006
    Location
    Czech Republic
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You must declare them as global as clamcrusher said

  12. #12
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the comment CommanderZ, but as I said before I don't know to much about PHP or programing.....
    if you can tell me what is the code I have to paste and where I will be more than glad.
    Thanks for the help so far guys.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •