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?
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]