Jump to content

[SOLVED] Logic Errors


phatgreenbuds

Recommended Posts

So I have this little bit of logic going where the code below will check one table for an entry. If it finds it then the $path is set and writes to a file. If its not then it should perform a query against another table for a default (random) entry to write to that same file.  SO far this will work but only if I leave out the second query. With it in it keeps giving the following error: "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/esv/aMT_dallas_playlist.php on line x"

 

<?php
//Starts the Query for content to write to the playlist
$query = "SELECT * FROM $MTtblname WHERE content_region = 1";
$content = mysql_query($query);
$num = mysql_num_rows($content); 
//

//Opens the playlist file to start writing assuming there is at least one entry
if ($num != 0) {
    $file = fopen("../test/Videos/MTdallas_playlist.wsx", "w");
    $wsxpl = "<?wsx version=\"1.0\"?>\r\n";
    $wsxpl .= "<smil repeatCount=\"indefinite\">\r\n";

    while ($row = mysql_fetch_assoc($content))
        $exists[$row['tbl_slot']] = $row['content_win_path'];
    for ($count = 1; $count <= 60; $count++) {
      		
	if (key_exists($count,$exists)) { //if there is an entry in that time slot then use it and place it in the file
	$path = $exists[$count];

	}else{ // otherwise go to the default table and pull a random entry into the playlist

		$queryx = "SELECT * FROM $tbl_def_content ORDER BY RAND()";
		$contentx = mysql_query($queryx);
		while ($rowx = mysql_fetch_array($contentx)) {
			$path = $rowx['content_win_path'];
			}
		}

	echo $count . ': ' . $path . '<br>';
        $wsxpl .= "\t<media src=\"" . $path . "\"/>\r\n";
    }
?>

Link to comment
https://forums.phpfreaks.com/topic/131989-solved-logic-errors/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.