DannyCarlton.net Feedback Forums | register | login
phpBible.org

    Return to Page 3
re: Install Problem in 1.0.6 (suggested fix)
Dec. 20th, 2005   2:39pm

Here’s a suggested modification to the install routine to work around my problem. It DID fix the problem and I’ve gotten the Bible up and running with only this change.

Code lines below may have wrapped!!!!!!

<?php

# Begin Brandon’s changes to the populate_db.php file for phpBible 1.0.6
# The changes were made because the original code depended on opening the entire file at one time, like this:
# $av_text = file(("./phpBible_av.dat"); # Brandon removed this line
# For whatever reason my server choked on this file size. A smaller file could be opened (about 3mb) but not
# the 9mb file that ships with the install.
# The code was modified to read the file incrementally, and use each line one by one.

if (!$fp = fopen("./phpBible_av.dat", "r")) {die("Couldn’t open file.");} # Brandon added this line

$table_name=$table_prefix;
$table_name.=’av’;

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

$query = "CREATE TABLE $table_name (row int(2), book int(2), chapter int(3), verse int(3), text text, coding text);";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
echo "Table ’$table_name’ created.<br>\n";

for($i=0;$i<=31101;$i++)
  {
  $row=$i+1;
  $temp = fgets($fp, 2000); # Brandon added this line
#  $temp=$av_text[$i]; # Brandon deleted this line
  $temp=str_replace("\n", ’’, $temp);
  $temp=str_replace("\r", ’’, $temp);
  $temp=str_replace(’INTO av VALUES (’, "INTO $table_name VALUES (", $temp);
  if($temp){$result = mysql_query($temp) or die("Query failed ($i) : " . mysql_error());}
  }
echo "Table ’$table_name’ populated.<br>\n";

$table_name=$table_prefix;
$table_name.=’books’;

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

$query = "CREATE TABLE $table_name (number int(2) DEFAULT ’0’ NOT NULL, book char(20) NOT NULL, chapters int(3), abbr text,

PRIMARY KEY (number));";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
echo "Table ’$table_name’ created.<br>\n";

$temp = fgets($fp); # read a blank line to skip the blank line in the phpBible_av.dat file # Brandon added this line

for($i=31103;$i<=31168;$i++)
  {
  $temp = fgets($fp, 2000); # Brandon added this line
#  $temp=$av_text[$i]; # Brandon deleted this line
  $temp=str_replace("\n", ’’, $temp);
  $temp=str_replace("\r", ’’, $temp);
  $temp=str_replace(’INTO books VALUES’, "INTO $table_name VALUES", $temp);
  if($temp){$result = mysql_query($temp) or die("Query failed ($i) : " . mysql_error());}
  }
echo "Table ’$table_name’ populated.<br>\n";

fclose($oldfp);  # Brandon added this line

# End of Brandon’s changes

?>

Brandon (138.162.0.37)


    Return to Page 3
This Thread

Post a Message
Name:

Subject:

Message:


page processed in 0.00177407264709 seconds
Return to DannyCarlton.net main page