Insert into MySQL database with jQuery and PHP -


i'm experiencing kind of problem here, have no idea what's wrong code. i'm pretty sure it's client sided since not getting php errors, may wrong.

i'm trying form, once submitted, insert information contained in text field mysql database via ajax request php file.

here's i'm at:

/* index.php */  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="scripts/ajax.js"></script>   //...           <div class="success" id="success"></div>         <div class="err" id="err"></div>    <!--create form-->  <form action="" method="post" name="create" id="createform" onsubmit="createnew(document.create.create2.value); return false;">                 <h5>create new file</h5>         <p><input name="create2" type="text" maxlength="32" /></p>  <input type="submit" name="submit" value="create" />  </form>   /* ajax.js */  function createnew(name) {  $('#loading').css('visibility','visible');    $.ajax({   type: "post",   url: "../utilities/process.php",   data: 'name='+name,   datatype: "html",   success: function(msg){     if(parseint(msg)!=5)    {     $('#success').html('successfully added ' + name + ' database.');     $('#loading').css('visibility','hidden');     alert('success');//testing purposes    }    else    {     $('#err').html('failed add ' + name + ' database.');     $('#loading').css('visibility','hidden');     alert('fail');//testing purposes    }   }       }) }   /* process.php */  <? include('db_connect.php');  if($_post['name']) {  $name = $_post['name'];  $name = mysql_escape_string($name);  $query = "insert tz_navbar (name) values (".$name.")";  $result = mysql_query("$query") or die ("5");  } ?> 

here's problem: after submit form something, reports succeeds nothing gets added database.

thank in advance taking time me.

looking @ query, suspect need be:

$query = "insert tz_navbar (name) values ('".$name."')"; 

if doesn't fix it, need log value of $_request

error_log(print_r($_request,true)); 

to ensure getting right values on server side.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -