I create a datebase named "mp3". Know I want to create a table called "contents" that will consist of

ID Primary Key
Song Name
Artist
Release Date
Additional Notes
File {contain mp3 file}

I will collect all this info through a PHP form. How do I load all this info into the table called "contents" and can you load mp3 files into an mysql database??

I have never dealt with MP3 file and MYSQL so I need some guidance

this is the PHP form so far

print<<<HTML
<table>
<form action="upload.php" method="post" enctype="multipart/form-data">

<tr><td><b>MP3 Info:</b></td></tr>
<tr><td>Song Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Artist: </td><td><input type="text" name="artist"></td></tr>
<tr><td>Release Date: </td><td> <input type="text" name="release_date"></td></tr>
<tr><td>Additional Notes</td></tr>
<tr><td></td><td><TEXTAREA NAME="note" COLS=40 ROWS=6></TEXTAREA></td></tr>
<tr><td>Select a File to Upload:</td>
<td><input type="file" name="mp3_file">
<input type="Submit" value="Upload File"></td></tr>

</form>
</table>

    Several flaws in your design:

    • Don't store an MP3 in a database unless you want it to not work.

    • Don't use print, use echo.

    • Actually, don't use echo either. Escape out of PHP so you speed up the program.

    And you could just read the ID3 tag out of the MP3, which would save them from having to enter the information.

      I decided to create a directory on my server to store the mp3 files instead and then to store the files path in the mysql

      so I would first create the table like this

      $sql = CREATE TABLE mp3_files (
      id int NOT NULL AUTO_INCREMENT Primary Key,
      Song Name VARCHAR,
      Artist Artist VARCHAR ,
      Release_Date date,
      Additional Notes VARCHAR,
      Path ?? );

      where "Path" would it me VARCHAR type?? and how would I store the absolute path of the file using PHP

      Lets say I had a folder called MP3_Files on my server that would contain all my mp3 files and I uploaded an mp3 song called big poppa? How would I store this location so that when I go to retrieve this file it know the exact one??

        I am trying to use the move_uploaded_file function to copy a file from my hard drive and move it into a directory on the server. The first agrument that I used with move_uploaded_file function is $uploadedfile because in my form I have the following <input type = "file" name = "uploadedfile"> the second argument is $folder because this variable contain the location of the directory that I want to save the file to

        $folder = "C:\Program Files\Apache Group\Apache2\htdocs\mp3_files";

        When I run a test of uploading a file and copying it to directory I get the following errors

        Warning: move_uploaded_file(C:\Program Files\Apache Group\Apache2\htdocs\mp3_files) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Program Files\Apache Group\Apache2\htdocs\upload.php on line 6

        Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\php4.tmp' to 'C:\Program Files\Apache Group\Apache2\htdocs\mp3_files' in C:\Program Files\Apache Group\Apache2\htdocs\upload.php on line 6

        what am I doing wrong??? How can I correct the problem??

        ?php

        if ($_POST['action']) {

        $folder = "C:\Program Files\Apache Group\Apache2\htdocs\mp3_files";
        move_uploaded_file($uploadedfile, $folder);

        }

        ?>

        <html>
        <head>
        <title></title>
        </head>
        <body>
        <table>
        <form action="upload.php" method="post" enctype="multipart/form-data">

        <tr><td><b>MP3 Info:</b></td></tr>
        <tr><td>Song Name:</td><td><input type="text" name="name"></td></tr>
        <tr><td>Artist: </td><td><input type="text" name="artist"></td></tr>
        <tr><td>Release Date: </td><td> <input type="text" name="release_date"></td></tr>
        <tr><td>Additional Notes</td></tr>
        <tr><td></td><td><TEXTAREA NAME="note" COLS=40 ROWS=6></TEXTAREA></td></tr>
        <tr><td>Select a File to Upload:</td>
        <td><input type = "file" name = "uploadedfile">
        <input type="Submit" name="submit" value="UpLoad">
        <input type="hidden" name="action" value=1>
        </td></tr>
        </form>
        </table>
        </body>
        </html>

          "Permission denied" means the web server does not have permission to write a file where you are asking it to do so.
          Since you're on a Windows box I can't tell you exactly how to fix that.

          If the MP3 files have artist data embedded in them, you don't have to ask your users to fill out a form. Example:

          http://www.phpfreaks.com/quickcode/code/127.php

            I need help using if, else, elseif statement to do the following

            Check if a "mp3db" database is present
            if not create the "mp3db" database
            if "mp3db" is present check to see if "mp3_files" tableis present
            if not create "mp3_files" table
            if table is present connect to table then goto to "input.php" file

            I basically need help create the layout/outline of statement for the above action.

            example:

            if (Check if a "mp3db" database is present){
            database is present}

            else
            create database

            etc.........

              I create this file listed below but I am getting this error when I run it:

              Can't create mp3_files table You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name VARCHAR, Artist VARCHAR , Release_Date date, Additional

              The syntax looks good to me what's wrong with it??

              <?php

              $host= "localhost";
              $dbuser= "unsernamer";
              $dbpass= "password";
              $database= "mp3_db";
              $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
              {
              $sql="CREATE TABLE $table (
              id int NOT NULL AUTO_INCREMENT Primary Key,
              Song Name VARCHAR,
              Artist VARCHAR ,
              Release_Date date,
              Additional_Notes VARCHAR,
              Path VARCHAR )";

              $query1 = mysql_query($sql);

               if ($query1){
               print "<p>$table table created</p>";
               } else {
               $error = 1;
               echo("<p>Can't create $table table ". mysql_error() ."<p>");
               }

              }

              ?>

                I have two php files one check to see if a database and table is present if it's not it create both (check.php). The other collects info from a form and then inputs that data to the database and copy the mp3 file to a location on my computer(masterupload.php).

                So far the only to things I know thats working is that it will create a database or table if one is not present {check.php files does that} and that it will copy the file to a location on the server {masterupload.php does that} But the problem I am having is that it won't copy info from the form to the table here are the two php files in question:

                Why am I unable to write info from the form to the mysql table???

                this is the masterupload.php whick includes an call to the check.php file via include()

                <?php

                if ($_POST['action']) {

                /$dir = "/home/nucity44/public_html/mp3_files/";/
                $dir = "C:\Program Files\Apache Group\Apache2\htdocs\mp3_files\";

                $uploadfile = $dir . $_FILES['mp3_file']['name'];

                move_uploaded_file($_FILES['mp3_file']['tmp_name'], $uploadfile);

                include 'check.php';

                $sql = "INSERT INTO $table (Song_Name, Artist, Release_Date, Additional_Notes, Path )
                VALUES ($POST[name], $POST[artist], $POST[date], $POST[notes],$uploadfile)";

                mysql_query($sql);
                }
                ?>

                check.php

                <?php

                $host= "localhost";
                $dbuser= "usernamer";
                $dbpass= "password";
                $database= "mp3_db";
                $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(! @("SELECT * FROM $table LIMIT 0,1")){

                $sql="CREATE TABLE $table (
                id INT NOT NULL auto_increment ,
                Song_Name VARCHAR(255) NOT NULL ,
                Artist VARCHAR(255) NOT NULL ,
                Release_Date DATE NOT NULL ,
                Additional_Notes VARCHAR(255) NOT NULL ,
                Path VARCHAR(255) NOT NULL ,
                PRIMARY KEY (id)
                )" ;

                mysql_query($sql);
                }
                }
                ?>

                  Write a Reply...