Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This question already has an answer here:

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?

share|improve this question

marked as duplicate by Second Rikudo May 19 at 15:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Look at the colors in your code, are you sure you got those quotes right ? –  adeneo Mar 21 '13 at 22:36
    
ah sorry, my editor sucks and did not highlight >< –  user2185501 Mar 21 '13 at 22:39
    
inspect what is rendered in the browser –  Jon P Mar 21 '13 at 22:41

3 Answers 3

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

share|improve this answer

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"];?>",

share|improve this answer

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.