views:

26

answers:

2

Hey guys,

I've got a function which sends the "id" value to a php file but all it's send is null.. can anyone spot why?

(the value of id is not null)

function send(point, name, message, type, file, id, lat, lng) {
var html = "<b>" + name + "</b> <br/>" + message + '<IMG SRC=\"'+file+'\">' + ' <br> id = ' + id + "<a href=delete.php?id="+ <?php echo "\"".$nt['id']."\""?> +">Delete Entry</a>";
}
A: 

oh I am wrong sorry

Iznogood
+1  A: 

you appear to use a javascript argument id and php variable $nt['id'] in your code, I'd assume you either need to use one or the other - logic dictates that if the js argument id is not null then you use that, if the PHP variable $nt['id'] is not null then use that.

If they are both null then you need to be checking more of the script that just this little snippet :)

function send(point, name, message, type, file, id, lat, lng) {
  var html = '<b>' + name + '</b><br/>'
   + message
   + '<img src="' + file + '">'
   + ' <br> id = <?php echo $nt['id']; ?>">'
   + '<a href="delete.php?id=<?php echo $nt['id']; ?>">Delete Entry</a>';
}

or

function send(point, name, message, type, file, id, lat, lng) {
  var html = '<b>' + name + '</b><br/>'
   + message
   + '<img src="' + file + '" />'
   + '<br/> id = ' + id
   + '<a href="delete.php?id=' + id + '">Delete Entry</a>';
}

may also be worth pointing out you really shouldn't be using GET params for a script such as 'delete.php' - what happens if they have a link checker, anti virus, or internet speeder which pre requests links? and technically, GET is a 'safe' HTTP method (a client should expect no action to be taken and no change to any resources to be made in response to a gET on an URL).

nathan