View Single Post
  #1 (permalink)  
Old 10-26-2008, 03:23 AM
edhan's Avatar
edhan edhan is offline
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Singapore
Posts: 716
edhan RepRank 3edhan RepRank 3edhan RepRank 3
Default How to inlcude email in table?

Hi

Hope this is the correct section to ask. I am confused as why I can include the email into the new table. Here is the extraction portion where I am trying to include the email.
Code:
function get_id_by_username($user)
{
$cond = "username='".trim($user)."' and active='1'";
$result = getField("register",$cond,"userid");

if($result != false && mysql_num_rows($result)>0)
{
$row = mysql_fetch_array($result);
return $row[0];
}

else
{
return false;
}
}
if($_POST['btnsend']==$__syslang["Send"])
{
$flagexists=strpos($_POST['txtemailids'],",");
if($flagexists)
{
$toemailids = explode(",",$_POST['txtemailids']);
}
else
{
$toemailids = $_POST['txtemailids'];
}
$sent = 0;
if(is_array($toemailids))
{
$lastmsgid = get_last_msgid();

for($i=0;$i<count($toemailids);$i++)
{
$tofriendid = get_id_by_username($toemailids[$i]);
	if($tofriendid)
{
	if(check_addressbook($_SESSION['userid'], $tofriendid))
{
	$check_msg .= " - $toemailids[$i]<br>";
	$failed = 1;
{
	$res =get_user($tofriendid,"username");
	$row = mysql_fetch_array($res);
	$usersname =$row['username'];
	$msg .= "- $usersname<br>";

}
	$table_name = "friendrequests";
	$field_names = "fromid,toid,messageid,ondate";
	$val = array();
	$val[0] = $_SESSION['userid'];
	$val[1] = $tofriendid;
	$val[2] = ($lastmsgid + 1);
	$val[3] = date("Y-m-d h:m:s");
	$insertedid = insert_into_db($table_name, $field_names, $val);
if($insertedid > 0)
	{
$sentmsg .= " - $toemailids[$i]<br>";
	$sent = 1;
	$inserted = 1;
Here are the portion that I modify but still can't work.

Code:
	if(check_addressbook($_SESSION['userid'], $tofriendid, $tofriendemail))
...
	$res =get_user($tofriendid,"username",$tofriendemail,"email");
	$row = mysql_fetch_array($res);
	$usersname =$row['username'];
	$email =$row['email'];
	$msg .= "- $usersname<br>- $email";
....

	$table_name = "friendrequests";
	$field_names = "fromid,toid,email,messageid,ondate";
	$val = array();
	$val[0] = $_SESSION['userid'];
	$val[1] = $tofriendid;
	$val[2] = $tofriendemail;
	$val[3] = ($lastmsgid + 1);
	$val[4] = date("Y-m-d h:m:s");
	$insertedid = insert_into_db($table_name, $field_names, $val);
But I can't seem to add the email into the table. It just only add userid, username, msg and date into the table.

What did I do wrong? Any help is greatly appreciated. Thanks!
Reply With Quote