Location: PHPKode > projects > phpBible > phpbible/install/populate_db2.php
<?php


reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) 
  {
  $$key=$value;
  }

reset ($HTTP_GET_VARS);
while (list ($key, $val) = each ($HTTP_GET_VARS)) 
  {
  $$key=$value;
  }

echo "<html>

<head>
<title>phpBible.org</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"../phpBible.css\">
</head>

<body class=\"light\"><center>

<b><font color=\"$page_dark\" size=\"7\" face=\"Georgia\">phpBible.org<br>
</font><font color=\"$page_dark\" face=\"Georgia\" size=\"4\">Online Study Bible</font></b><br>
<font color=\"$page_dark\"><b><font face=\"Verdana\" size=\"3\">Installation: Step 3</font></b><br>
";


require("../config.php");
$link = mysql_connect($host, $user, $password)
    or die("Could not connect : " . mysql_error());


$db_list = mysql_list_dbs($link);

$i = 0;
$cnt = mysql_num_rows($db_list);
while ($i < $cnt)
  {
  $temp=mysql_db_name($db_list, $i);
  $names.="%%%$temp%%%";
  $i++;
  }
if(!strstr($names, $db_name))
  {
  if (mysql_create_db($db_name))
    {
    echo "Database '$db_name' created successfully<br>\n";
    }
  else
    {
    echo "Error creating database: " . mysql_error() . "\n";
    }
  }

mysql_select_db($db_name) or die("Could not select database");


$table_name=$table_prefix;
$table_name.='greek_lexicon';

$query = "DROP TABLE IF EXISTS $table_name;";
$result = mysql_query($query) or die("Query failed : " . mysql_error());

$query = "CREATE TABLE $table_name (number int(5), orig_word text, word_orig text, translit text, tdnt text, phonetic text, part_of_speech text, st_def text, IPD_def text);";
$result = mysql_query($query) or die("Query failed (creating table): " . mysql_error());
echo "Table '$table_name' created.<br>\n";

$in_data=file("./Greek_Lexicons.dat");
$query='';
for($i=0;$i<count($in_data);$i++)
#for($i=0;$i<20;$i++)
  {
  $query.="INSERT INTO $table_name VALUES ( ";
  $row=explode('|', str_replace("\n", '', str_replace("'", "\'", str_replace('\\', '\\\\', $in_data[$i]))));
  for($r=0;$r<count($row);$r++)
    {
    $query.="'$row[$r]'";
    if($r<8){$query.=', ';}
    }
  $query.=");";
  $result = mysql_query($query) or die("Query failed <br>(<font color=red><b>$i. </b><pre>$query</pre>)<br> : " . mysql_error());
  $query='';
  }

echo "Table '$table_name' populated.<br>\n";


##   HEBREW

$table_name=$table_prefix;
$table_name.='hebrew_lexicon';

$query = "DROP TABLE IF EXISTS $table_name;";
$result = mysql_query($query) or die("Query failed : " . mysql_error());

$query = "CREATE TABLE $table_name (number int(5), orig_word text, word_orig text, translit text, tdnt text, phonetic text, part_of_speech text, st_def text, IPD_def text);";
$result = mysql_query($query) or die("Query failed (creating table): " . mysql_error());
echo "Table '$table_name' created.<br>\n";

$in_data=file("./Hebrew_Lexicons.dat");
$query='';
for($i=0;$i<count($in_data);$i++)
#for($i=0;$i<20;$i++)
  {
  $query.="INSERT INTO $table_name VALUES ( ";
  $row=explode('|', str_replace("\n", '', str_replace("'", "\'", str_replace('\\', '\\\\', $in_data[$i]))));
  for($r=0;$r<count($row);$r++)
    {
    $query.="'$row[$r]'";
    if($r<8){$query.=', ';}
    }
  $query.=");";
  $result = mysql_query($query) or die("Query failed <br>(<font color=red><b>$i. </b><pre>$query</pre>)<br> : " . mysql_error());
  $query='';
  }

echo "Table '$table_name' populated.<br>\n";
echo "
<br>The link below will take you to the administration script. Bookmark it so you'll be able to return. Also, for security,  remove the install.php script as well as the install folder/directory.</br>
<p align=\"center\"><a href=\"../admin/admin.php\">Click to continue...</a></p>
</center>
</body>

</html>";
?> 
Return current item: phpBible