...

View Full Version : :: problems with delete record ajax script..



babelfish
08-08-2008, 03:09 PM
Hi all,

im quite enw to PHP so this may be the wrong way of doing things... it is deleting the record but then i get an apache error. if i then refresh the page the record has been deleted.

this is for an intranet based system im writing:

javascript...


function deleterecord(thetable, theid) {
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) {
alert ("Browser does not support HTTP Request")
return
}

var params = "?theid=" + theid + "&thetable=" + thetable;
var url="_delete_record.php"
url=url+params;
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById("theitems").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject() {
var objXMLHttp=null
if (window.XMLHttpRequest) {
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject) {
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}


php _deleterecord.php ...



$query = "DELETE FROM $thetable WHERE id=$theid";
mysql_query($query) or die('Error ,query failed');

mysql_free_result($result);
writes some data....

derzok
08-08-2008, 04:22 PM
If you're getting an apache error it's not a problem with the javascript - especially if it's getting you to the delete entry php page. What is the error that apache gave you?

babelfish
08-08-2008, 04:32 PM
yeah, didnt think it was JS - just showing you my method in case its the wrong way to do it.

i dont get an error in the error.log in the Apache2\logs folder...

its windows Apache HTTP Server error - the ones where you send an error report.

babelfish
08-11-2008, 09:11 AM
bump...

babelfish
08-11-2008, 04:18 PM
ok, the line "mysql_free_result($result);" was causing the error!

all working now!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum