#1 2003-11-05 04:23:39

BigC
Guest

Can't Update To 1.3

Hi...the new version looks intriguing, and I would very much like to install it. So I followed the instructions, and ran the conversion script. Here is what it said:

--------------------------------------------------------------------------------------
19:02:26 : Start of updating database scheme
19:02:26 : Deletion of obsolete tables [done]
19:02:26 : Creation of new tables [done]
19:02:26 : Recreation of empty tables (history and sessions) [done]
19:02:26 : Drop columns becomed useless [done]
19:02:26 : Add new columns [done]
ALTER TABLE phpwebgallery_images CHANGE id id mediumint( 8 ) unsigned NOT NULL auto_increment,CHANGE cat_id storage_category_id smallint(5) unsigned default NULL,CHANGE comment comment text; N°= 2000 -->> Column 'storage_category_id' is used with UNIQUE or INDEX but is not defined as NOT NULL


19:02:26 : Modify columns [done]
ALTER TABLE phpwebgallery_images DROP INDEX cat_id,ADD INDEX ( storage_category_id ); N°= 2000 -->> Key column 'storage_category_id' doesn't exist in table


19:02:26 : Update keys and indexes [done]

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/upgrade1.2to1.3.php on line 293

19:02:26 : Special treatment on data [done]
19:02:26 : Your database has been succesfully updated from release 1.2 to 1.3
--------------------------------------------------------------------------------------

Now, when I try to run my gallery, I get lots of error messages like this:

--------------------------------------------------------------------------------------
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/category.php on line 388

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/functions_category.inc.php on line 366
--------------------------------------------------------------------------------------

And I don't see any thumbnails. Can I do something to fix it? Or do I have to go back to 1.2 (hope it still works now)?

Any help would be great. Thanks!

~Chris

 

#2 2003-11-05 07:27:25

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
14068

Re: Can't Update To 1.3

First question : which version of MySQL are you using ?

Then, you will have to use PhpWebGallery without the index on storage_category_id, doesn't matter. Go to your MySQL admin tool (PhpMyAdmin maybe). You have to create the column :

Code:

ALTER TABLE phpwebgallery_images DROP INDEX cat_id;
ALTER TABLE phpwebgallery_images CHANGE cat_id storage_category_id smallint(5) unsigned default NULL;

Then, you have to run this script (part of upgrade1.2to1.3.php)

Code:

<?php
include( './mysql.inc.php' );
define( PREFIX_TABLE, $prefixeTable );
@mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
or die ( "Could not connect to server" );
@mysql_select_db( $cfgBase )
or die ( "Could not connect to database" );

// each picture must be linked to its storage category in the new table
// image_category
$query = 'SELECT id,storage_category_id';
$query.= ' FROM '.PREFIX_TABLE.'images';
$query.= ';';
$result = mysql_query( $query );
while ( $row = mysql_fetch_array( $result) )
{
  $query = 'INSERT INTO '.PREFIX_TABLE.'image_category';
  $query.= ' (image_id,category_id) VALUES ';
  $query.= ' ('.$row['id'].','.$row['storage_category_id'].')';
  $query.= ';';
  mysql_query( $query ) or my_error( $query.' ' );
}
?>

(place this upgrade.php script in your include directory)

Offline

 

#3 2003-11-05 20:50:37

BigC
Guest

Re: Can't Update To 1.3

Hi!

Thanks for the answer. I am running MySQL 3.22.32. Does that have an impact?

I did completely restore my 1.2 environment, program and database.

For your suggestion, do I understand you right that the script is part of  upgrade1.2to1.3.php. So that means, if I start with my 1.2 database, all I have to do is the table modification before I run upgrade1.2to1.3.php? Besides following the other upgrade install steps, of course.

Thanks,
~Chris

 

#4 2003-11-05 21:17:29

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
14068

Re: Can't Update To 1.3

For your suggestion, do I understand you right that the script is part of  upgrade1.2to1.3.php. So that means, if I start with my 1.2 database, all I have to do is the table modification before I run upgrade1.2to1.3.php? Besides following the other upgrade install steps, of course.

No, if you have been able to restore your 1.2 database, just modify script upgrade1.2to1.3.php before running it once more :

in upgrade1.2to1.3.php, after

Code:

198 //------------------------------------------ column modified in existing tables

insert

Code:

$query = 'ALTER TABLE '.PREFIX_TABLE.'images';
$query.= ' DROP INDEX cat_id';
$query.= ';';
mysql_query( $query ) or my_error( $query.' ' );

and delete

Code:

    261 $query = 'ALTER TABLE '.PREFIX_TABLE.'images';
    262 $query.= ' DROP INDEX cat_id';
    263 $query.= ',ADD INDEX ( storage_category_id )';
    264 $query.= ';';
    265 mysql_query( $query ) or my_error( $query.' ' );

Offline

 

#5 2003-11-06 04:09:15

BigC
Guest

Re: Can't Update To 1.3

That looks much better - the upgrade script output:

18:56:41 : Start of updating database scheme
18:56:41 : Deletion of obsolete tables [done]
18:56:41 : Creation of new tables [done]
18:56:41 : Recreation of empty tables (history and sessions) [done]
18:56:41 : Drop columns becomed useless [done]
18:56:41 : Add new columns [done]
18:56:41 : Modify columns [done]
18:56:41 : Update keys and indexes [done]
18:56:41 : Special treatment on data [done]
18:56:41 : Your database has been succesfully updated from release 1.2 to 1.3

I can browse my galleries, see thumbnails, etc. However, when I open the gallery homepage and login, and when I open a  (for example top-level) category with no pictures in it, I get errormessages like this:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/functions_category.inc.php on line 644

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/functions_category.inc.php on line 652

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/category.php on line 388

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/functions_category.inc.php on line 366

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/category.php on line 388

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/functions_category.inc.php on line 366

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/category.php on line 388

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/functions_category.inc.php on line 366

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/category.php on line 388

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/functions_category.inc.php on line 366

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/category.php on line 388

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/include/functions_category.inc.php on line 366

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/kris/public_html/gallery/category.php on line 388

Any ideas how to overcome this? In any case, this is great progress already - thank you for all your help!

~Chris

 

#6 2003-11-06 07:37:23

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
14068

Re: Can't Update To 1.3

I think I see what the problem is : your (very old) version of MySQL server doesn't support the SQL statement "ORDER BY RAND()" which is used when no pictures are in the category you wish to display.

Wouldn't it be a good idea to update your MySQL version ?

This is just a suggestion, we can do something else (but behaviour will be quite different)

1. in category.php (1.3), replace

Code:

    384       $query.= ' ORDER BY RAND()';

by

Code:

$query.= $conf['order_by'];

2. in include/functions_category.inc.php (1.3), replace

Code:

    641   $query.= ' ORDER BY RAND()';

by

Code:

$query.= ' ORDER BY rank';

3. in comments.php (1.3), delete

Code:

     44     $query.= ' ORDER BY RAND()';

Offline

 

#7 2003-11-06 08:22:58

Guest
Guest

Re: Can't Update To 1.3

Whow! Thanks for your ultrafast response!

It works now - great! You da man!   :D

P.S. Upgrading MySQL is unfortunately not possible - I have no root access on the server where I host the galleries. They are very conservative with updates for stability reasons.

 

Board footer

Powered by FluxBB