Why do you want to find duplicate values? Because perhaps you can write some PHP code to find duplicate values?
minitauros 151 Junior Poster Featured Poster
Why do you want to find duplicate values? Because perhaps you can write some PHP code to find duplicate values?
Well, the variables you're using in these lines of code
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
have not been defined in the code that precedes it (for as far as I can see), and therefore will be null (if what I see here is all your code).
What ardav says is right. You can use PHP+MySQL. You need to create a user activity field and check and update it on every page the user views.
For example
CREATE TABLE user_activity (
user_id INT(11) NOT NULL,
last_active TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id)
)
Then, you need to check and compare results on every page.
For example
$q = 'SELECT COUNT(user_id) AS users_online
FROM user_activity
WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(last_active)) <= 60';
$rq = mysql_query($q) or die(mysql_error());
$fetch = mysql_fetch_assoc($rq);
$users_active = $fetch['users_online'];
echo '<p>There are '.$users_active.' users online.</p>';
This would count the users that have been active in the last minute. (I'm not sure about the SQL syntax here, might show errors, but this is just something to lead you into the right direction).
Finally, obviously, you will need to update the table. Something like
UPDATE user_activity
SET last_active = "'.date('Y-m-d H:i:s').'"
WHERE user_id = '.$user_id.'
It's not that I mind that it's a headache, I'd love to understand it :). Upgrade my scripting skills a bit.
Hello,
I'm encountering an AJAX problem when I try to execute multiple AJAX requests at the same time. What I want to do is delete a message and display the status (succes or failure) of that in div1, and refresh the messages on the page in div2. This needs (for as far as my knowledge reaches) two AJAX actions from which I both need the responseText.
The problem
What happens when I execute my script is that the second action (refresh a part of the page) happens before the deletion is executed. The result of this is that when the deletion has been executed, the page is already updated, and the deleted message is still there.
The script
What I now have is:
function doAjax(url, element_id, img_url)
{
var ajaxObject = createAjaxObject();
ajaxObject.open('GET', url, true);
ajaxObject.onreadystatechange = function()
{
if(ajaxObject.readyState==4 && ajaxObject.status==200)
{
document.getElementById(element_id).innerHTML = ajaxObject.responseText;
delete ajaxObject;
}
else
{
if(img_url)
document.getElementById(element_id).innerHTML = '<img src="' + img_url + '" alt=""/>';
}
};
ajaxObject.send();
}
to execute the actions, and
function createAjaxObject()
{
var ajaxObject;
try
{
ajaxObject = new XMLHttpRequest();
}
catch (e)
{
try
{
ajaxObject = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
try
{
ajaxObject = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
return;
}
}
}
return ajaxObject;
}
to create the AJAX object.