PHP into JavaScript Var. Well, I tried the div method and for this I used the code below:
<div class="service-container" data-service="
<?php echo bp_loggedin_user_domain() . BP_XPROFILE_SLUG . '/change-avatar/'; ?>"
style="display:none;"><\div>
<?php
$avatarcount = 0;
if ( is_user_logged_in() ) {
global $bp;
global $current_user;
get_currentuserinfo();
$local = BP_AVATAR_UPLOAD_PATH . '/avatars/' . $bp->loggedin_user->id;
$useremail = $current_user->user_email;
if (!file_exists($local) ) {
echo '<script type="text/javascript">
$(document).ready(function() {
$('.service-container').each(function() {
var container = $(this);
var service = container.data('service');
if(document.URL.search("change-avatar") != -1) { } else {
window.location = service;}
});
});
</script>';
}}?>
Received this syntax error:
Parse error: syntax error, unexpected '').each(function()
{' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';'
What I couldn't figure out?