User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,572 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,817 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Sep 20th, 2004
Views: 2,554
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.
php Syntax | 2 stars
  1. // Checks if the domain and ip is in the list
  2.  
  3. $quer = mysql_query('SELECT * FROM domains WHERE name="$domain"', $con) or die('No domain in the database');
  4. $quer2 = mysql_query('SELECT * FROM vhostips WHERE ip="$ip"', $con) or die('No IP in the database');
  5. $vhost2 = "$vhost" . "." . "$domain";
  6. $query = "SELECT * FROM vhosts";
  7. $result = mysql_query($query) or die(mysql_error());
  8. $crap = mysql_fetch_array($result);
  9.  
  10. print('$crap["vhost"][0]');
  11. // Eventually we'll have to see if the IP is attached to the server
  12. if ($quer && $quer2) {
  13. $insert = mysql_query("INSERT INTO
  14. vhosts
  15. (id, vhost, ip)
  16. VALUES
  17. ('$id', '$vhost2', '$ip')");
  18. if (!$insert) {
  19. die('Error in MySQL query: ' . mysql_error());
  20. } else {
  21. $blah = "blah";
  22. }
  23. }
  24. // Print the success page
  25.  
  26. if ($blah) {
  27. print('V-Host ' . $vhost2 . ' added. IP: ' . $ip . ".");
  28. }
  29.  
  30. ?>
Comments (Newest First)
Ginetta | Newbie Poster | Feb 20th, 2008
express $con variable (in your sql query)
I don't see it anywhere.
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 5:55 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC