My Latest Script

Syneticus 0 Tallied Votes 100 Views Share

Alrighty! My goal here is to add the specified information into a MySQL database, but then also include a script that goes back and checks to make sure that the entrie given does not already exist. If you have any corrections, or any ideas on how to do this, I'd really appreciate it. I posted something simliar in the PHP section, but figured it might be more appropriate to put my code in the snippets.

// Checks if the domain and ip is in the list 

$quer = mysql_query('SELECT * FROM domains WHERE name="$domain"', $con) or die('No domain in the database'); 
$quer2 = mysql_query('SELECT * FROM vhostips WHERE ip="$ip"', $con) or die('No IP in the database'); 
$vhost2 = "$vhost" . "." . "$domain"; 
$query = "SELECT * FROM vhosts"; 
$result = mysql_query($query) or die(mysql_error()); 
$crap = mysql_fetch_array($result); 

print('$crap["vhost"][0]'); 
// Eventually we'll have to see if the IP is attached to the server 
if ($quer && $quer2) { 
$insert = mysql_query("INSERT INTO 
vhosts 
(id, vhost, ip) 
VALUES 
('$id', '$vhost2', '$ip')"); 
if (!$insert) { 
die('Error in MySQL query: ' . mysql_error()); 
} else { 
$blah = "blah"; 
} 
} 
// Print the success page 

if ($blah) { 
print('V-Host ' . $vhost2 . ' added.  IP: ' . $ip . "."); 
} 

?>
Ginetta 0 Newbie Poster

express $con variable (in your sql query)
I don't see it anywhere.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.