Gettin this error:
Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/w/i/s/wishitlist/html/viewmyitems.php on line 59
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/w/i/s/wishitlist/html/viewmyitems.php on line 59
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/w/i/s/wishitlist/html/viewmyitems.php on line 60
Heres my code:
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: main.html");
}
//otherwise they are shown the admin area
else
{
echo "<table align=\"right\" valign=\"top\" background=\"Main_files/PhotoGray_bg_c-1.jpg\"><td><a href=logout.php target=\"_self\"><font face=\"Arial\" color=\"#667C26\" style=\"text-decoration:none\">Logout</font></a></td></table>";
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
$username = $_COOKIE['ID_my_site'];
$usernameclean = preg_replace("/[^A-Za-z0-9]/","",$username);
$query="SELECT mygroups FROM $usernameclean";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo "<b><center><font size=4 face=\"Arial\" color=\"#667C26\">My items</center></b><br><br \></font>";
echo "<font size=1 face=\"Arial\" color=\"#667C26\">Click the group you wish to Edit or View<br><br \></font>";
$i=0;
while ($i < $num) {
$mygroups=mysql_result($result,$i,"mygroups");
if($i!=0)
{
$items = mysql_query("SELECT * FROM $usercheck WHERE mygroups = '$mygroups'");
$row = mysql_fetch_row($items);
$Item1 = $row[2];
$Item2 = $row[3];
$Item3 = $row[4];
$Item4 = $row[5];
$Item5 = $row[6];
$Item6 = $row[7];
$Item7 = $row[8];
$Item8 = $row[9];
$Item9 = $row[10];
$Item10 = $row[11];
print <<< EOF
<a href="viewgroup.php?group=$mygroups" target="_self" style="text-decoration:none"><font face="Arial" color="#667C26">
<b>$mygroups</b></font></a><br>
EOF;
echo $Item1;
echo $Item2;
echo $Item3;
echo $Item4;
echo $Item5;
echo $Item6;
echo $Item7;
echo $Item8;
echo $Item9;
echo $Item10;
}
$i++;
}