javascript - echo PHP variable into JS parentheses -


in loop have link sends id via query string, want through ajax. i've attempted through setting php variable js variable , haven't had success. try says illegal token.

(it's on 8th line).

<?php //we display list of read messages while($dn2 = mysql_fetch_array($req2)) { ?>          <tr>         <td class="left"><a href="#" onclick="hello('"<?php echo $dn1['id']; ?>"')"><?php echo htmlentities($dn2['title'], ent_quotes, 'utf-8'); ?></a></td>         <td><?php echo $dn2['reps']-1; ?></td>         <td><a href="profile.php?id='.<?php echo $dn2['userid']; ?>'."><?php echo htmlentities($dn2['username'], ent_quotes, 'utf-8'); ?></a></td>         <td><?php echo date('y/m/d h:i:s' ,$dn2['timestamp']); ?></td>     </tr> <?php } 

you have way many quotes going on here. i've cleaned below.

<?php //we display list of read messages while($dn2 = mysql_fetch_array($req2)) { ?>         <tr>         <td class="left"><a href="#" onclick="hello('<?php echo $dn1['id']; ?>')"><?php echo htmlentities($dn2['title'], ent_quotes, 'utf-8'); ?></a></td>         <td><?php echo $dn2['reps']-1; ?></td>         <td><a href="profile.php?id=<?php echo $dn2['userid']; ?>"><?php echo htmlentities($dn2['username'], ent_quotes, 'utf-8'); ?></a></td>         <td><?php echo date('y/m/d h:i:s' ,$dn2['timestamp']); ?></td>     </tr> <?php } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -