Solved

Help with jQuery and AJAX process to load data to MySQL

Posted on 2011-09-28
4
291 Views
Last Modified: 2012-05-12
I am wanting to use jquery/ajax to load data to mysql. Below is the HTML and the php script that I am using. When I run this program the MySql db is NOT updated. Would someone please review the code and offer any suggestions as to why this may not be working? This is my first attempt at jquery/ajax so the error may be a simple one but it has me stumped. Thanks.

 ee.txt
0
Comment
Question by:kbios
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
replace : data: "item="+citem,
by : data: "citem="+citem,
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
"replace" :
mysql_query("INSERT INTO itemdtl (ukey, item) VALUES ("XXXX10000", '$item')");

Open in new window

by :
   $result = mysql_query("INSERT INTO itemdtl (ukey, item) VALUES ("XXXX10000", '$item')");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

Open in new window

0
 
LVL 2

Expert Comment

by:Robert Silver
Comment Utility
Your HTML is missing a HEADER and BODY to start with You may find that an OnLoad javascript
may be helpful in setting things up as well.  e.g <BODY onLoad="javascript:myFunction();">


If I were you I would start with a simple connection test in PHP
maybe write it to a file or the screen using typical submit action code

the file is as simple as
$fp1=fopen("path2debgfile.txt", "a");
fwrite($fp1, "what I want to verify:" .  (string)  $valueFromDatabase );
fclose($fp1);

I find that really helps when debugging complex web apps
There are also debuggers you can use as well

I hope thsa helped.
0
 

Author Closing Comment

by:kbios
Comment Utility
You're terrefic!  Thank you. I can't believe I was THAT close but hey that's why you're the expert! Thanks again.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now