cleary1981 Posted July 23, 2008 Share Posted July 23, 2008 Hi all, I am trying to update my db passing variables from javascript to php that updates my database. There is a problem with my javascript somewhere but im not sure where. When I enter dummy values into the php the db updates fine. Is there anything wrong with my POST? heres the function that passes the variables. function updateProjectDetails() { var uproj_id = document.getElementById("proj_id_edit").value; var uaccess = document.getElementById("access_edit").value; var ucable = document.getElementById("cable_edit").value; var uip = document.getElementById("ip_edit").value; var ufault = document.getElementById("fault_edit").value; var uform = document.getElementById("iform_edit").value; var upman = document.getElementById("pman_edit").value; var udl = document.getElementById("deadline_edit").value; var url = "updateProjectDetails.php"; request.open("POST", url, true); request.onreadystatechange = showConfirmation; request.send("uproj_id=" + escape(uproj_id) + "&uaccess=" + escape(uaccess) + "&ucable=" + escape(ucable) + "&uip=" + escape(uip) + "&ufault=" + escape(ufault) + "&uform=" + escape(uform) + "&upman=" + escape(upman) + "&udl=" + escape(udl)); } function showConfirmation () { } heres the HTML code where they originate <table width=100% border=0> <tr> <td><label for="proj_id_edit">Project ID</label> <input type = "text" value = "" name = "proj_id_edit" id = "proj_id_edit"></td> <td><label for="projName_edit">Project Name</label> <input type = "text" value = "" disabled name = "projName_edit" id = "projName_edit"></td></tr> <tr><td><label for="comp_edit">Company Name</label> <input type = "text" value = "" disabled name = "comp_edit" id = "comp_edit"></td> <td><label for="access_edit">Access</label> <input type = "text" value = "" name = "access_edit" id = "access_edit"></td></tr> <tr><td><label for="cable_edit">Cable Entry</label> <input type = "text" value = "" name = "cable_edit" id = "cable_edit"></td> <td><label for="ip_edit">IP Rating</label> <input type = "text" value = "" name = "ip_edit" id = "ip_edit"></td></tr> <tr><td><label for="fault_edit">Fault Rating</label> <input type = "text" value = "" name = "fault_edit" id = "fault_edit"><span>KW/sec</span></td> <td><label for="iform_edit">Form</label> <input type = "text" value = "" name = "iform_edit" id = "iform_edit"></td></tr> <tr><td><label for="pman_edit">Project Manager</label> <input type = "text" value = "" name = "pman_edit" id = "pman_edit"></td> <td><label for="deadline_edit">Tender Deadline</label> <input type = "text" value = "" name = "deadline_edit" id = "deadline_edit"></td> </tr> <tr><td><input type="button" value="Update" name="update" onClick="updateProjectDetails()"> heres my php <?php require "config.php"; $proj_id = $_REQUEST['uproj_id']; $access = $_REQUEST['uaccess']; $cable = $_REQUEST['ucable']; $ip = $_REQUEST['uip']; $fault = $_REQUEST['ufault']; $form = $_REQUEST['uform']; $pman = $_REQUEST['upman']; $dl = $_REQUEST['udl']; $q = mysql_query("update project set form='$form', access='$access', cable_entry='$cable', ip_rating='$ip', fault_rating='$fault', proj_manager='$pman', deadline='$dl' where proj_id= '$proj_id'"); ?> Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted July 23, 2008 Share Posted July 23, 2008 looks like an ajax update to me. I can't check the code right now but i'll give you some tips how to track your problem relatively fast. 1. try to run your php page that does the update to database by placing that url into your browser(you prob already did that) 2. change all your post variables to get and echo them to make sure you got all variables when calling the update php directly 3. use firebug to see your ajax call and track your bugs Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.