Wordpress:来自表单操作文件的MySQL查询

I have a PHP file that I've set as the action of my form within a Wordpress template page. I made a custom table in the WP DB and I need the PHP script to run some SQL to insert data into it. How do I connect to the WP database from this standalone action file?

you can use the wpdb class ... read the documentation to understand more http://codex.wordpress.org/Class_Reference/wpdb

In that case . if its a seperate table and a php then u can use the normal mysql connect

<?php
    $con = mysql_connect("localhost","username","password");
    if (!$con)
     {
      die('Could not connect: ' . mysql_error());
     }
     if (mysql_query("inset into table values() my_db",$con)){
       // done
      }
?>

but i wouldn't recomment this ... its better to remain inside the context of wordpress . it has a good framework which u can make good use of