2DWorlds Forums
MySQL - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: Off Topic (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=5)
+--- Forum: Programming (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=30)
+--- Thread: MySQL (/showthread.php?tid=7036)



MySQL - Dignity - 07-19-2011

When using MySQL, wouldn't this create multi-databases?

Code:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die(mysql_error());
  }

if (mysql_query("CREATE DATABASE my_db",$con))
  {
  echo "Database created";
  }
else
  {
  echo mysql_error();
  }

mysql_close($con);
?>

One every time the page is loaded?



RE: MySQL - Jacob__mybb_import1 - 07-19-2011

(07-19-2011, 04:35 PM)roperson Wrote: When using MySQL, wouldn't this create multi-databases?

Code:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die(mysql_error());
  }

if (mysql_query("CREATE DATABASE my_db",$con))
  {
  echo "Database created";
  }
else
  {
  echo mysql_error();
  }

mysql_close($con);
?>

One every time the page is loaded?

I think it would cause an error, because you can't have 2 databases with the same name.


RE: MySQL - Dignity - 07-19-2011

So...

Just create a ConnectionTest.php page, and create the db, and the tables, and then add stuff to the in the forum and stuff?