1

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>";
}
1
  • 1
    180 chars in one LOC is 100 chars too many, especially if it's PHP+HTML+JS mish-mash. Consider breaking your code down into readable chunks. Also, do a var_dump to see if $nt['id'] actually contains something. Commented Jul 22, 2010 at 21:47

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.