0

I have the following code:

FB.getLoginStatus(function (response) {
    if (response.status === "connected") {
        FB.api("me/bookvote:download", "post", {

        }, //Missing a , here?

however, I am still getting:

 Uncaught SyntaxError: Unexpected identifier 
 for  book: "<?php echo "http://mysite.xom/auction_details.php?name=$item_details["name"]&auction_id=$item_details["auction_id"]";?>",

what could be wrong in my php variable to JavacScript?

3 Answers3

3

Wrap { } around your array items inside your string, like {$item_details["name"]}

Uberfuzzy
  • 8,253
  • 11
  • 42
  • 50
1

Magic quotes are no longer supported. Change

book: "<?php echo "http://mysite.xom/auction_details.php?name=$item_details["name"]&auction_id=$item_details["auction_id"]";?>",

to

book: "<?php echo "http://mysite.xom/auction_details.php?name=" . $item_details["name"] . "&auction_id=" . $item_details["auction_id"];?>",

zajd
  • 761
  • 1
  • 5
  • 18
1

You're not concatenating properly in your PHP code:

FB.getLoginStatus(function (response) {
    if (response.status === "connected") {
        FB.api("me/bookvote:download", "post", {
            book: "<?php echo 'http://mysite.xom/auction_details.php?name='. $item_details['name'] . '&auction_id=' . $item_details['auction_id']; ?>",
            fb:explicitly_shared = "true" //? Is syntactically valid but creates a global
        },

For readability, I replaced double quotes in your PHP code with single quotes.

HellaMad
  • 5,294
  • 6
  • 31
  • 53