Audio upload feature

Im trying to put together code that will aloow visitors to upload audio to a website.
While the audio is stored in a file the information should be passed to a SQL database.
I seem to having problems with this though…
This is what iv put together so far, unfortunatly it doesnt quite work. Any ideas?

[code] <?php $Mix_Namei = getenv("Mix_Name"); $DJi = getenv ("DJ"); $Additional_notesi = getenv ("Additional_Notes"); ?>

DJ Name

Mix Name

Mix Discription

Choose a file to upload: [/code]

[code]

<?php $host= ""; $dbuser= ""; $dbpass= ""; $database= ""; $table= "mp3_files"; $link= @mysql_connect($host, $dbuser, $dbpass) or die ('I cannot connect to the database because: ' . mysql_error()); if (! @mysql_select_db($database,$link)){ mysql_query("CREATE DATABASE $database"); } else { if(! @mysql_query("SELECT * FROM `$table` LIMIT 0,1")){ $sql="CREATE TABLE $table ( id INT NOT NULL auto_increment , Mix_Name VARCHAR(255) NOT NULL , DJ VARCHAR(255) NOT NULL , Additional_Notes VARCHAR(50) NOT NULL , Path VARCHAR(255) NOT NULL , PRIMARY KEY (id) )" ; mysql_query($sql); } } ?>[/code]

[code]

<?PHP if ($_POST['action']) { $dir = "http://www."; $uploadfile = $dir . $_FILES['mp3_file']['name']; move_uploaded_file($_FILES['mp3_file']['tmp_name'], $uploadfile); include 'check.php'; $sql = "INSERT INTO $table (Mix_Name, DJ, Additional_Notes, Path ) VALUES ($_POST[name], $_POST[DJ], $_POST[notes],$uploadfile)"; mysql_query($sql); } ?>[/code]

There’s a pretty nice code snippet on this page. Your $dir variable for example, is probably messing up, but use error_reporting() to make sure you don’t get any other issues.

Sponsor our Newsletter | Privacy Policy | Terms of Service