Jump to content

endorush

New Members
  • Posts

    2
  • Joined

  • Last visited

endorush's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. echo before the variable... ooops!!! lol its working now.... THANKS!!!!
  2. I'm having problem with this code. It's supposed to pull a link from a database and feed it into an iframe src to make the video display on screen. I'm getting a white box... It seems like the "address" variable is getting dropped or something, out of scope? here is the code: <?php /* Attempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "root", "Mm62Tic8FH", "music"); $rand_num; $rowcount; // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Attempt select query execution $sql = "SELECT * FROM songs"; if($result = mysqli_query($link, $sql)){ // query results stored in "result" if(mysqli_num_rows($result) > 0){ $rowcount = mysqli_num_rows($result); $rand_num = rand(0,$rowcount - 1); $address = "5"; echo "<table>"; while($row = mysqli_fetch_array($result)){ echo "<tr>"; echo "<td>" . $row['artist_name'] . "</td>"; echo "<td>" . $row['song_name'] . "</td>"; echo "<td>" . $row['url'] . "</td>"; echo "<td>" . $row['item_id'] . "</td>"; echo "<td>" . $rand_num; echo "</tr>"; if ($rand_num == $row['item_id']) { $address = "https://www.youtube.com/embed/". $row['url']; } echo "----".$address."----"; } echo "</table>"; // Free result set mysqli_free_result($result); } else{ echo "No records matching your query were found."; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?> <iframe width="420" height="315" src=<?php $address ?>> </iframe>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.