MySQL update error

General discussion about netjukebox
Aricu_LoneGRo

MySQL update error

Post by Aricu_LoneGRo »

MySQL update error
Incremental upgrade is not supported from this database version.

Delete your old database.
On the next start netjukebox automatic creates a new MySQL database and table structure.



Im Getting this error I would like to know what are the names of the tables that have to be earse. I checked my database and I dont think they where created but. I would like to know what are the names of the files.

Thanx in Advance.
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Post by wbartels »

You also get this error if there is an empty database.
I will see if I can fix this on the next version.
I assume you have created the database: netjukebox.

So delete the "netjukebox" database and start netjukebox.
It will automatically create the database "netjukebox" and all the required "tables".
Last edited by wbartels on Wed Oct 19, 2005 6:27 pm, edited 1 time in total.
Aricu-

?

Post by Aricu- »

Im using my existing Database I belive but i do not see the tables created.
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Re: ?

Post by wbartels »

Aricu- wrote:Im using my existing Database I belive but i do not see the tables created.
That is the point, delete the (empty) database!
Then netjukebox will create a new one with all the required "tables".
aricu
User
Posts: 11
Joined: Thu Sep 22, 2005 3:14 pm
Location: Jerzey

Post by aricu »

I delet my database I will loose other applications that I am running in my existing bd. ?Does netjukebox need to have is own bd.

I not how can I make it work with the existing bd that im already running.
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Post by wbartels »

aricu wrote:I delet my database I will loose other applications that I am running in my existing bd. ?Does netjukebox need to have is own bd.

I not how can I make it work with the existing bd that im already running.
Maybe I was unclear but I mend only the "netjukebox" database.
See this post for the steps to take:
viewtopic.php?p=533#533
aricu
User
Posts: 11
Joined: Thu Sep 22, 2005 3:14 pm
Location: Jerzey

Post by aricu »

I am running the program on my Unix Host. How can i do that using the phpMyAdmin
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Post by wbartels »

1) Select the "netjukebox" database in the "Database:" pulldown.
2) Then click on "Drop" (top right)
3) Then click on "Ok"
4) close phpMyAdmin
5) start netjukebox

Good luck,
aricu
User
Posts: 11
Joined: Thu Sep 22, 2005 3:14 pm
Location: Jerzey

Post by aricu »

It wanst created. I dont think my host allows for the script to creat a data base.

Any other suggestions.
:oops: :oops: :roll:
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Post by wbartels »

aricu wrote:It wanst created. I dont think my host allows for the script to creat a data base.

Any other suggestions.
:oops: :oops: :roll:
As soon as I have an updated "mysql.ins.php" ready I will post it here.
The updated version will allow creating a database/tables when there is an empty database.

In the meantime you could try to manually import the tables with phpMyAdmin.
1) Select the already (empty) created database with the "Database:" pull down.
2) Select SQL
3) Select browse
4) Open file: ".../netjukebox/sql/netjukebox_11.sql"
5) Click on "OK" (lower right)

If this went well you get the message "Your SQL query has been executed successfully"

Success,

Willem
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Post by wbartels »

This update (mysql.inc.php) should fix the problems with an empty database:
Any comment or improvement?

Code: Select all

<?php
//  +---------------------------------------------------------------------------+
//  | netjukebox, Copyright © 2001-2005  Willem Bartels                         |
//  |                                                                           |
//  | http://www.netjukebox.nl                                                  |
//  |                                                                           |
//  | This file is part of netjukebox.                                          |
//  | netjukebox is free software; you can redistribute it and/or modify        |
//  | it under the terms of the GNU General Public License as published by      |
//  | the Free Software Foundation; either version 2 of the License, or         |
//  | (at your option) any later version.                                       |
//  |                                                                           |
//  | netjukebox is distributed in the hope that it will be useful,             |
//  | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
//  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
//  | GNU General Public License for more details.                              |
//  |                                                                           |
//  | You should have received a copy of the GNU General Public License         |
//  | along with this program; if not, write to the Free Software               |
//  | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA |
//  +---------------------------------------------------------------------------+



//  +---------------------------------------------------------------------------+
//  | mysql.inc.php                                                             |
//  +---------------------------------------------------------------------------+
$cfg['mysql_required_version'] = 11;
//  Version 01 <=> netjukebox 2.02
//  Version 02 <=> netjukebox 3.00
//  Version 03 <=> netjukebox 3.50
//  Version 04 <=> netjukebox 3.55
//  Version 05 <=> netjukebox 3.61
//  Version 06 <=> netjukebox 3.67
//  Version 07 <=> netjukebox 3.69
//  Version 08 <=> netjukebox 3.70
//  Version 09 <=> netjukebox 3.73
//  Version 10 <=> netjukebox 3.74
//  Version 11 <=> netjukebox 3.76



//  +---------------------------------------------------------------------------+
//  | MySQL Connect                                                             |
//  +---------------------------------------------------------------------------+
@mysql_pconnect($cfg['mysql_host'], $cfg['mysql_user'], $cfg['mysql_password']) or message('error', '<strong>Can\'t connect to MySQL server on:</strong><br>' . $cfg['mysql_host']);
@mysql_select_db($cfg['mysql_db']) or createDB();

$query = mysql_query('SELECT version FROM configuration_database ORDER BY version DESC');
$cfg['mysql_current_version'] = @mysql_result($query, 'version');
if ($cfg['mysql_current_version'] != $cfg['mysql_required_version'])
	updateDB();



//  +---------------------------------------------------------------------------+
//  | Create Database                                                           |
//  +---------------------------------------------------------------------------+
function createDB()
{
global $cfg;
@mysql_query('CREATE DATABASE ' . $cfg['mysql_db']) or message('error', '<strong>Can\'t create database:</strong><br>' . $cfg['mysql_db']);
importDB();
}



//  +---------------------------------------------------------------------------+
//  | Import Database                                                           |
//  +---------------------------------------------------------------------------+
function importDB()
{
global $cfg;
$file = $cfg['home_dir'] . '/sql/netjukebox_' . str_pad($cfg['mysql_required_version'], 2, '0', STR_PAD_LEFT) . '.sql';
if (!file_exists($file)) message('error', '<strong>Can\'t open file:</strong><br>'. $file);
@mysql_select_db($cfg['mysql_db']) or message('error', '<strong>Can\'t select database:</strong><br>' . $cfg['mysql_db']);
QuerySqlFile($file);
message('ok', '<strong>Database ' . $cfg['mysql_db'] . '@' . $cfg['mysql_host'] . ' created successfully.</strong><br>
For security reason it is advisable to change the password.<br><br>
<a href="index.php?menu=browse&authenticate=logout" target="_top"><strong>Login netjukebox:</strong></a>
<ul>
	<li><strong>username:</strong> admin</li>
	<li><strong>password:</strong> admin</li>
</ul>');
}



//  +---------------------------------------------------------------------------+
//  | Update Database                                                           |
//  +---------------------------------------------------------------------------+
function updateDB()
{
global $cfg;

$query = @mysql_query('SHOW TABLES') or message('error', '<strong>Can\'t show MySQL tables in:</strong><br>' . $cfg['mysql_db']);
$table = @mysql_result($query, 0);
if ($table == '')
	{
	importDB();
	}
if ($cfg['mysql_current_version'] < 1 || $cfg['mysql_current_version'] > $cfg['mysql_required_version'])
	{
	message('error', '<strong>MySQL update error</strong><br>
Incremental upgrade is not supported from this database version.<br>
<ul class="compact">
	<li>Delete your old database.</li>
	<li>On the next start netjukebox automatic creates a new MySQL database and table structure.</li>
</ul>');
	}
else
	{
	for($i = $cfg['mysql_current_version'] + 1; $i <= $cfg['mysql_required_version']; $i++)
		{
		$file = $cfg['home_dir'] . '/sql/incremental_upgrade_' . str_pad($i, 2, '0', STR_PAD_LEFT) . '.sql';
		if (!file_exists($file)) message('error', '<strong>Can\'t open file:</strong><br>'. $file);
		QuerySqlFile($file);
		}
	message('ok', '<strong>Incremental database upgrade successfuly on ' . $cfg['mysql_db'] . '@' . $cfg['mysql_host'] . '</strong><br>
It is advisable to update de database now.<br>
<ul class="compact"><li><a href="update.php">Update database now</a></li></ul>');
	}
}



//  +---------------------------------------------------------------------------+
//  | Query SQL File                                                            |
//  +---------------------------------------------------------------------------+
function QuerySqlFile($file)
{
$fp = fopen($file, 'r');
$query = '';
while (!feof($fp))
	{
	$line = fgets ($fp, 1024);
	if (($line{0} != '#') && (trim($line) != ''))
		{
		$query .= $line;
		}
	if (strstr ($line, ';'))
		{
		$query = str_replace(';', '', $query);
		@mysql_query($query) or message('error', '<strong>MySQL create/upgarde error, Can\'t execute:</strong><br>' . $file . '<br>' . $query);
		$query = '';
		}
	}
}
?>
Last edited by wbartels on Fri Jan 12, 2007 9:16 pm, edited 1 time in total.
aricu
User
Posts: 11
Joined: Thu Sep 22, 2005 3:14 pm
Location: Jerzey

Can't open file: /sql/netjukebox_11.sql

Post by aricu »

wbartels wrote:
aricu wrote:It wanst created. I dont think my host allows for the script to creat a data base.

Any other suggestions.
:oops: :oops: :roll:
As soon as I have an updated "mysql.ins.php" ready I will post it here.
The updated version will allow creating a database/tables when there is an empty database.

In the meantime you could try to manually import the tables with phpMyAdmin.
1) Select the already (empty) created database with the "Database:" pull down.
2) Select SQL
3) Select browse
4) Open file: ".../netjukebox/sql/netjukebox_11.sql"
5) Click on "OK" (lower right)

If this went well you get the message "Your SQL query has been executed successfully"

Success,

Willem



I check the SQL directory I noticed that I was missing it so I reloaded the directory then I unziped the ziped file with the old SQL. But now Im getting the error cant Open /sql/netjukebox_11.sql.

What might be the reason for this.
Aricu*

Post by Aricu* »

I noticed that the file being asked for is located in the zip folder. So that why I unziped it and placed it in the same directory as the updated ones. Is this file suppose to be in a specific directory.

I manually inserted the table but it still has the error above.
Guest

Post by Guest »

The Mod's to the "mysql.inc.php" work but I dont have access on my host to allow a program t creat a database. I could creat another one but it has to be done manually.
User avatar
wbartels
netjukebox developer
Posts: 881
Joined: Thu Nov 04, 2004 3:12 pm
Location: Netherlands
Contact:

Post by wbartels »

Aricu* I have deleted the "Can't open file: /sql/netjukebox_11.sql" post.
Because it is the same subject as this tread.
Post Reply