Undefined variable

Hier könnt Ihr fragen zu PHP Scriptproblemen diskutieren. Auch Anfängerfragen in Sachen PHP können hier gestellt werden.

Undefined variable

Beitragvon kiatrro am Mo, 11:13:18 15.03.10

Hallo, bekomme folgende Fehlerausgabe:

Notice: Undefined variable: thispager in /homepages/htdocs/chat/template/index.tpl.html on line 93

Zeile lautet: <?php echo $thispager;?>

Bin mit Programmierung nicht so vertraut aber vielleicht kann mir jemand helfen.

Sowie ich gelesen habe muß der Code irgentwie umgeschrieben werden für die Funktion.
kiatrro
Newbi
 
Beiträge: 2
Registriert: Mo, 11:09:02 15.03.10

Re: Undefined variable

Beitragvon -Dark-Emperor- am Sa, 18:18:37 20.03.10

also soweit wie ich das von der einen zeile sagen kann würde ich meinen das du die variable voher nirgends deffiniert hast!
es würde aber bestimmt allen helfen wenn du den ganzen teil vor der zeile mit angibst!
am besten mit dem code-befehl!
-Dark-Emperor-
Newbi
 
Beiträge: 3
Registriert: Sa, 14:47:53 20.03.10
Wohnort: Dresden

Re: Undefined variable

Beitragvon kiatrro am Mo, 10:31:24 22.03.10

Hoffe das hilft etwas weiter:

<td width="662" valign="top">
<div id="header_shadow"></div>
<div id="content">
<table width="624" height="752" border="0" align="center" cellpadding="0" cellspacing="12" style="position:relative; top:-12px;">
<tr>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[0])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[0])) echo $thispics[0];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[0])) echo $thisusernames[0];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[0])) echo $thisregions[0];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[0])) echo $thisflirttext[0];?></div>
<?php if (isset($thisid[0])) echo '<a onMouseOver="javascript: over(\''.$thisid[0].'\');" onMouseOut="javascript: out(\''.$thisid[0].'\');" href="index.php?f=show_profile&p='.$thisid[0].'"><div class="click" id="'.$thisid[0].'"></div></a>';?>
</div>
</td>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[1])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[1])) echo $thispics[1];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[1])) echo $thisusernames[1];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[1])) echo $thisregions[1];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[1])) echo $thisflirttext[1];?></div>
<?php if (isset($thisid[1])) echo '<a onMouseOver="javascript: over(\''.$thisid[1].'\');" onMouseOut="javascript: out(\''.$thisid[1].'\');" href="index.php?f=show_profile&p='.$thisid[1].'"><div class="click" id="'.$thisid[1].'"></div></a>';?>
</div>
</td>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[2])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[2])) echo $thispics[2];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[2])) echo $thisusernames[2];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[2])) echo $thisregions[2];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[2])) echo $thisflirttext[2];?></div>
<?php if (isset($thisid[2])) echo '<a onMouseOver="javascript: over(\''.$thisid[2].'\');" onMouseOut="javascript: out(\''.$thisid[2].'\');" href="index.php?f=show_profile&p='.$thisid[2].'"><div class="click" id="'.$thisid[2].'"></div></a>';?>
</div>
</td>
</tr>
<tr>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[3])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[3])) echo $thispics[3];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[3])) echo $thisusernames[3];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[3])) echo $thisregions[3];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[3])) echo $thisflirttext[3];?></div>
<?php if (isset($thisid[3])) echo '<a onMouseOver="javascript: over(\''.$thisid[3].'\');" onMouseOut="javascript: out(\''.$thisid[3].'\');" href="index.php?f=show_profile&p='.$thisid[3].'"><div class="click" id="'.$thisid[3].'"></div></a>';?>
</div>
</td>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[4])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[4])) echo $thispics[4];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[4])) echo $thisusernames[4];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[4])) echo $thisregions[4];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[4])) echo $thisflirttext[4];?></div>
<?php if (isset($thisid[4])) echo '<a onMouseOver="javascript: over(\''.$thisid[4].'\');" onMouseOut="javascript: out(\''.$thisid[4].'\');" href="index.php?f=show_profile&p='.$thisid[4].'"><div class="click" id="'.$thisid[4].'"></div></a>';?>
</div>
</td>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[5])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[5])) echo $thispics[5];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[5])) echo $thisusernames[5];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[5])) echo $thisregions[5];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[5])) echo $thisflirttext[5];?></div>
<?php if (isset($thisid[5])) echo '<a onMouseOver="javascript: over(\''.$thisid[5].'\');" onMouseOut="javascript: out(\''.$thisid[5].'\');" href="index.php?f=show_profile&p='.$thisid[5].'"><div class="click" id="'.$thisid[5].'"></div></a>';?>
</div>
</td>
</tr>
<tr>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[6])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[6])) echo $thispics[6];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[6])) echo $thisusernames[6];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[6])) echo $thisregions[6];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[6])) echo $thisflirttext[6];?></div>
<?php if (isset($thisid[6])) echo '<a onMouseOver="javascript: over(\''.$thisid[6].'\');" onMouseOut="javascript: out(\''.$thisid[6].'\');" href="index.php?f=show_profile&p='.$thisid[6].'"><div class="click" id="'.$thisid[6].'"></div></a>';?>
</div>
</td>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[7])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[7])) echo $thispics[7];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[7])) echo $thisusernames[7];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[7])) echo $thisregions[7];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[7])) echo $thisflirttext[7];?></div>
<?php if (isset($thisid[7])) echo '<a onMouseOver="javascript: over(\''.$thisid[7].'\');" onMouseOut="javascript: out(\''.$thisid[7].'\');" href="index.php?f=show_profile&p='.$thisid[7].'"><div class="click" id="'.$thisid[7].'"></div></a>';?>
</div>
</td>
<td height="249" valign="top" width="208" <?php if (isset($thisusernames[8])) echo 'class="profile"';?>>
<div class="wrapper">
<div class="profile_pic_small" align="center"><?php if(isset($thispics[8])) echo $thispics[8];?></div>
<div class="profile_card_heading" align="center"><?php if (isset($thisusernames[8])) echo $thisusernames[8];?></div>
<div class="profile_card_region" align="center"><?php if (isset($thisregions[8])) echo $thisregions[8];?></div>
<div class="profile_card_flirttext" align="center"><?php if (isset($thisflirttext[8])) echo $thisflirttext[8];?></div>
<?php if (isset($thisid[8])) echo '<a onMouseOver="javascript: over(\''.$thisid[8].'\');" onMouseOut="javascript: out(\''.$thisid[8].'\');" href="index.php?f=show_profile&p='.$thisid[8].'"><div class="click" id="'.$thisid[8].'"></div></a>';?>
</div>
</td>
</tr>
</table>
<?php echo $thispager;?>
</div>
</td>


Code Befehl:

$thispager = '';
$thispager .= '<table width="100%" valign="top" align="center" border="0" cellspacing="0" cellpadding="0" style="position:relative; top:-10px;">
<tr>
<td align="left" valign="top" height="10" width="125" style="line-height:1;">'.( $page!=0 ? '<a href="index.php?f=webmaster&page=0'.$page_req.$pager_sort.'"><img src="../template/images/general/pager_start.jpg" border="0" align="middle"></a>' : '' ).'&nbsp;&nbsp;'.( $page>0 ? '<a href="index.php?f=webmaster&page='.($page-1).$page_req.$pager_sort.'"><img src="../template/images/general/pager_back.jpg" border="0" align="middle"></a>' : '' ).'</td>
<td width="400" valign="top" align="center" style="line-height:1;"><center><span class="contenttext">'.L_PAGINA_PAGE.' '.$page_sel.'</span></center></td>
<td align="right" valign="top" width="125" style="line-height:1;">
<div style="text-align:right;">'.( $page<$page_cnt ? '<a href="index.php?f=webmaster&page='.($page+1).$page_req.$pager_sort.'"><img src="../template/images/general/pager_next.jpg" border="0" align="middle"></a>' : '' ).'&nbsp;&nbsp;'.( $page!=$page_cnt ? '<a href="index.php?f=webmaster&page='.$page_cnt.$page_req.$pager_sort.'"><img src="../template/images/general/pager_end.jpg" border="0" align="middle"></a>' : '' ).'</div></td>
</tr></table>';
kiatrro
Newbi
 
Beiträge: 2
Registriert: Mo, 11:09:02 15.03.10

Re: Undefined variable

Beitragvon Marcel am Do, 11:22:41 1.04.10

Da die Variable nicht definiert ist, entweder irgendwo vorher (auch Zentral möglich) definieren mit einer Standard Zuweisung.

Oder solch ein Konstrukt verwenden:
  1. <?php echo (isset($thispager))? $thispager : '';?>

Das bläht bei einer Verwendung von vielen Variablen den Code auf.
MfG
Marcel
Marcel
Member
 
Beiträge: 542
Registriert: Di, 16:13:41 3.01.06

Zurück zu PHP Hilfe



cron