PHP多个文件上传多个输入

I'm new to PHP. Now i have a problem with files upload. All files are moved, but It didn't store file's name to database. and it didn't show error. I have no idea to fix this one. Please help me out.

<form method="post" action="index.php?insert_ads" enctype="multipart/form-data">
    <input type="file" name="b1" id="b1"/>

    <b>Link</b></br>
    <input type="text" id="b1l" name="b1l" class="form-control"/></br>

    <b>Home Small</b> <b style="color: blue;">100 x 100 px</b></br>
    <input type="userfile" name="b2" id="b2"/><br>

    <b>Link</b></br>
    <input type="text" id="b2l" name="b2l" class="form-control"/></br>

    <input type="submit" name="submit" value="Publish"/>

</form></br>

<?php 

if(isset($_POST['submit'])){

    $b1 = $_FILES['b1']['name'];
    $tmp1 = $_FILES['b1']['tmp_name']; 
    $b1l = $_POST['b1l'];
    $b2 = $_FILES['b2']['name'];
    $tmp2 = $_FILES['b2']['tmp_name'];
    $b2l = $_POST['b2l'];

    move_uploaded_file($tmp1,"ads/$b1");
    move_uploaded_file($tmp2,"ads/$b2");

    $insert_posts = "insert into ads (b1,b2) value ('$b1','$b2')";
    $run_posts = mysql_query($insert_posts);
}
?>

Notwithstanding any issues about using mysql_query or injection attacks, there are a number of things that could be going wrong here.

One option is that the query is executing, but you haven't assigned the $b1 and $b2 variables correctly. This would be the case if rows are being added to the database, but the rows are empty (e.g., SELECT b1, b2 FROM db.ads" returns rows of '',''); in that case, you probably just aren't extracting the name attribute from the $_FILES variable correctly. You can run var_dump($_FILES); to see more information about it and figure out what you need to get.

Another possibility is that the query is not executing. Again, this may be for a couple of reasons -- maybe (somehow) it's not reaching that point in the code. You can test that like so:

$insert_posts = "insert into ads (b1,b2) value ('$b1','$b2')";
echo $insert_posts; // if this shows up, you're running the next line also
$run_posts = mysql_query($insert_posts);

Another option is that your error reporting level is not capturing an error. A likely cause of this is that you have not connected to the database -- according to the mysql_query documentation...

If no connection is found or established, an E_WARNING level error is generated.

A E_WARNING level error will allow the program to continue to execute unless you have configured your program to behave differently.

Finally, you may have a syntax error (and indeed it seems you do -- VALUES, not VALUE); according to the documentation, mysql_query returns false on error -- it does not throw an error.

You can rig it to do so by testing for false and using the mysql_error function to get the error:

$run_posts = mysql_query($insert_posts);
if ($run_posts === false) { 
  trigger_error("Error in SQL!
" + mysql_error(), E_USER_ERROR); 
}