I am developing a simple application on PHP . If I trying to run it always showing undefined variable.. I need some suggestions regarding how to fix this, Please find the code snippet below,
<?php
session_start();
include("profilesql.php");
$result = mysql_query("SELECT * FROM addfriends where meid='$_SESSION[stuid]' ");
while($row = mysql_fetch_array($result))
{
$uid1[$i] = $row["friendid"];
$i++;
}
$acrec1 = mysql_query("SELECT * FROM addfriends WHERE userid='$uid1[1]'");
while($row = mysql_fetch_array($acrec2))
{
$img1[0]= $row["image"];
}
$acrec2 = mysql_query("SELECT * FROM addfriends WHERE userid='$uid1[2]'");
while($row = mysql_fetch_array($acrec2))
{
$img1[1]= $row["image"];
}
$acrec3 = mysql_query("SELECT * FROM profile WHERE userid='$uid1[3]' ");
while($row = mysql_fetch_array($acrec3))
{
$img1[2]= $row["image"];
}
$acrec4 = mysql_query("SELECT * FROM profile WHERE userid='$uid1[4]' ");
while($row = mysql_fetch_array($acrec4))
{
$img1[3]= $row["image"];
}
?>
As per the above code snippet, I am getting the error message like stated below,
Notice: Undefined variable: uid1 in C:\xampp\htdocs\collegenetwrking\friends.php on line 11
Notice: Undefined variable: acrec2 in C:\xampp\htdocs\collegenetwrking\friends.php on line 13
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\collegenetwrking\friends.php on line 13
Notice: Undefined variable: uid1 in C:\xampp\htdocs\collegenetwrking\friends.php on line 18
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\collegenetwrking\friends.php on line 20
Notice: Undefined variable: uid1 in C:\xampp\htdocs\collegenetwrking\friends.php on line 25
Notice: Undefined variable: uid1 in C:\xampp\htdocs\collegenetwrking\friends.php on line 32
Please suggest me on this.