mikell wrote:It could be a permissions problem...I doubt it though, but make sure the user you are connecting as has permission to insert and select from whatever table you are using.
What is the code for is_send_newmessage_alerts() and send_newmessage_alert()?
Does it always break at the same place? As in...insert #100.
Does it always break on the same query?
Does it always break after the same amount of time?
This is what happens ....if I just send 1 message ..it executes with no problem ....but if I change the option in admin to message all .....the script will start inserting message into about 30 - 90 rows before the error message appears and sometimes the browser will timeout as if I wasn't connected to the internet ....usually takes 30 secs to 2 mins before the error message or browser time out happens. The mysql says error line 70 which would be: if (!($res=mysql_query($query))) {general_error(mysql_error(),LINE,FILE);} if I included all lines in the code below ...
the code for is_send_newmessage_alerts() and send_newmessage_alert() is a function to email the user letting them know they have a new message on the site mailbox
Here is the full script:
<?
/*
SOME INCLUDE FILES REMOVED
*/
db_connect();
check_login_member();
set_time_limit(0);
$tpl = new phemplate(_TPLPATH_,'remove_nonjs');
$topass=array();
$error=false;
$message="";
if ($_SERVER['REQUEST_METHOD']=='POST') {
$from=addslashes_mq($_POST['from']);
$query="SELECT user_id FROM users WHERE name='$from'";
if (!($res=mysql_query($query))) {general_error(mysql_error(),__LINE__,__FILE__);}
if (mysql_num_rows($res)) {
$from_id=mysql_result($res,0,0);
} else {
$error=true;
$topass['message']="Invalid FROM field! Message not sent.";
}
if (isset($_POST['subject']) && !empty($_POST['subject'])) {
$subject=addslashes_mq($_POST['subject']);
} else {
$error=true;
$topass['message']="No subject specified. Message not sent.";
}
if (isset($_POST['body']) && !empty($_POST['body'])) {
$body=unix2dos(addslashes_mq($_POST['body']));
} else {
$error=true;
$topass['message']="No message body! Message not sent.";
}
$action=0;
if (isset($_POST['act']) && !empty($_POST['act'])) {
$action=addslashes_mq($_POST['act']);
}
if (!$error) {
$sendto=array();
if ($action==-4) {
$name=addslashes_mq($_POST['name']);
$query="SELECT user_id FROM users WHERE name='$name'";
} elseif ($action==-3) {
$query="SELECT user_id FROM users";
} elseif ($action==-2) {
$query="SELECT user_id FROM users WHERE membership="._REGISTERLEVEL_;
} elseif ($action==-1) {
$query="SELECT user_id FROM users WHERE membership="._SUBSCRIBERLEVEL_;
} elseif ($action>=1 && $action<=count($accepted_genders)) {
$query="SELECT user_id FROM users WHERE gender='$action'";
} else {
$error=true;
$topass['message']="You have to specify a member/group where to send the message";
}
if (!$error) {
if (!($res=mysql_query($query))) {general_error(mysql_error(),__LINE__,__FILE__);}
if (mysql_num_rows($res)) {
for ($i=0;$i<mysql_num_rows($res);$i++) {
$sendto[]=mysql_result($res,$i,0);
}
}
$totalusers=count($sendto);
foreach ($sendto as $user_id) {
$query="INSERT INTO mail_inbox VALUES('',0,'$user_id','$from_id','$subject','$body','',now(),'$from','1')";
if (!($res=mysql_query($query))) {general_error(mysql_error(),__LINE__,__FILE__);}
if (is_send_newmessage_alerts($user_id)) {send_newmessage_alert($from_id,$user_id);}
}
$topass['message']="Message sent to $totalusers members.";
} else {
$topass['from']=$from;
$topass['subject']=$subject;
$topass['body']=$body;
$topass['name']=$name;
$topass['act']=$act;
redirect2page('admin/send_message.php',$topass);
}
} else {
$topass['from']=$from;
$topass['subject']=$subject;
$topass['body']=$body;
$topass['name']=$name;
$topass['act']=$act;
redirect2page('admin/send_message.php',$topass);
}
}
redirect2page('admin/controlpanel.php',$topass);
?>