php - ajax returns success but mysql db not updated -
i have javascript loop sends array ajax page update mysql database.
i echo result original page , echos success when check db nothing has changed
my javascript loop sends array
for(var m=0; m<array.length; m++){ $.post("update_page_positions.php",{page_ref:array[m][0], ref:array[m][12], menu_pos:array[m][1], sub_menu_pos:array[m][2], top_menu:array[m][3], pagelink:array[m][4], indexpage:array[m][5], hidden:array[m][6], page_title:array[m][7], page_desc:array[m][8], page_keywords:array[m][9], page_name:array[m][10], deletedpage:array[m][11]}, function(data,status){ alert("data="+data+" status="+status); });
here php ajax page updates db
<? include("connect.php"); $ref = $_post['ref']; $page_ref = $_post['page_ref']; $menu_pos = $_post['menu_pos']; $sub_menu_pos = $_post['sub_menu_pos']; $top_menu = $_post['top_menu']; $indexpage = $_post['indexpage']; $page_name = $_post['page_name']; $page_title = $_post['page_title']; $page_desc = $_post['page_desc']; $page_keywords = $_post['page_keywords']; $hidden = $_post['hidden']; $pagelink = $_post['pagelink']; $deletedpage = $_post['deletedpage']; $query = mysql_query("select * pages ref='$ref' , page_ref='$page_ref'"); if(mysql_num_rows($query)==0){ mysql_query("insert pages(page_ref, ref, page_name, menu_pos, sub_menu_pos, top_menu, link, indexpage) values('$page_ref','$ref','$page_name','$menu_pos','$sub_menu_pos','$top_menu','$pagelink','$indexpage')"); } if($deletedpage=="1"){ mysql_query("delete pages ref='$ref' , page_ref='$page_ref'"); mysql_query("delete site_content ref='$ref' , page_ref='$page_ref'"); } else{ if(mysql_query("update pages set menu_pos='$menu_pos', sub_menu_pos='$sub_menu_pos', top_menu='$top_menu', indexpage='$indexpage', page_name='$page_name', page_title='$page_title', desc1='$page_desc', keywords_list='$page_keywords', hidden='$hidden', link='$pagelink' ref='$ref' , page_ref='$page_ref'")){ echo "updated!"; } else{ echo "error"; } } ?>
the insert , delete functions fine update returns success statement not update db.
can see problem is?
posted answer because comment hard read:
rather echoing "updated", try echoing
"update pages set menu_pos='$menu_pos', sub_menu_pos='$sub_menu_pos', top_menu='$top_menu', indexpage='$indexpage', page_name='$page_name', page_title='$page_title', desc1='$page_desc', keywords_list='$page_keywords', hidden='$hidden', link='$pagelink' ref='$ref' , page_ref='$page_ref'"
(ie. query you're trying run).
see if gives clues.
Comments
Post a Comment