Roundcube Community Forum

Release Support => Older Versions => 0.1 Beta 1 => Topic started by: DJDarknez on July 26, 2006, 03:20:23 PM

Title: page not found on mysql.initial.sql
Post by: DJDarknez on July 26, 2006, 03:20:23 PM
I ran through the installation guide in the wiki, and got up to the step of entering /sql/mysql.initial.sql into the address bar in my browser. I get a "page not found" though. According to my FTP software, it's there. I see it there. But it's pretending it's not...
Title: Re: page not found on mysql.initial.sql
Post by: bpat1434 on July 26, 2006, 04:31:14 PM
Well, why would you view it in the browser? It needs to get executed in phpMyAdmin or via an SQL query.....
Title: Re: page not found on mysql.initial.sql
Post by: DJDarknez on July 26, 2006, 04:50:59 PM
OK, well, I'm a n00b when it comes to SQL. Here's what I got, with different variations to the SQL line I tried typing in.

SQL query:

EXECUTE / home / ykslmsuc / public_html / mail / SQL / mySQL.initial.sql

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/home/ykslmsuc/public_html/mail/SQL/mySQL.initial.sql' at line 1
Title: Re: page not found on mysql.initial.sql
Post by: bpat1434 on July 26, 2006, 05:33:18 PM
EXECUTE is for prepared statements :(

You need to either use your database management system (phpMyAdmin) or create an execute script, put itn the /mail/SQL/ folder and execute it:
// Which file will we use?
$filename = 'mySQL.initial.sql';

/**
 * DO NOT EDIT THIS SECTION!!
 */
include_once('../config/db.inc.php');
list($info, $host) = explode('@', $rcmail_config['db_dsnw']);
list($type, $login) = explode('://', $info);
list($user, $pass) = explode(':', $login);
list($host, $db) = explode('/', $host);

if(strtolower($type) != 'mysql')
  die('Sorry, this script works for mySQL only.');

$conn = @mysql_connect($host, $user, $pass);
if(!$conn)
  die('Connection can not be established.');
@mysql_select_db($db, $conn);

// Get the SQL file information:
$sql = file_get_contents($filename);

// Okay, execute it :)
$result = @mysql_query($sql);

if(!$result)
  echo 'There was an error executing the contents of '. $filename. '.
Error #'. mysql_errno().': '.mysql_error();
else
  echo 'SQL statement executed successfully!!';

?>

Run that once, then try. Or just use your phpMyAdmin DB interface.
Title: Re: page not found on mysql.initial.sql
Post by: DJDarknez on July 26, 2006, 07:12:35 PM
OK, I copy and pasted that script into a php file, uploaded it to the SQL folder, and went to that file in the browser (assuming that was the right thing to do)

There was an error executing the contents of mySQL.initial.sql.
Error #1065: Query was empty
Title: Re: page not found on mysql.initial.sql
Post by: DJDarknez on July 30, 2006, 03:40:12 PM
?
Title: Re: page not found on mysql.initial.sql
Post by: bpat1434 on July 30, 2006, 11:19:08 PM
// Which file will we use?
$filename = 'mysql.initial.sql';


/**
 * DO NOT EDIT THIS SECTION!!
 */
try
{
$sql = @file_get_contents($filename);
if(!$sql)
throw new Exception('File ('.$filename.') wasn\'t found.');
}
catch (Exception $e)
{
echo 'Error: '. $e->getMessage().'

Trying directory above first....
';
// Let's try the directory above it ;)
try
{
$path = realpath('../');
if(substr($path, -1) == '/')
$path = substr($path, 0, -1);

$sql = @file_get_contents($path.'/'.$filename);
if(!$sql)
throw new Exception('File ('$path.'/'.$filename.') wasn\'t found.');
}
catch (Exception $e)
{
echo 'Error: '. $e->getMessage().'

Trying the directory below the current one, most likely named SQL';

// Let's try the direcotry below it :)
try
{
$path = realpath('./SQL/');
if(substr($path, -1) == '/')
$path = substr($path, 0, -1);
$sql = @file_get_contents($path.'/'.$filename);
if(!$sql)
throw new Exception('File ('.$path.'/'.$filename.') wasn\'t found.');
}
catch (Exception $e)
{
echo 'Error: '. $e->getMessage().'



Sorry,

the file ('. $filename. ') was not found in the current directory, or the ones above and below it. Make sure your paths are correct.';
exit();
}
}
}

include_once('../config/db.inc.php');
list($info, $host) = explode('@', $rcmail_config['db_dsnw']);
list($type, $login) = explode('://', $info);
list($user, $pass) = explode(':', $login);
list($host, $db) = explode('/', $host);

if(strtolower($type) != 'mysql')
  die('Sorry, this script works for mySQL only.');

$conn = @mysql_connect($host, $user, $pass);
if(!$conn)
  die('Connection can not be established.');
@mysql_select_db($db, $conn);

// Get the SQL file information:
$sql = file_get_contents($filename);

// Okay, execute it :)
$result = @mysql_query($sql);

if(!$result)
  echo 'There was an error executing the contents of '. $filename. '.
Error #'. mysql_errno().': '.mysql_error();
else
  echo 'SQL statement executed successfully!!';

?>
Try that one. It has a bit more debugging information in it. Plus, the filename may have been case-sensitive, so I fixed that.
Title: Re: page not found on mysql.initial.sql
Post by: DJDarknez on July 31, 2006, 12:54:25 AM
Okey dokey, "ran" that one, and it displayed a blank page. Just for the heck of it, I tried going to the install file, but it didn't happen. Might I have something on one of the config files wrong?
Title: Re: page not found on mysql.initial.sql
Post by: bpat1434 on July 31, 2006, 10:09:35 AM
Woops... it's a parse error on my part :(

Sorry... threw in some PHP 5 code, so it wouldn't work on PHP 4 and gives a syntax error. Plus, there was a syntax error in general :( So I worked on it, and tested it out. The following script WILL work and execute the file and create the tables required.

// Which file will we use?
$filename = 'mysql.initial.sql';


/**
 * DO NOT EDIT THIS SECTION!!
 */

$sql = @file_get_contents($filename);

if(!$sql)
{
echo 'Error: The file ('.$filename.') wasn\'t found in the current directory.

Trying directory above first....
';

// Let's try the directory above it ;)
$path = realpath('../');
if(substr($path, -1) == '/')
$path = substr($path, 0, -1);

$sql = @file_get_contents($path.'/'.$filename);

if(!$sql)
{
// How about directory above, but SQL under :)
$path = realpath('../SQL/');
if(substr($path, -1) == '/')
$path = substr($path, 0, -1);

$sql = @file_get_contents($path.'/'.$filename);

if(!$sql)
{
echo 'Error: File ('.$path.'/'.$filename.') wasn\'t found.

Trying the directory below the current one, most likely named SQL.
';

$path = realpath('./SQL/');
if(substr($path, -1) == '/')
$path = substr($path, 0, -1);

$sql = @file_get_contents($path.'/'.$filename);
if(!$sql)
{
echo 'Error: File ('.$path.'/'.$filename.') wasn\'t found.



Sorry,

the file ('. $filename. ') was not found in the current directory, or the ones above and below it. Make sure your paths are correct.';
exit();
}
}
}
}
echo '
FOUND THE SQL FILE TO EXECUTE!!
';
// SO what happened?
flush();
ob_flush();


@include_once('config/db.inc.php');
if(!isset($rcmail_config))
{
echo 'Error: Config file not found in config directory below current working directory.
';

// How about above?
@include_once('../config/db.inc.php');
if(!isset($rcmail_config))
{
echo 'Error: Config file not found in config directory above current one.
';

// How about without the config/ path?
@include_once('db.inc.php');
if(!isset($rcmail_config))
{
echo 'Error: Config file not found in current directory.
';

// How about the directory directly above us? (Why I'm not sure)
@include_once('../db.inc.php');
if(!isset($rcmail_config))
{
// Can't find it.... kill it...
echo 'Error: Config file not found above current directory.

Sorry,

the config file (db.inc.php) was not found anywhere I know where to look for it.';
exit();
}
}
}
}
echo '
FOUND THE Database Setup FILE!!! :)


';
// Show some feedback... geeze!!
flush();
ob_flush();

preg_match_all("/(CREATE TABLE.*?\)\;)/si", $sql, $queries);
array_shift($queries);

// Build our query:

list($info, $host) = explode('@', $rcmail_config['db_dsnw']);
list($type, $login) = explode('://', $info);
list($user, $pass) = explode(':', $login);
list($host, $db) = explode('/', $host);

if(strtolower($type) != 'mysql')
  die('Sorry, this script works for mySQL only.');

$conn = @mysql_connect($host, $user, $pass);
if(!$conn)
  die('Connection can not be established.');
@mysql_select_db($db, $conn);

// Okay, execute them all :)
foreach($queries[0] as $sql)
{
$lines = explode("\n", $sql);
$table = $lines[0];
$table = substr($table, 14, -4);
$result = @mysql_query($sql);

if(!$result)
echo '
Error: There was an error executing the query for `'. $table. '`.
Error #'. mysql_errno().':
'.mysql_error();
else
echo 'Successfully created table `'.$table.'`
';

// Send the junk to the browser already!!
flush();
ob_flush();
}

?>

That is given that you place the file in the root ROundcube directory like so:

/home/username/public_html/email/roundcube/[HERE]

It can work if you move it around, or put it in the SQL folder too. But it's guaranteed to work where the roundcube index.php file is ;)
Title: Re: page not found on mysql.initial.sql
Post by: DJDarknez on July 31, 2006, 03:05:31 PM
AH HA! Here we go.

FOUND THE SQL FILE TO EXECUTE!!
Error: Config file not found in config directory below current working directory.

FOUND THE Database Setup FILE!!! :)

Successfully created table `cache`
Successfully created table `contacts`
Successfully created table `identities`
Successfully created table `session`
Successfully created table `users`
Successfully created table `messages`

Now I just need to figure out why it isn't locating that config file...
Title: Re: page not found on mysql.initial.sql
Post by: bpat1434 on July 31, 2006, 10:51:42 PM
no, it does.... it set it up :) This line:
Quote
FOUND THE Database Setup FILE!!
says it found db.inc.php somewhere in there. Plus, the mysql_connect call would fail if the db.inc.php file wasn't found ;)

You should be good to go.