Php 添加ajax自动保存后,数据库连接过多错误
我有PHP网站与MySql数据库 我刚刚添加了文本区域的自动保存 其中一个用户收到以下错误: 中的连接太多…无法连接到数据库 也许我必须更改我的ajax自动保存:Php 添加ajax自动保存后,数据库连接过多错误,php,mysql,Php,Mysql,我有PHP网站与MySql数据库 我刚刚添加了文本区域的自动保存 其中一个用户收到以下错误: 中的连接太多…无法连接到数据库 也许我必须更改我的ajax自动保存: bkLib.onDomLoaded(function(){ var myEditor = new nicEditor({iconsPath : 'include/nicEdit/nicEditorIcons.gif'}).panelInstance('area1'); auto_save_func(myEditor); }
bkLib.onDomLoaded(function(){
var myEditor = new nicEditor({iconsPath : 'include/nicEdit/nicEditorIcons.gif'}).panelInstance('area1');
auto_save_func(myEditor);
});
function auto_save_func(myEditor)
{
draft_content=myEditor.instanceById('area1').getContent();
int_id='<?=$_GET[interview_id]?>';
$.post("ajax_for_auto_save_interview.php", { interview_id: int_id,content:draft_content},
function(data){ });
setTimeout( function() { auto_sav_func(myEditor); }, 100);
}
bkLib.ondomload(函数(){
var myEditor=new nicEditor({iconpath:'include/nicEdit/nicEditorIcons.gif'});
自动保存功能(myEditor);
});
自动保存功能(MyEdit)
{
draft_content=myEditor.instanceById('area1').getContent();
int_id=“”;
$.post(“ajax_for_auto_save_interview.php”,{interview_id:int_id,content:draft_content},
函数(数据){};
setTimeout(function(){auto_sav_func(myEditor);},100);
}
在“ajax\u for\u auto\u save\u interview.php”页面中,我包括了到数据库的连接
var isAjaxStarted = 0;
bkLib.onDomLoaded(function(){
var myEditor = new nicEditor({iconsPath : 'include/nicEdit/nicEditorIcons.gif'}).panelInstance('area1');
if(isAjaxStarted == 0)
auto_save_func(myEditor);
});
function auto_save_func(myEditor)
{
isAjaxStarted = 1;
draft_content=myEditor.instanceById('area1').getContent();
int_id='<?=$_GET[interview_id]?>';
$.post("ajax_for_auto_save_interview.php", { interview_id: int_id,content:draft_content},
function(data){ isAjaxStarted = 0; });
setTimeout( function() { auto_sav_func(myEditor); }, 100);
}
var=0;
bkLib.ondomload(函数(){
var myEditor=new nicEditor({iconpath:'include/nicEdit/nicEditorIcons.gif'});
如果(IsajaxStart==0)
自动保存功能(myEditor);
});
自动保存功能(MyEdit)
{
Isajax=1;
draft_content=myEditor.instanceById('area1').getContent();
int_id=“”;
$.post(“ajax_for_auto_save_interview.php”,{interview_id:int_id,content:draft_content},
函数(数据){isAjaxStarted=0;});
setTimeout(function(){auto_sav_func(myEditor);},100);
}
var isAjaxStarted = 0;
bkLib.onDomLoaded(function(){
var myEditor = new nicEditor({iconsPath : 'include/nicEdit/nicEditorIcons.gif'}).panelInstance('area1');
if(isAjaxStarted == 0)
auto_save_func(myEditor);
});
function auto_save_func(myEditor)
{
isAjaxStarted = 1;
draft_content=myEditor.instanceById('area1').getContent();
int_id='<?=$_GET[interview_id]?>';
$.post("ajax_for_auto_save_interview.php", { interview_id: int_id,content:draft_content},
function(data){ isAjaxStarted = 0; });
setTimeout( function() { auto_sav_func(myEditor); }, 100);
}
var=0;
bkLib.ondomload(函数(){
var myEditor=new nicEditor({iconpath:'include/nicEdit/nicEditorIcons.gif'});
如果(IsajaxStart==0)
自动保存功能(myEditor);
});
自动保存功能(MyEdit)
{
Isajax=1;
draft_content=myEditor.instanceById('area1').getContent();
int_id=“”;
$.post(“ajax_for_auto_save_interview.php”,{interview_id:int_id,content:draft_content},
函数(数据){isAjaxStarted=0;});
setTimeout(function(){auto_sav_func(myEditor);},100);
}
也许我写晚了,你能帮忙吗?多谢各位
<script type="text/javascript">
bkLib.onDomLoaded(function() {
var myNicEditor = new nicEditor({buttonList : ['bold','italic','underline','strikethrough','left','center','right','justify',/*'ol','ul',*/'forecolor',/*'fontSize','fontFamily',*//*'fontFormat',*//*'indent','outdent',*/'image','upload','link','unlink'/*,'bgcolor'*/,'hr','removeformat', 'youTube'/*,'subscript','superscript'*/],/*fullPanel : true,*/
iconsPath : '<? echo "".$IndirizzoPagina."".$IndirizzoCartella."";?>default/image/EditorDiTesto/nicEditorIcons.gif'});
myNicEditor.setPanel('myNicPanel'); //PANNELLO DI CONTROLLO
myNicEditor.addInstance('titolo'); //TITOLO
myNicEditor.addInstance('contenuto'); //CONTENUTO
});
bkLib.ondomload(函数(){
var myNicEditor=new nicEditor({按钮列表:['bold'、'italic'、'underline'、'Streethrough'、'left'、'center'、'right'、'justify'、/*'ol'、'ul'、*/'forecolor'、/*'fontSize'、'fontFamily'、*/*/*'fontFormat'、*/*/*'indent'、'outdent'、*/'image'、'upload'、'link'、'unlink'、'unlink'、'bgcolor'、'hr'、'removeformat'、'youTube'/*、'superscript'、',/*fullPanel:true,*/
IConPath:'default/image/EditorDiTesto/nicEditorIcons.gif'});
myNicEditor.setPanel('myNicPanel');//PANNELLO DI CONTROLLO
myNicEditor.addInstance('titolo');//titolo
myNicEditor.addInstance('contenuto');//contenuto
});
“$ContenutoNotizia。”
我用了这段代码也许我写晚了你帮我到位了吗?非常感谢
<script type="text/javascript">
bkLib.onDomLoaded(function() {
var myNicEditor = new nicEditor({buttonList : ['bold','italic','underline','strikethrough','left','center','right','justify',/*'ol','ul',*/'forecolor',/*'fontSize','fontFamily',*//*'fontFormat',*//*'indent','outdent',*/'image','upload','link','unlink'/*,'bgcolor'*/,'hr','removeformat', 'youTube'/*,'subscript','superscript'*/],/*fullPanel : true,*/
iconsPath : '<? echo "".$IndirizzoPagina."".$IndirizzoCartella."";?>default/image/EditorDiTesto/nicEditorIcons.gif'});
myNicEditor.setPanel('myNicPanel'); //PANNELLO DI CONTROLLO
myNicEditor.addInstance('titolo'); //TITOLO
myNicEditor.addInstance('contenuto'); //CONTENUTO
});
bkLib.ondomload(函数(){
var myNicEditor=new nicEditor({按钮列表:['bold'、'italic'、'underline'、'Streethrough'、'left'、'center'、'right'、'justify'、/*'ol'、'ul'、*/'forecolor'、/*'fontSize'、'fontFamily'、*/*/*'fontFormat'、*/*/*'indent'、'outdent'、*/'image'、'upload'、'link'、'unlink'、'unlink'、'bgcolor'、'hr'、'removeformat'、'youTube'/*、'superscript'、',/*fullPanel:true,*/
IConPath:'default/image/EditorDiTesto/nicEditorIcons.gif'});
myNicEditor.setPanel('myNicPanel');//PANNELLO DI CONTROLLO
myNicEditor.addInstance('titolo');//titolo
myNicEditor.addInstance('contenuto');//contenuto
});
“$ContenutoNotizia。”
我使用了这段代码你是否在php文件中关闭连接?否。我是否应该在保存数据后每次在此页面中调用mysql\u close()?是的,你应该在不需要时立即关闭连接。你是否在php文件中关闭连接?否。我是否应该在保存数据后每次在此页面中调用mysql\u close()?是的,一旦你不需要它,你就应该马上关闭它,谢谢。您添加了仅第一次调用ajax的if-in-ondomload函数。在第二个函数中,它会在AJAx之后继续调用它,不是只有在从AJAx返回后才会自动继续吗?感谢您注意到这一点。是的,它也应该添加到setTimeout函数中。它不是只有在从Ajax返回后才调用setTimeout吗?不是。由于这是一个异步调用,它不会等待AJAX完成。为什么不在从AJAX返回时调用函数(数据)中的setTimeOut呢
我可以这样做:
函数报告自动保存(myEditor){…….$.post(“ajax_for_auto_save_interview.php”),{interview_id:int_id,content:draft_content},函数(data){setTimeout(function(){report_auto_save(myEditor);},3000);}谢谢。您添加了仅第一次调用ajax的if-in-ondomload函数。在第二个函数中,它会在AJAx之后继续调用它,不是只有在从AJAx返回后才会自动继续吗?感谢您注意到这一点。是的,它也应该添加到setTimeout函数中。它不是只有在从Ajax返回后才调用setTimeout吗?不是。由于这是一个异步调用,它不会等待AJAX完成。为什么不在从AJAX返回时调用函数(数据)中的setTimeOut呢
我可以这样做吗:
函数