Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
注意:php中用于显示数据库中图像的未定义索引_Php_Html - Fatal编程技术网

注意:php中用于显示数据库中图像的未定义索引

注意:php中用于显示数据库中图像的未定义索引,php,html,Php,Html,我正在用php开发一种社交网络类型的项目,但我在某个地方无意中显示了数据库中的use图像&得到了这个 注意:第19行的C:\wamp\www\collegenetwring\profileleft.php中未定义的索引:usimg profile.php <?php include("header.php"); include("profilesql.php"); include("friends.php"); ?> <center> <div class=con

我正在用php开发一种社交网络类型的项目,但我在某个地方无意中显示了数据库中的use图像&得到了这个

注意:第19行的C:\wamp\www\collegenetwring\profileleft.php中未定义的索引:usimg

profile.php

<?php
include("header.php");
include("profilesql.php");
include("friends.php"); 
?>
<center>
<div class=container>
<div class=container>

<!-- head --><!-- navigation menu -->
<?php include("head.php"); ?>
<?php
include("menu.php"); 
$result = mysql_query("SELECT * FROM profile ORDER BY RAND()");
$i=0;
while($row = mysql_fetch_array($result))
  {
      if($row["userid"] != $_SESSION["stuid"] )
{ 
$img[$i] = $row["image"];
$uid[$i] = $row["userid"];
$city[$i] = $row['city'];
$i++;
  }
  }
  $result = mysql_query("SELECT * FROM stuacc where id");  

$strec = mysql_query("SELECT * FROM stuacc WHERE email='$_SESSION[logid]' ");

while($row = mysql_fetch_array($strec))
  {
$_SESSION["stuid"] =  $row["id"];

  }

$colrec = mysql_query("SELECT * FROM profile WHERE userid='$_SESSION[stuid]' ");

while($row = mysql_fetch_array($colrec))
  {
$cname = $row["coluni"];
  }

$acrec1 = mysql_query("SELECT * FROM stuacc WHERE id='$uid[0]' ");

while($row = mysql_fetch_array($acrec1))
  {
      $stid1 = $row["id"];
$name1 = $row["firstname"];
$gen1= $row["iam"];
  }

  $acrec2 = mysql_query("SELECT * FROM stuacc WHERE id='$uid[1]' ");

while($row = mysql_fetch_array($acrec2))
  {
          $stid2 = $row["id"];
$name2 = $row["firstname"];
$gen2= $row["iam"];
  }

  $acrec3 = mysql_query("SELECT * FROM stuacc WHERE id='$uid[2]' ");

while($row = mysql_fetch_array($acrec3))
  {
          $stid3 = $row["id"];
$name3 = $row["firstname"];
$gen3= $row["iam"];
  }

  $acrec4 = mysql_query("SELECT * FROM stuacc WHERE id='$uid[3]' ");

while($row = mysql_fetch_array($acrec4))
  {
          $stid4 = $row["id"];
$name4 = $row["firstname"];
$gen4= $row["iam"];
  }
?>


<div style="padding: 10px; text-align: left;">
<!-- body  content -->

    <table width="100%" height="382" border="0" >
  <tr>
    <td width="16%" rowspan="9" align="left" valign="top" bgcolor="#CCCCCC"><?php include("profileleft.php"); ?></td>
    <td width="55%" rowspan="9" valign="top"><table width="100%" border="1">
        <tr>
          <th scope="col"><strong>Welcome, <?php echo $_SESSION["logid"]; ?></strong></th>
          </tr>
        <tr>
          <td><strong>Number of visitors:
              <?php
if(isset($_SESSION['views']))
 $_SESSION['views']=$_SESSION['views']+1;
   else
 $_SESSION['views']=1;
 echo $_SESSION['views']; 
 ?>
          </strong></td>
          </tr>
        <tr>
         <?php if(isset($cname)) { ?> <td><strong>College Name : </strong><b><?php echo $cname ; ?></b></td><?php } ?>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>
      <table width=100%>

        <tr valign=top align=center>
          <td colspan="4" align="left"><strong>Request Friends</strong></td>
          </tr>
        <tr valign=top align=center>
            <td><a href="friendsprofile.php?fid=<?php echo $stid1 ; ?>"><img src="<?php echo $img[0] ; ?>" width="100" height="150" border="0" alt=""><br />
             <?php echo $name1 ; ?><br />

            </a><br></td>
            <td><a href="friendsprofile.php?fid=<?php echo $stid2 ; ?>""><img src="<?php echo $img[1] ; ?>" width="100" height="150" border="0" alt=""><br />
              <?php echo $name2 ; ?>
            </a><br></td>
            <td><a href="friendsprofile.php?fid=<?php echo $stid3 ; ?>""><img src="<?php echo $img[2] ; ?>" width="100" height="150" border="0" alt=""><br />
             <?php echo $name3 ; ?>
            </a><br></td>
            <td><a href="friendsprofile.php?fid=<?php echo $stid4 ; ?>""><img src="<?php echo $img[3] ; ?>" width="100" height="150" border="0" alt=""><br />
              <?php echo $name4 ; ?>
            </a><br></td>

        </tr>
        </table>
      <table width="100%" border="1">
      <tr>
        <th colspan="2" scope="col"><br />            &nbsp;     <?php echo $fname. " " . $lname; ?></th>
      </tr>
      <tr>
        <?php if(isset($cname)) { ?><td colspan="2"><strong>College Name : </strong><b><?php echo $cname ; ?></b></td> <?php } ?>
      </tr>
      <tr>
        <?php if(isset($fmes)) { ?><td width="51%"><strong>City :<?php echo $_GET["fmes"]; ?></strong></td><?php } ?>

        </tr>
      <tr>
        <td height="23"><strong>State:</strong></td>
        <?php if(isset($state)) { ?><td><?php echo $state; ?></td><?php } ?>
        </tr>
      <tr>
        <td height="23"><strong>Pincode:</strong></td>
        <?php if(isset($pincode)) { ?><td><?php echo $pincode; ?></td><?php } ?>
        </tr>
      <tr>
        <td height="23"><strong>Country:</strong></td>
        <?php if(isset($country)) { ?><td><?php echo $country; ?></td><?php } ?>
        </tr>
      </table></td>
      <td height="23" colspan="2" background="" bgcolor="#CCCCCC"><strong><u>My friends</u></strong></td>
  </tr>
  <tr>
    <td width="14%" height="23" bgcolor="#CCCCCC" align="center" valign="top"><img src="<?php echo $img[0] ; ?>" alt="" width="71" height="53" /></td>
    <td width="15%" height="23" bgcolor="#CCCCCC" align="center" valign="top"><img src="<?php echo $img[1] ; ?>" alt="" width="71" height="53" /></td>
  </tr>
  <tr>
    <td height="4" align="center" valign="top" bgcolor="#CCCCCC"><img src="<?php echo $img[2] ; ?>" alt="" width="71" height="53" /><br />      
      <br /></td>
    <td height="4" bgcolor="#CCCCCC" align="center" valign="top"><img src="<?php echo $img[3] ; ?>" alt="" width="71" height="53" /></td>
  </tr>
  <tr>
    <td height="21" colspan="2" align="center" valign="top" bgcolor="#CCCCCC"><strong><a href="viewall.php">View all</a></strong></td>
  </tr>
  <tr>
    <td height="36" bgcolor="#CCCCCC" align="center"><img src="images/alosious.jpg" alt="" width="77" height="75" /></td>
    <td height="36" bgcolor="#CCCCCC" align="center"><img src="images/alvas.jpg" alt="" width="96" height="96" /></td>
  </tr>
  <tr>
    <td height="36" bgcolor="#CCCCCC" align="center"><img src="images/canara.jpg" alt="" width="78" height="78" /></td>
    <td height="36" bgcolor="#CCCCCC"><img src="images/dhavala.jpg" alt="" width="96" height="74" /></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#CCCCCC" align="center"><strong>View all</strong></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#CCCCCC"><strong><u>Advertisement</u></strong></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#CCCCCC" align="center"  ><a href="http://www.admissionopen.com/" ><img src="images/advt.jpg" width="173" height="185" /></a></td>
  </tr>
  </table>


</div>
<center>
<?php include("footer.php"); ?>

换行

<a href="profile.php"><img src="<?php echo $usimg;?>" alt="" 
width="90" height="106" /></a><br>

对此

<a href="profile.php">
 <?php if(isset($usimg)) { ?>
  <img src="<?php echo $usimg;?>" alt="" width="90" height="106" />
  <?php } ?>
</a><br>

添加
isset
功能。如果userimg存在,则显示图像。您可以添加
else
部分,并在用户没有图像的情况下显示一些通用图像


文档链接:

简单变量
$usimg
非set@SatishSharma您能详细地帮助我吗?您正在使用
$usimg
行中的变量
“..
。但是它没有在页面中设置。使用前在
$usimg
中指定一些内容。我需要您的帮助。看,我刚刚更新了我的问题。。请看一看确定如果(设置($row[“userid”])和($row[“userid”])!=$\u会话[“stuid”])谢谢你帮了我很多忙。。非常感谢您,很高兴我能够帮助您解决您的问题。请告诉我什么是未定义的索引错误,因为我在其他页面上也遇到了此错误。