Let me first say that your code is completely disorganized. I'd recommend that you consider starting over again and really think about what you are doing first. For starters, you have posted what appear to be two different scripts without telling me what their names are.
In the first script you connect to the database and run a query that uses $_POST data without even checking:
mysql_connect("lago.startlogicmysql.com", "gguppies", "12345678") or die(mysql_error());
mysql_select_db("tutorescue") or die(mysql_error());
function is_valid_user()
{
if(isset($_SESSION['userID']))
{
echo "<a href='members.php'>" .$row['firstname']. "</a>";
}
if(!isset($_SESSION['userID']))
{
echo "<a href='login.php' class='login'>Login</a>";
}
}
$query = mysql_query("SELECT * FROM users WHERE userID = '".$_POST['userID']."'")or die(mysql_error());
$row = mysql_fetch_array($query);
If the user hasn't submitted anything to this script, that is probably going to return an error and die. Whether they have submitted or not, it runs a query and returns $row and then does nothing with the var $row.
Then you perform a cookie check and have some other stuff happen if the cookie is defined. It looks like you are looking for a username and password in the cookie. It's a really bad idea to store usernames and passwords in a cookie:
if(isset($_COOKIE['ID_my_site']))
//if there is, it logs you in and directes you to the members page
{
$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 ($pass != $info['password'])
{
}
else
{
header("Location: index.php");
}
}
}
And that's just for starters. Your code is also poorly formatted. I'm not sure what you're trying to do here, but I think you should start over and keep it simple. Let's build up from simple rather than trying to fix this long, confused bunch of code.