php - MySQL error: Incorrect Table Name -


i'm pretty new web development there's chance i'm doing pretty dumb here.

i'm using ajax send data php file use data run sql commands update table. i'm dealing editing articles, php file needs know 3 things: original name of article (for reference), new name , new content. tell page user looking @ knows table edit.

    $('#save_articles').click(function () {      var current_page = $('#current_location').html();     var array_details = {};     array_details['__current_page__'] = current_page;          $('#article_items .article_title').each(function(){              var article_name = $(this).html(); //the text in div element name             var new_article_name = $(this).next('.article_content');             new_article_name = $(new_article_name).children('.article_content_title').html();             var new_article_content = $(this).next('.article_content');             new_article_content = $(new_article_content).children('.article_content_content').html();              array_new_deets = {new_name:new_article_name, content:new_article_content};             array_details[article_name] = array_new_deets;          });          send_ajax("includes/admin/admin_save_articles.php", array_details);      }); 

in php file, first retrieve current page , store in $sql_table , remove current page variable $_post. run this.

foreach($_post $key => $value){          $original_name = $key;         $new_name = $value['new_name'];         $new_cont = $value['content'];           $query =    "update                          `$sql_table`                     set                          `element_name`= '$new_name',                         `element_content` = '$new_cont',                                             `element_name` = '$original_name'";          $query = mysql_query($query);           if(!$query){                  die(mysql_error());              }      } 

i receive error saying 'sitep_home' incorrect table name. not real table in db, i've changed name make sure isn't issue keywords or something.

if instead run query without variable $sql_table (specifying table called 'sitep_home'), query accepts table. doesn't update table, , suspect it's because of argument uses variable.

can see i'm doing wrong here?

thanks

try use $sql_table '$sql_table' if sure contain right table name. using other column's value check if can help!!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -