Link to home
Start Free TrialLog in
Avatar of kbios
kbios

asked on

Help with jQuery and AJAX process to load data to MySQL

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
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"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

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.
Avatar of kbios
kbios

ASKER

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