Page 1 of 1

Problem with a variable value...

Posted: Tue Jul 06, 2010 12:08 pm
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

Re: Problem with a variable value...

Posted: Tue Jul 06, 2010 12:50 pm
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.

Re: Problem with a variable value...

Posted: Tue Jul 06, 2010 1:05 pm
by jotae
Thanks for the code and the favor :-). All ok.