Problem with a variable value...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jotae
Forum Commoner
Posts: 25
Joined: Fri Jul 02, 2010 5:49 pm

Problem with a variable value...

Post by jotae »

In this code

Code: Select all

<?php
//....more code....
 while ($row=mysql_fetch_assoc($result))
      {
       //echo '<tr><td>'.$row["tema"].'</td>';
      ?>
      <td>
       <a href="javascript:void(null)" onclick="mp3('http://www.prolatin.net/musica/<?php echo $row["archivo"];?>,1,280,67')"><?php echo $row["tema"]; ?></a> // here work OK...
      </td>
      <?php
       echo '<td>'.$row["ritmo"].'</td>';
       echo '<td>'.$row["archivo"].'</td>';
       //echo '<td>'.$row["archiletra"].'</td>';
       if ($row["archiletra"]<>''){
       <td>
       <A href="javascript:void(null)" onclick="ventana(<?php echo $row["archiletra"]; ?>)">OK!</A> // here don´t work
       </td>
       <?php
       }else{
        echo '<td>'."".'</td>';
       }
       if ($row["karaoke"]=='Y'){
        echo '<td>'."OK".'</td>';
       }else{
        echo '<td>'."".'</td>';
       }
       echo '<td>'.$row["fecha"].'</td></tr>';
      }
      mysql_free_result($result)
     ?>
    </table>

   </div>
   <div class="xr_ap" style="left: 22px; top: 1746px; width: 757px; height: 27px;">
     <script>
      function ventana(url){
        alert(url)
        nueva=window.open(url,"ventana","menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,height=350,width=380")
       }
      </script>
      
The alert in the function (for testing archiletra value) say: UNDEFINED. Can help me please what are wrong?. Thanks
Last edited by jotae on Tue Jul 06, 2010 12:51 pm, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Problem with a variable value...

Post by requinix »

Your problem is with bad JavaScript code, not variables.

Code: Select all

onclick="verletra('<?php echo htmlentities($row["archiletra"], ENT_QUOTES); ?>')"
I added the 's and even did you a favor of including that htmlentities.
jotae
Forum Commoner
Posts: 25
Joined: Fri Jul 02, 2010 5:49 pm

Re: Problem with a variable value...

Post by jotae »

Thanks for the code and the favor :-). All ok.
Post Reply