I have two tables: one hostgroup_host and the other one hostgroups. The hostgroups represents the names of all the host groups and has 3 important values (hostgroup_id, name and alias). The hostgroup_host makes the connection between the groups and the hosts and has two values (hostgroup_id and host_id).
Example:
hostgroup_id = 1 and host_id = 3 it means that host which id is number 3 belongs to hostgroup with id = 1 (with a specific name).
I have this:
$name=$_POST['name']; $alias=$_POST['alias']; $address=$_POST['address']; $hostgroup=$_POST['hostgroup'];
mysql_connect('localhost:/usr/local/groundwork/mysql/tmp/mysql.sock', $username ,$password); @mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO hosts (host_id, name, alias, address, hosttemplate_id) VALUES ('','$name','$alias','$address', '1'); INSERT INTO hostgroup_host (hostgroup_id, host_id) VALUES ((select hostgroup_id from hostgroups where name='$hostgroup'), (SELECT host_id from hosts where name = '$name'))"; mysql_query($query);
mysql_close(); ?>
Why doesn't work?