0

Hey I'm Trying To add some data in my table through a form .
But the form is not working or somethings wrong with my PHP code .

This is the HTML

        <form action="upload.php" method="post" enctype="multipart/form-data" name="subform" id="subform" class="forms" role="form" >

        <label>    
        <input name="title" id="title" type="text" class="form-control" placeholder="put the title here">
        </label>

        <label>    
        <input name="singer" id="singer" type="text" class="form-control" placeholder="Artist / Band">
        </label>

        <label>    
        <input name="songname" id="songname" type="text" class="form-control" placeholder="Song Name">
        </label>

        <label>
        <input name="lyrics" id="lyrics" type="text" class="form-control" placeholder="Lyrics">
        </label>

        <label>    
        <input name="arrange" id="arrange" type="text" class="form-control" placeholder="Arrangement By ?">
        </label>

        <label>    
        <input name="channel" id="channel" type="text" class="form-control" placeholder="Channel">
        </label>

        <label>
        <input name="dllink" id="dllink" type="text" class="form-control" placeholder="Download Link">
        </label>

        <label>
        <select name="category" id="category" class="form-control">
        <option>Pop</option>
        <option>Rock</option>
        <option>Rap</option>
        <option>Classic</option>
        </select>
        </label>

        <label><input name="cover" id="cover" type="file" class="form-control"
        placeholder="Cover"></label>

        <div class="submit-btn">
        <input type="submit" class="Btn_submit" id="submit" name="button" />
        </div>

        </form>

And This is The PHP :

 if(isset($_POST['title'])){
$title = mysql_real_escape_string($_POST['title']);

$category = mysql_real_escape_string($_POST['category']);

$singer = mysql_real_escape_string($_POST['singer']);

$songname = mysql_real_escape_string($_POST['songname']);

$arrange = mysql_real_escape_string($_POST['arrange']);

$lyrics = mysql_real_escape_string($_POST['lyrics']);

$dllink = mysql_real_escape_string($_POST['dllink']);

$channel = mysql_real_escape_string($_POST['channel']);

$sql = mysql_query("INSERT INTO songs (title, category, singer, sname, arrangement, lyrics, download, channel, reldate) VALUES('$title','$category','$singer','$songname',$arrange','$lyrics','$dllink','$channel',now())");

$sid = mysql_insert_id();
$newname = "$sid.jpg";
move_uploaded_file($_FILES['cover']['tmp_name'], "../covers/$newname");
header("location: upload.php");
}

Do You know What i'm doing wrong here ? i've done this before with no problems .
but it seems like i'm forgetting something this time .

1
  • what error it's showing?? Commented Apr 30, 2014 at 8:14

2 Answers 2

2

You have a syntax error in your SQL query:

',$arrange'

There is a missing '.

You can check for SQL errors by running echo mysql_error(); after the query.

Side note: The mysql_* functions you are using are becoming deprecated and will be removed from future PHP versions. Your code will stop working then. If you write new code, use mysqli_* functions or PDO instead.

Sign up to request clarification or add additional context in comments.

Comments

0

You have not passed the connection variable to mysql_query function.

If you are getting the connection by some other way then do the following and see:

Just print the whole post array and see anything missing. Also print file array and see the presence of file and error.

1 Comment

The connection parameter is optional for mysql_query().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.