ErnieAlex,
Thank you for your response. You’ve given me some good things to watch for and think about.
To clarify, this issue doesn’t happen all the time, however I’ve been having trouble identifying what is unique about the situation when it does happen.
So far I have used two differnt laptops (one at home - wireless and the other at work wired) and the problem has occured while using both. I am also testing on an iPhone and I’m not 100% sure if it happend while using the phone exclusivly.
This is the code (java script) that is in the main webpage, which is run when a button is clicked.
function start_activity(msg){
var r=confirm("Do you want to start this activity?\r" + msg);
if (r==true) {
window.location.href = 'start_new_activity.php' + '?theactivity=' + $new_activity + '&thebillable=' + $thebillable + '&thedate=' + $thedate + '&thenote=' + $thenote;
}
}
The button code is…
[php]onclick=“start_activity(’’. $buttonactivity .’’);”[/php]
The php file in its entirerty…
[php]<?php
$theactivity = $_GET[‘theactivity’];
$theactivity_clean = str_replace(" [ Other Activity ]","",$theactivity);
$thebillable = $_GET[‘thebillable’];
$thedate = $_GET[‘thedate’];
$thenote = $_GET[‘thenote’];
if (empty($theactivity )) {
echo ‘Erro no activity name!’;
} else {
$con = mysql_connect('localhost','fakeuser','fakepassword');
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("fake_database", $con);
echo ‘
Checking for current activity.
’;
$result = mysql_query(“SELECT * FROM
fake_database
.
settings
WHERE
email
= ‘
[email protected]’;”);
$row = mysql_fetch_array($result);
$scactivityname = $row['cactivityname'];
$scactivitystart= $row['cactivitystart'];
$scactivityid= $row['cactivityid'];
if ($scactivityid <> 0){
echo ‘
Ending current activity.
’;
$sql0=“UPDATE
fake_database
.
activities
SET
endtime
= ‘$thedate’ WHERE
activities
.
id
= ‘$scactivityid’”;
if (!mysql_query($sql0,$con)){
die('Error: ’ . mysql_error());
}
}
echo ‘
Starting new activity.
’;
$sql1=“INSERT INTO
fake_database
.
activities
(
id
,
email
,
billable
,
activity
,
note
,
starttime
,
endtime
) VALUES (NULL, ‘
[email protected]’, ‘$thebillable’, ‘$theactivity_clean’, ‘$thenote’, ‘$thedate’, ‘0000-00-00 00:00:00’)”;
if (!mysql_query($sql1,$con)){
die('Error: ’ . mysql_error());
}
$last_id = mysql_insert_id();
if ($last_id) {
$sql2="UPDATE `fake_database`.`settings` SET `cactivityid` = '$last_id', `cactivityname` = '$theactivity', `cactivitystart` = '$thedate' WHERE `settings`.`email` = '[email protected]'";
if (!mysql_query($sql2,$con)){
die('Error: ' . mysql_error());
}
} else {
echo "The last query did not generate an AUTO_INCREMENT value";
}
echo ‘
Done.
’;
mysql_close($con);
$to =
"[email protected]";
$subject = $theactivity_clean;
$message = $thedate;
$from =
"[email protected]";
$headers = “From:” . $from;
mail($to,$subject,$message,$headers);
echo “Mail Sent.”;
}
?>
[/php]
I think the code is pretty simple, but really what do I know. I’ve been expirencing the problem for about 4 days - while trying to nail down a pattern, but I finally hit a wall.
Any review and help would be appreciated. I’m going to checkout the capture the IP idea to see if I can determine what is running the script.
Thank you again,
Jim