select_audio.php on line 43

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Goldenlamp
    New Member
    • Jul 2007
    • 6

    select_audio.php on line 43

    Hey.. I'm getting an error.: Warning: in_array() [function.in-array]: Wrong datatype for second argument in select_audio.ph p on line 43

    I'm uploading a audio-file (au).

    The Database has a id int auto_increment
    word varchar(255)

    The ID should give the audio an id with link to the word.
    I'm making a dictation..

    Code:
    <?
    	require("database.inc.php");
    	connectDatabase();
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>V&aelig;lg lyd til <?=$_POST['title']?></title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    <? if(file_exists("text/".$_POST['title'].".txt")) {
    ?>
    <h1>choose sound</h1>
    <h3 style="color:#CC3333">Pas p&aring;! there are allready a dictation with that word.<br />
    Hvis du er ved at lave et nyt diktat, burde du g&aring; <a href="javascript:history.back()">tilbage</a> og v&aelig;lge en anden titel.
    G&oslash;r du ikke det, bliver diktatet med titelen &quot;<?=$_POST['title']?>&quot; erstattet med dette diktat her!</h3>
    <?
    }
    ?>
    <form enctype="multipart/form-data" action="save_dict.php" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="500000" />
    <table border="0">
    <?
    	$result=mysql_query("SELECT word FROM repository;");
    	while($entry=mysql_fetch_array($result)) {
    		$repository[]=$entry[0];
    	}
    	$word_start=0;
    	$word_stop=0;
    	$open=false;
    	$words=array();
    	$content=$_POST['content'];
    	for($i=0;$i<strlen($content);$i++) {
    		if(substr($content,$i,1)=="<" && !$open) {
    			$word_start=$i+1;
    			$open=true;
    		}
    		elseif(substr($content,$i,1)==">" && $open) {
    			$word_stop=$i;
    			$word=substr($content,$word_start,$word_stop-$word_start);
    			if(!in_array($word,$repository)) {
    				$words[]=$word;
    				?>
    				<tr>
    					<td><?=$word?></td>
    					<td><input type="file" name="<?=$word?>" /></td>
    				</tr>
    				<?
    			}
    			$open=false;
    		}
    	}
    ?>
    </table>
    <input type="hidden" name="words" value="<? echo implode(";",$words); ?>" />
    <input type="hidden" name="content" value="<?=$_POST['content']?>" />
    <input type="hidden" name="title" value="<?=$_POST['title']?>" />
    <input type="submit" value="Upload &amp; gem" />
    </form>
    </body>
    </html>
  • coffear
    New Member
    • Nov 2007
    • 20

    #2
    Try echoing out $word and print_r() $repository

    1 possible reason for the error is that the database is not returning any rows so $repository is not getting set.

    Comment

    Working...