未定义的索引:template_id

时间:2015-04-16 06:27:34

标签: php ajax

我是karthik,在我的项目中我有一个问题,我得到错误取消定义索引:template_id。我已经在网上搜索了更多,但我无法解决这个问题我已经在下面附上了我的代码,请指导我

if($fetquery["template_id"] == 5){

                $query = mysql_query("SELECT * FROM ".$fetquery['table_name']." WHERE template_content_id = ".$fetquery['id']."");

                $fetquery = mysql_fetch_array($query);

             ?>

             <!-- Template5-->

             <input type="hidden" name="template5" value="template5">

    <div class="fillContent" id="subscreen5">    

    <div class="mainTitle"> 

            <h3>Fill Content - Template E</h3> 

        </div>

        <input type="hidden" name="template5id" value="<?php echo $fetquery['temp5_id']; ?>">

        <div class="current-title">  

            <label>Main Title</label> <input type="text" class="fillTitleText" name="etemp5title"placeholder="Lorem Ipsum" value="<?php echo $fetquery['title']; ?>"><!--  <a href="#">Edit</a>  -->

        </div>

        <div class="section2"> 

            <div class="contentSecTitle">

                <h3>Banner Image</h3>

            </div>

            <div class="subSec">                

                <div class="subSec1">  

                    <div class="contentSec2Left">

                                  <input type="text" id="template5banner" value="<?php echo $fetquery['bannerimage']; ?>" class="upLoadText">

             <div class="fileUpload btn btn-primary">

                 <span class="uploadImage"></span> 

                 <input id="temp5_bannerimg" onchange="addtemplate5banner(this)" name="etemplate5bannerimg" type="file" class="upload" value="Browse">

             </div>

                    </div>

                    <div class="contentSecRight"> 

                    <input type="hidden" name="gettopImage" value="<?php echo $fetquery['bannerimage']; ?>">

                          <p class="imageView3"><img src="<?php echo $fetquery['bannerimage']; ?>" style="width:82px; height:82px;" id="changetemp5banner"><br><br>Current Image</p>

                         <!-- <p class="imageView4">filename.jpg</p>

                          <div class="deLete">

                                <a href="" onClick="removetemplate5banner()"></a>

                          </div> 
-->
                    </div>

                 </div>  

             </div> 

        </div>

        <div class="fillSec"> 

            <div class="contentSecTitle">

                <h3>Content</h3>

            </div> 

            <div class="current-textarea">  

                <div class="text-area">

                  <label>Description</label>  <textarea rows="4" name="etemp5desc" ><?php echo $fetquery['description']; ?></textarea>

                </div>



            </div> 

        </div> 

    </div>

    <?php 
}

    if($fetquery["template_id"] == 6){
        //echo "SELECT * FROM ".$fetquery['table_name']." WHERE template_content_id = ".$fetquery['id']."";
        $query = mysql_query("SELECT * FROM ".$fetquery['table_name']." WHERE template_content_id = ".$fetquery['id']."");

        $fetquery = mysql_fetch_array($query);

     ?>

    <!-- Template6-->

    <input type="hidden" name="template6" value="template6">

    <div class="fillContent" id="subscreen6">    

    <div class="mainTitle">

            <h3>Fill Content - Template F</h3> 

        </div>

        <input type="hidden" name="template6id" value="<?php echo $fetquery['temp6_id']; ?>">

        <div class="current-title"> 

            <label>Main Title</label> <input value="<?php echo $fetquery['title']; ?>" type="text" class="fillTitleText" name="etemplate6title" placeholder="Lorem Ipsum">  <!--<a href="#">Edit</a>  -->

        </div>

        <div class="section2">  

            <div class="contentSecTitle">

                <h3>Banner Image</h3>

            </div>

            <div class="subSec">                

                <div class="subSec1">  

                    <div class="contentSec2Left">

                                  <input type="text" id="template6banner" value="<?php echo $fetquery['bannerimage']; ?>" class="upLoadText">

             <div class="fileUpload btn btn-primary">

                 <span class="uploadImage"></span> 

                 <input id="temp6_bannerimg" onchange="addtemplate6banner(this)" name="template6bannerimg" type="file" class="upload" value="Browse">

             </div>

                    </div>

                    <div class="contentSecRight">

                    <input type="hidden" name="gettopImage" value="<?php echo $fetquery['bannerimage']; ?>"> 

                          <p class="imageView3"><img src="<?php echo $fetquery['bannerimage']; ?>" style="width:82px; height:82px;" id="changetemp6banner"><br><br>Current Image</p>

                         <!-- <p class="imageView4">filename.jpg</p>

                          <div class="deLete">

                                <a href="" onClick="removetemplate6banner()"></a>

                          </div> -->

                    </div>

                 </div>  

             </div> 

        </div>

        <div class="fillSec"> 

            <div class="contentSecTitle">

                <h3>Content</h3>

            </div> 

            <div class="current-textarea">  

                <div class="text-area">

                   <label>Desription</label>  <textarea rows="4" name="temp6desc"><?php echo $fetquery['description']; ?></textarea>

                </div>



            </div> 

        </div> 

        </div>

        <?php } ?>

此代码位于ajax页面

1 个答案:

答案 0 :(得分:0)

尝试在使用前添加支票。并检查是否已定义。 -

if (!empty($fetquery["template_id"]) && $fetquery["template_id"] == 5) { ...