Code: Select all
function bgnpg($title){ # begins all pages
include("/home/joshua/includes/fyd.db.php"); # includes file
$ims=array();
if($_COOKIE['login']){ # we're logged in
$db=mysql_connect($host, $login2, $pass2) or die("cannot access mysql"); # get the sql connection
$fyd=mysql_select_db('findyourdesire', $db) or die("cannot connect to db"); # select the db
$un=$_COOKIE['un']; $pw=$_COOKIE['pw']; # what we wont change on-the-fly
$fprefs=mysql_query("SELECT uid, gmt_offset, tds, login_duration, msgs FROM users WHERE username='$un' AND password='$pw
'", $db); # get the prefs
if(mysql_num_rows($fprefs)>0){ # we can update the cookies
$prefs=mysql_fetch_array($fprefs); $gmto=$prefs['gmt_offset']; $utds=$tds[$prefs['tds']];
$duration=$durr[$prefs['login_duration']]; $accepts=($prefs['msgs']*1); $uid=$prefs['uid'];
$expire=(time()+($duration*60));
setcookie(un, $un, $expire); # set username
setcookie(pw, $pass, $expire); # set password
setcookie(login, TRUE, $expire); # set login
setcookie(gmto, $gmto, $expire); # set the gmt offset
setcookie(utds, $rtds, $expire); # set the time display style
$active=gmdate("Y-m-d H:i:s", time());
$update=mysql_query("UPDATE users SET last_activity='$active' WHERE username='$un'", $db); # try to update users (we d
on't really care if it fails)
if($accepts){ # person accepts ims
if($accepts>5){ # the user wants them ALL
$fims=mysql_query("SELECT msg_id FROM msgs WHERE to_id='$uid' AND viewed='0'", $db);
$amtims=mysql_num_rows($fims);
if($amtims){ # we have ims
for($i=0;$i<$amtims;$i++){ # for each im
$gimid=mysql_fetch_array($fims); $ims=$gimid['msg_id']; # record the msg_id
}
}
}else{ # user wants $accepts amount
$fims=mysql_query("SELECT msg_id FROM msgs WHERE to_id='$uid' AND viewed='0' ORDER BY msg_id ASC LIMIT '$accepts'"
, $db);
$errno=mysql_errno($db);$error=mysql_error($db);echo"<p>errno: $errno<br />error:$error</p>";
$amtims=mysql_num_rows($fims);
if($amtims){ # we have ims
for($i=0;$i<$amtims;$i++){ # for each im
$gimid=mysql_fetch_array($fims); $ims=$gimid['msg_id']; # record the msg_id
}
}
}
}
}else{ cookies('logout'); } # there was an error for some reason
} # end cookie updating
# set headers to stop caching
header("Expires: Sat, 24 Feb 1979 20:00:00 GMT");
header("cache-control: no-store,no-cache,must-revalidate");
header("cache-control: post-check=0,pre-check=0", false);
header("Pragma: no-cache");
echo <<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>FindYourDesire.com -- $title</title>
<meta name="Author" content="Pages coded by Josh Perlmutter for Desired Creations LLC">
<meta name="Author" content="Graphics created by Alix Stolzer for Desired Creations LLC">
<meta name="Author" content="Smileys created by Amber Beausoleil for Desired Creations LLC">
<style type="text/css">
<!-- this comment is for non-css compliant browsers
{text-decoration:none}
end of css -->
</style>
</head>
<body bgcolor="#878787" text="#ffffff" alink="#950c0c" vlink="#3347c5" link="#000000">
<center>
END;
if(count($ims)){ # if there's any ims
echo ' <script language="javascript">';
foreach($ims as $im){ # foreach im to display
echo " window.open('http://24.91.157.113/findyourdesire/message.php?mid=$im', '$im', 'height=200,width=200,scrollba
rs=auto,resizable=yes');";
}
echo ' </script>';
}
}and the msgs table DOES exist, infact....errno: 1064
error:You have an error in your SQL syntax near ''2'' at line 1
Code: Select all
mysql> show tables;
+--------------------------+
| Tables_in_findyourdesire |
+--------------------------+
| bio |
| comments |
| forums |
| friends |
| interests |
| mail |
| msgs |
| pests |
| posts |
| stats |
| threads |
| tops |
| users |
| votes |
+--------------------------+
14 rows in set (0.51 sec)
mysql> describe msgs;
+---------+---------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------------+------+-----+---------------------+----------------+
| msg_id | bigint(20) unsigned | | PRI | NULL | auto_increment |
| to_id | int(10) unsigned | | MUL | 0 | |
| from_id | int(10) unsigned | | | 0 | |
| from_un | varchar(15) | | | | |
| sent | datetime | | MUL | 0000-00-00 00:00:00 | |
| message | text | | | | |
| viewed | tinyint(1) | | | 0 | |
+---------+---------------------+------+-----+---------------------+----------------+
7 rows in set (0.19 sec)
mysql>