配置文件上的php未定义索引错误
我正在制作社交网络类型的项目,我也在参考一些项目。在这里,我在第15行得到了未定义的索引错误,我无法解决 profileleft.php配置文件上的php未定义索引错误,php,html,Php,Html,我正在制作社交网络类型的项目,我也在参考一些项目。在这里,我在第15行得到了未定义的索引错误,我无法解决 profileleft.php <SCRIPT language="JavaScript1.2"> function openwindow() { window.open("chat/mychat.php","mywindow","menubar=1,resizable=1,width=350,height=750"); } </script> <br
<SCRIPT language="JavaScript1.2">
function openwindow()
{
window.open("chat/mychat.php","mywindow","menubar=1,resizable=1,width=350,height=750");
}
</script>
<br /><center>
<a href="profile.php">
<?php if(isset($usimg)) { ?>
<img src="<?php echo $usimg;?>" alt="" width="90" height="106" />
<?php } ?>
</a><br>
<font color="#000099"><strong><?php echo $fname ." ".$lname; ?></strong><br />
<a href="changepic.php">Change Picture</a>
</center>
<hr />
<img src="images/icon/profile.gif" width="23" height="22" align="absmiddle" /> <a href="editprof.php" >Edit Profile</a><br />
<a href="msg.php"><img src="images/icon/messages.gif" width="27" height="24" align="absmiddle" /> Scrap</a><br />
<a href="answer.php"><img src="images/icon/answers.png" width="25" height="24" align="absmiddle" /> Answers </a><br />
<a href="viewuploads.php"><img src="images/uploads.png" alt="" width="27" height="26" align="absmiddle" /></a><a href="viewuploads.php">View Uploads</a><br />
<a href="javascript: openwindow()" ><img src="images/chat.png" width="25" height="24" align="absmiddle" /> Chat </a>
<p> </p>
函数openwindow()
{
open(“chat/mychat.php”,“mywindow”,“menubar=1,resizable=1,width=350,height=750”);
}
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(isset($row["userid"]) && $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"><?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> </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 /> <?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"); ?>
试试这个
$sql="INSERT INTO addfriends(meid,friendid) VALUES
('".$_SESSION['stuid']."','".$_GET[fid]."')";
因为您的会话变量必须处于“或”
如果(isset($\u GET[“addf”])
或使用“@”例如@$\u GET[“addf”]
生成错误是因为您的$\u GET[“addf”]未设置为任何值,但它仍在检查其值。因此它的未定义索引错误
如果您将
if(isset($_GET["addf"]) && $_GET["addf"]=="t")
在第15行,它将检查它的集合是否正确,以及它是否等于t,然后将遵循它的if条件。祝你好运&每当你遇到未定义的错误时,记得在使用变量之前检查变量是否被索引
Here i am getting undefined index error on line 15 which i cant solve..
代码的第15行有:
if($_GET["addf"]=="t")
你兴高采烈地检查它的价值,而不检查它的存在
你可以做(并且有习惯):
您也可以通过以下方式关闭通知,但在将来,您将获得性能点击,这不是一个好的做法,也是懒惰的
if(@$_GET["addf"]=="t")
你还写了这样的话:
<hr /> <a href="friendsprofile.php?fid=<?php echo $_GET["fid"]; ?>&fmes=Added as friend&addf=t">
$\u GET[“addf”]
可能未设置,因此请检查它是否已先设置->如果(isset($\u GET[“addf”])&&&$\u GET[“addf”]=“t”)
。您还需要使用其他变量执行此操作->$\u会话[stuid]
,$\u GET[fid]
,等等。此外,通过直接在查询中插入用户值,您可以完全接受sql注入->…userid=$\u GET[fid]
但问题仍然是一样的..请看我正在发布错误感谢Aniket..我还有一个小问题是,在friendsprofile配置文件中,pic很好,但在我自己的配置文件中,它没有显示任何图片..我再次更新我的问题并将codeDo inspect元素发布在chrome上的那个地方,检查img标签,看看它的fetc是否正确正确设置图像url,我猜图像路径不正确。我有两个表studacc和profile。如果我注册了新用户,它将转到studacc,但它没有添加到新注册用户的profile表中。这一定是从数据库获取图像链接并以正确方式放置的问题,就像我正在更新profile图片的代码一样是profileleft.php。请看一看
if(@$_GET["addf"]=="t")
<hr /> <a href="friendsprofile.php?fid=<?php echo $_GET["fid"]; ?>&fmes=Added as friend&addf=t">
<hr /> <a href="friendsprofile.php?fid=<?php echo $_GET["fid"]; ?>&fmes=<?php echo urlencode("Added as friend"); ?>&addf=t">