undefined index

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anfetienne
    Contributor
    • Feb 2009
    • 424

    undefined index

    i take information from a database and then have the collected values entered into a form with hidden fields.

    Code:
      <input type="hidden" name="tempID" id="tempID" value='<?php print $random_digit;?>'/> 
      <input type="hidden" name="htmlcss" id="htmlcss" value='<?php print $htmlcss;?>'/>      
      <input type="hidden" name="header" id="header" value='<?php print $header;?>'/>
      <input type="hidden" name="nav" id="nav" value='<?php print $nav;?>'/>      
      <input type="hidden" name="titleWrap01" id="titleWrap01" value='<?php print $titleWrap01;?>'/> 
      <input type="hidden" name="titleWrap02" id="titleWrap02" value='<?php print $titleWrap02;?>'/>      
      <input type="hidden" name="subheadWrap01" id="subheadWrap01" value='<?php print $subheadWrap01;?>'/>
      <input type="hidden" name="subheadWrap02" id="subheadWrap02" value='<?php print $subheadWrap02;?>'/>      
      <input type="hidden" name="flashWrap01" id="flashWrap01" value='<?php print $flashWrap01;?>'/> 
      <input type="hidden" name="flashWrap02" id="flashWrap02" value='<?php print $flashWrap02;?>'/>      
      <input type="hidden" name="flash01" id="flash01" value='<?php print $flashURL;?>'/>
      <input type="hidden" name="flashVar" id="flashVar" value='<?php print $flashVar;?>'/>      
      <input type="hidden" name="flash02" id="flash02" value='<?php print $flash02;?>'/> 
      <input type="hidden" name="flashWrap03" id="flashWrap03" value='<?php print $flashWrap03;?>'/>      
      <input type="hidden" name="descriptionWrap01" id="descriptionWrap01" value='<?php print $descriptionWrap01;?>'/>
      <input type="hidden" name="descriptionWrap02" id="descriptionWrap02" value='<?php print $descriptionWrap02;?>'/>      
      <input type="hidden" name="generalWrap01" id="generalWrap01" value='<?php print $generalWrap01;?>'/> 
      <input type="hidden" name="generalWrap02" id="generalWrap02" value='<?php print $generalWrap02;?>'/>      
      <input type="hidden" name="aboutWrap01" id="aboutWrap01" value='<?php print $aboutWrap01;?>'/>
      <input type="hidden" name="aboutWrap02" id="aboutWrap02" value='<?php print $aboutWrap02;?>'/>      
      <input type="hidden" name="paymentWrap01" id="paymentWrap01" value='<?php print $paymentWrap01;?>'/> 
      <input type="hidden" name="paymentWrap02" id="paymentWrap02" value='<?php print $paymentWrap02;?>'/>
      <input type="hidden" name="termsWrap01" id="termsWrap01" value='<?php print $termsWrap01;?>'/>      
      <input type="hidden" name="termsWrap02" id="termsWrap02" value='<?php print $termsWrap02;?>'/>
      <input type="hidden" name="footer" id="footer" value='<?php print $footer;?>'/>
    when i submit the form with all the other text fields filled out......then in the file to save it to a database it brings up the error....."unde fined index" although i only have 1 index set.

    Code:
    <?PHP error_reporting(E_ALL);
    $username="tempsUser";
    $password="auction";
    $database="auctionTemps";
    
    $returnURL = $_POST['returnURL'];
    
    $tempID=$_POST['tempID'];
    $htmlcss=$_POST['htmlcss'];
    $header=$_POST['header'];
    $nav=$_POST['nav'];
    $titleWrap01=$_POST['titleWrap01'];
    $title=$_POST['title'];
    $titleWrap02=$_POST['titleWrap02'];
    $subheadWrap01=$_POST['subheadWrap01'];
    $subheading=$_POST['subheading'];
    $subheadWrap02=$_POST['subheadWrap02'];
    $flashWrap01=$_POST['flashWrap01'];
    $flashWrap02=$_POST['flashWrap02'];
    $flash01=$_POST['flash01'];
    $flashVar=$_POST['flashVar'];
    $flash02=$_POST['flash02'];
    $flashWrap03=$_POST['flashWrap03'];
    $descriptionWrap01=$_POST['descriptionWrap01'];
    $description=$_POST['description'];
    $descriptionWrap02=$_POST['descriptionWrap02'];
    $generalWrap01=$_POST['generalWrap01'];
    $general=$_POST['general'];
    $generalWrap02=$_POST['generalWrap02'];
    $aboutWrap01=$_POST['aboutWrap01'];
    $about=$_POST['about'];
    $aboutWrap02=$_POST['aboutWrap02'];
    $paymentWrap01=$_POST['paymentWrap01'];
    $payment01=$_POST['payment01'];
    $payment02=$_POST['payment02'];
    $paymentWrap02=$_POST['paymentWrap02'];
    $termsWrap01=$_POST['termsWrap01'];
    $terms=$_POST['terms'];
    $termsWrap02=$_POST['termsWrap02'];
    $footer=$_POST['footer'];
    ?>
    
    <?
    
    // OPEN CONNECTION ---> 
    $connection=mysql_connect("localhost" ,"$username", "$password") or die("Unable to connect!");
    
    mysql_select_db("$database") or die("Unable to select database!");
    
    //  EXECUTE QUERY ---> 
    $query="INSERT savedTemps (
    
    		    tempID, 
    		    htmlcss, 
                header, 
                nav, 
                titleWrap01, 
                title,
    			titleWrap02,
                subheadWrap01, 
                subheading,
    			subheadWrap02, 
                flashWrap01, 	
                flashWrap02, 
                flash01, 
                flashVar,
                flash02, 
                flashWrap03,
    			descriptionWrap01,
                description, 
                descriptionWrap02,
    			generalWrap01, 
                general, 
                generalWrap02, 
    			aboutWrap01,
                about, 
                aboutWrap02,
    			paymentWrap01, 
                payment01, 
                payment02, 
                paymentWrap02,
                termsWrap01, 
                terms, 
                termsWrap02,
    			footer)
    
            VALUES(	
    		    '$tempID', 
    		    '$htmlcss', 
                '$header', 
                '$nav.', 
                '$titleWrap01', 
                '$title',
    			'$titleWrap02',
                '$subheadWrap01', 
                '$subheading',
    			'$subheadWrap02', 
                '$flashWrap01', 	
                '$flashWrap02', 
                '$flash01', 
                '$flashVar', 
                '$flash02', 
                '$flashWrap03',
    			'$descriptionWrap01',
                '$description', 
                '$descriptionWrap02',
    			'$generalWrap01', 
                '$general', 
                '$generalWrap02', 
    			'$aboutWrap01',
                '$about', 
                '$aboutWrap02',
    			'$paymentWrap01', 
                '$payment01', 
                '$payment02', 
                '$paymentWrap02',
                '$termsWrap01', 
                '$terms', 
                '$termsWrap02',
    			'$footer')";
    			$result=mysql_query($query) or die("Error in query:".mysql_error()); 
    
    
    //  CLOSE CONNECTION ---> 
    mysql_close($connection); 
    
    //
    
    ?>
    <script language="JavaScript">
    <!--
    window.location="<? print $returnURL?>";
    //-->
    </SCRIPT>
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Thread moved to PHP Forum.

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Cheers, mwasif.

      You're receiving an undefined index error because you're looking (in an array) for a value that doesn't exist. Maybe you've written a typo? I don't have time to check the to files.

      The error will give you a line number, if you show us it, we can point out the specific error and give you a fix.

      - Mark.

      Comment

      • anfetienne
        Contributor
        • Feb 2009
        • 424

        #4
        it says there is a error with these lines

        # $returnURL = $_POST['returnURL'];
        #
        # $tempID=$_POST['tempID'];
        # $htmlcss=$_POST['htmlcss'];
        # $header=$_POST['header'];
        # $nav=$_POST['nav'];
        # $titleWrap01=$_ POST['titleWrap01'];
        # $title=$_POST['title'];
        # $titleWrap02=$_ POST['titleWrap02'];
        # $subheadWrap01= $_POST['subheadWrap01'];
        # $subheading=$_P OST['subheading'];
        # $subheadWrap02= $_POST['subheadWrap02'];
        # $flashWrap01=$_ POST['flashWrap01'];
        # $flashWrap02=$_ POST['flashWrap02'];
        # $flash01=$_POST['flash01'];
        # $flashVar=$_POS T['flashVar'];
        # $flash02=$_POST['flash02'];
        # $flashWrap03=$_ POST['flashWrap03'];
        # $descriptionWra p01=$_POST['descriptionWra p01'];
        # $description=$_ POST['description'];
        # $descriptionWra p02=$_POST['descriptionWra p02'];
        # $generalWrap01= $_POST['generalWrap01'];
        # $general=$_POST['general'];
        # $generalWrap02= $_POST['generalWrap02'];
        # $aboutWrap01=$_ POST['aboutWrap01'];
        # $about=$_POST['about'];
        # $aboutWrap02=$_ POST['aboutWrap02'];
        # $paymentWrap01= $_POST['paymentWrap01'];
        # $payment01=$_PO ST['payment01'];
        # $payment02=$_PO ST['payment02'];
        # $paymentWrap02= $_POST['paymentWrap02'];
        # $termsWrap01=$_ POST['termsWrap01'];
        # $terms=$_POST['terms'];
        # $termsWrap02=$_ POST['termsWrap02'];
        # $footer=$_POST['footer'];

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          OK. What method are you using for your form? (method=" ... ")

          Comment

          • anfetienne
            Contributor
            • Feb 2009
            • 424

            #6
            i am using the post method

            Comment

            • anfetienne
              Contributor
              • Feb 2009
              • 424

              #7
              i really appreciate the help but i dont want you to tell me the answer.....if you could tell me where i went wrong and show me a site that has a tutorial for picking a specif row by searching for a certain thing that would be great and ill try get it to work......it enters it into the database just fine but i get an undefined index error and then i get a lot of blank spaces and full stops in the database after row 1

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                Can I see the full form please? It appears you're either naming them (the post array indices) wrong or you're not sumbiting the form correctly.

                Comment

                • anfetienne
                  Contributor
                  • Feb 2009
                  • 424

                  #9
                  this is the full form code with the database details as well

                  Code:
                  <?
                  $username="tempsUser";
                  $password="auction";
                  $database="auctionTemps";
                  
                  mysql_connect(localhost,$username,$password);
                  @mysql_select_db($database) or die( "Unable to select database");
                  $query="SELECT * FROM templates";
                  $result=mysql_query($query);
                  
                  mysql_close();
                  ?>
                  <?
                  $i= "$templateID";
                  
                  $htmlcss=mysql_result($result,$i,"htmlcss");
                  $header=mysql_result($result,$i,"header");
                  $nav=mysql_result($result,$i,"nav");
                  $titleWrap01=mysql_result($result,$i,"titleWrap01");
                  $titleWrap02=mysql_result($result,$i,"titleWrap02");
                  $subheadWrap01=mysql_result($result,$i,"subheadWrap01");
                  $subheadWrap02=mysql_result($result,$i,"subheadWrap02");
                  $flashWrap01=mysql_result($result,$i,"flashWrap01");
                  $flashWrap02=mysql_result($result,$i,"flashWrap02");
                  $flashVar=mysql_result($result,$i,"flashVar");
                  $flash02=mysql_result($result,$i,"flash02");
                  $flashWrap03=mysql_result($result,$i,"flashWrap03");
                  $descriptionWrap01=mysql_result($result,$i,"descriptionWrap01");
                  $descriptionWrap02=mysql_result($result,$i,"descriptionWrap02");
                  $generalWrap01=mysql_result($result,$i,"generalWrap01");
                  $generalWrap02=mysql_result($result,$i,"generalWrap02");
                  $aboutWrap01=mysql_result($result,$i,"aboutWrap01");
                  $aboutWrap02=mysql_result($result,$i,"aboutWrap02");
                  $paymentWrap01=mysql_result($result,$i,"paymentWrap01");
                  $paymentWrap02=mysql_result($result,$i,"paymentWrap02");
                  $termsWrap01=mysql_result($result,$i,"termsWrap01");
                  $termsWrap02=mysql_result($result,$i,"termsWrap02");
                  $footer=mysql_result($result,$i,"footer");
                  ?>
                  <?
                  $flashURL="http://theauctionwinners.com/resources/upload/$random_digit/gallery.swf";
                  ?>
                  
                    <form id="form1" name="form1" method="post" action="save.php">
                          <tr>
                          <td>  
                    <input type="hidden" name="returnURL" id="returnURL" value="<?php print $returnURL;?>"/>      
                    <input type="hidden" name="tempID" id="tempID" value='<?php print $random_digit;?>'/> 
                    <input type="hidden" name="htmlcss" id="htmlcss" value='<?php print $htmlcss;?>'/>      
                    <input type="hidden" name="header" id="header" value='<?php print $header;?>'/>
                    <input type="hidden" name="nav" id="nav" value='<?php print $nav;?>'/>      
                    <input type="hidden" name="titleWrap01" id="titleWrap01" value='<?php print $titleWrap01;?>'/> 
                    <input type="hidden" name="titleWrap02" id="titleWrap02" value='<?php print $titleWrap02;?>'/>      
                    <input type="hidden" name="subheadWrap01" id="subheadWrap01" value='<?php print $subheadWrap01;?>'/>
                    <input type="hidden" name="subheadWrap02" id="subheadWrap02" value='<?php print $subheadWrap02;?>'/>      
                    <input type="hidden" name="flashWrap01" id="flashWrap01" value='<?php print $flashWrap01;?>'/> 
                    <input type="hidden" name="flashWrap02" id="flashWrap02" value='<?php print $flashWrap02;?>'/>      
                    <input type="hidden" name="flash01" id="flash01" value='<?php print $flashURL;?>'/>
                    <input type="hidden" name="flashVar" id="flashVar" value='<?php print $flashVar;?>'/>      
                    <input type="hidden" name="flash02" id="flash02" value='<?php print $flash02;?>'/> 
                    <input type="hidden" name="flashWrap03" id="flashWrap03" value='<?php print $flashWrap03;?>'/>      
                    <input type="hidden" name="descriptionWrap01" id="descriptionWrap01" value='<?php print $descriptionWrap01;?>'/>
                    <input type="hidden" name="descriptionWrap02" id="descriptionWrap02" value='<?php print $descriptionWrap02;?>'/>      
                    <input type="hidden" name="generalWrap01" id="generalWrap01" value='<?php print $generalWrap01;?>'/> 
                    <input type="hidden" name="generalWrap02" id="generalWrap02" value='<?php print $generalWrap02;?>'/>      
                    <input type="hidden" name="aboutWrap01" id="aboutWrap01" value='<?php print $aboutWrap01;?>'/>
                    <input type="hidden" name="aboutWrap02" id="aboutWrap02" value='<?php print $aboutWrap02;?>'/>      
                    <input type="hidden" name="paymentWrap01" id="paymentWrap01" value='<?php print $paymentWrap01;?>'/> 
                    <input type="hidden" name="paymentWrap02" id="paymentWrap02" value='<?php print $paymentWrap02;?>'/>
                    <input type="hidden" name="termsWrap01" id="termsWrap01" value='<?php print $termsWrap01;?>'/>      
                    <input type="hidden" name="termsWrap02" id="termsWrap02" value='<?php print $termsWrap02;?>'/>
                    <input type="hidden" name="footer" id="footer" value='<?php print $footer;?>'/> 
                    </td>
                        </tr>
                  
                      <table width="700" border="0" align="center" cellpadding="2" cellspacing="2">
                        <tr>
                          <td width="177">Template</td>
                          <td><select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
                            <option>item1</option>
                          </select></td>
                        </tr>
                        <tr>
                          <td>Title</td>
                          <td><input name="title"  type="text" value="" size="75" maxlength="60" /></td>
                        </tr>
                        <tr>
                          <td>Subtitle</td>
                          <td><input name="subheading"  type="text" value="" size="75" /></td>
                        </tr>
                        <tr>
                          <td>Description</td>
                              						<script type="text/javascript">
                  							tinyMCE.init({
                  								mode : "exact"
                  								,elements : "id_description"
                  								,theme : "advanced"
                  								,theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,formatselect,fontselect,fontsizeselect"
                  								,theme_advanced_buttons2 : "cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,image,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,code,fullscreen"
                  								,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,"
                  								,theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor"
                  								,theme_advanced_toolbar_location : "top"
                  								,theme_advanced_toolbar_align : "left"
                  								,theme_advanced_statusbar_location : "bottom"
                  								,theme_advanced_resizing : true
                  								,theme_advanced_resize_horizontal : false
                  								,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups"
                  							});
                  						</script>
                          <td><textarea name="description" cols="75" id="id_description" style="width:450px; height:350px;"></textarea></td>
                        </tr>
                        <tr>
                          <td>General Information</td>
                              						<script type="text/javascript">
                  							tinyMCE.init({
                  								mode : "exact"
                  								,elements : "id_general"
                  								,theme : "advanced"
                  								,theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,formatselect,fontselect,fontsizeselect"
                  								,theme_advanced_buttons2 : "cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,image,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,code,fullscreen"
                  								,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,"
                  								,theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor"
                  								,theme_advanced_toolbar_location : "top"
                  								,theme_advanced_toolbar_align : "left"
                  								,theme_advanced_statusbar_location : "bottom"
                  								,theme_advanced_resizing : true
                  								,theme_advanced_resize_horizontal : false
                  								,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups"
                  							});
                  						</script>
                          <td><textarea style="width:450px; height:350px;" id="id_general" name="general"></textarea></td>
                        </tr>
                        <tr>
                          <td>Terms &amp; Conditions</td>
                  							<script type="text/javascript">
                  							tinyMCE.init({
                  								mode : "exact"
                  								,elements : "id_terms"
                  								,theme : "advanced"
                  								,theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,formatselect,fontselect,fontsizeselect"
                  								,theme_advanced_buttons2 : "cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,image,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,code,fullscreen"
                  								,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,"
                  								,theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor"
                  								,theme_advanced_toolbar_location : "top"
                  								,theme_advanced_toolbar_align : "left"
                  								,theme_advanced_statusbar_location : "bottom"
                  								,theme_advanced_resizing : true
                  								,theme_advanced_resize_horizontal : false
                  								,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups"
                  							});
                  						</script>
                          <td><textarea style="width:450px; height:350px;" id="id_terms" name="terms"></textarea></td>
                        </tr>
                        <tr>
                          <td>About Us</td>
                          <script type="text/javascript">
                  							tinyMCE.init({
                  								mode : "exact"
                  								,elements : "id_about"
                  								,theme : "advanced"
                  								,theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,formatselect,fontselect,fontsizeselect"
                  								,theme_advanced_buttons2 : "cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,image,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,code,fullscreen"
                  								,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,"
                  								,theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor"
                  								,theme_advanced_toolbar_location : "top"
                  								,theme_advanced_toolbar_align : "left"
                  								,theme_advanced_statusbar_location : "bottom"
                  								,theme_advanced_resizing : true
                  								,theme_advanced_resize_horizontal : false
                  								,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups"
                  							});
                  						</script>
                          <td><textarea style="width:450px; height:350px;" id="id_about" name="about"></textarea></td>
                        </tr>
                        <tr>
                          <td>Payment Methods</td>
                          <td>PayPal 
                            <label>
                            <input type="checkbox" name="payment01" id="payment01" value="<img src=http://theauctionwinners.com/resources/temp/paypal.gif>"/>
                            <br />
                            Personal Cheques 
                            <br />
                            <input type="checkbox" name="payment02" id="payment02" value="<img src=http://theauctionwinners.com/resources/temp/cheque.gif>"/>
                          </label></td>
                        </tr>
                        <tr>
                          <td colspan="2"><div align="center">
                            <input name="Submit" type="submit" value="Save" />
                          </div></td>
                        </tr>    
                  </form>

                  Comment

                  • Markus
                    Recognized Expert Expert
                    • Jun 2007
                    • 6092

                    #10
                    On save.php do a print_r() of your POST data, to see if the POST array is being populated with the form details.

                    Code:
                    print( '<pre>' );
                    print_r( $_POST );
                    print( '</pre>' );

                    Comment

                    • anfetienne
                      Contributor
                      • Feb 2009
                      • 424

                      #11
                      i've done as you said and the post array is being populated with the form data but i still get the error of undefined index.....i've even defined an index and i still get the error message of undefined index

                      Comment

                      Working...