Member
Member
bearaa   08-02-2014, 03:59
#1

Some time ago I created a website using zenphoto for the backend photo gallery management. I recently copied my web pages over to a new site, created an empty mysql database, and did a fresh install of the latest zenphoto release. I'm now getting weird strings such as "a:1:{s:5:"en_US";s:9:"album title";}" displaying in place of what displays as just the album title on the old site. Do I need to use a different method of getting/printing album titles, or change some kind of language encoding setting...? What's going on here exactly?

Administrator
Administrator
acrylian   08-02-2014, 11:10
#2

Since you didn't mention the theme used that one might need an update. That is the correct way. Please see here: http://www.zenphoto.org/news/multi-lingual-sites#backend-usage (the box below the 2nd image).

Member
Member
bearaa   08-02-2014, 17:36
#3

I created my own theme... so I guess I need to know what I need to change in my code?

Administrator
Administrator
acrylian   08-02-2014, 18:13
#4

I suggest to re-read the theming tutorial.

Member
Member
bearaa   08-02-2014, 21:29
#5

Here's a piece of my code. All I want to know is why $row['title'] no longer prints as simply the album title, and how to make it do so. Is there a function I need to use to strip out all the extra string characters so I'm left with just the album title?

$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );

$q = "SELECT id, title FROM zp_albums WHERE parentid IS NULL ORDER BY sort_order";
$r = @mysqli_query ($dbc, $q);

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
    echo "" . $row['title'] . "";
}

The result prints on my page as "a:1:{s:5:"en_US";s:9:"my album title";}" instead of just "my album title".

Member
Member
sbillard   08-02-2014, 22:23
#6

The simple answer is because that is not how those things are typically stored.

The more complex answer is that you should NEVER bypass the object model. There is good reason why we use objects because they hide underlying implementations.

The code you show seems to be an over complication of:

$albumlist = $_zp_gallery->getAlbums(); foreach ($albumlist as $albumname) { $album=newAlbum($albumname); echo ''.$album->getTitle().''; }
There is much written in the [i]themeing[/i] tutorial, none of which suggests you fetch anything directly from the database. Besides the difficulty you are having you are also bypassing any of the security, publication status, and ownership processing of the objects.

Member
Member
bearaa   09-02-2014, 01:36
#7

Ah I see, thanks. I read a theming tutorial way back when I built this, but since I was new to programming it was really confusing and had a lot that didn't apply to my site, so I ended up just using zenphoto to manage the back end and directly querying the database since that was the only thing I knew how to do. It worked fine for what I needed it for with the version of zenphoto that was out at that time, but I suppose I should reprogram everything correctly. Thanks.

Member
Member
earthnutvt   17-05-2014, 22:41
#8

I am having this same issue. When I first create an album, the title appears fine. But if I update it, I get this: a:1:{s:5:"en_US";s:12:"Test Album 2";}

I'm using the Default theme, so I'm not sure what the issue is. I recently upgraded to 1.4.5.9. Any help would be appreciated. I cannot figure out what formats the album title or sends it to the database, but something is clearly wrong.

Administrator
Administrator
acrylian   18-05-2014, 07:34
#9

What you see is the string as correctly stored in the database to Zenphoto would work in multilingual mode:http://www.zenphoto.org/news/multi-lingual-sites

You did not tell from which version you upgraded. Also please take a look at this bug report guide: http://www.zenphoto.org/news/general-contributor-guidelines#reporting-bugs (especially the error log part).

You also probably should try the 1.4.6 RC2.

Member
Member
digheal   04-08-2014, 00:06
#10

I am running the Zenphoto 1.4.6 and am experiencing the same issue - whenever I use the ZP web ui to modify albums and images, they end up with titles like this:

a:1:{s:5:"en_US";s:20:"themontecarloband001";}

I can go in through phpMyAdmin and modify to remove the extra characters, but that's a lot of extra work I would like to avoid. Is there a way to permanently stop Zenphoto from adding these extra characters? I am only interested in having my website be in U.S. English so if it means completely disabling multilingual support, that's totally fine with me.

Thus far, I've deselected all languages but US English and set US English to be the default language, but I am still getting those characters when I modify albums and images. Also, I am using Chrome if that makes any difference.

Thanks in advance for any help you can provide.

Member
Member
sbillard   04-08-2014, 00:19
#11

These are correctly represented titles. While the titles without the language elements will work, Zenphoto will never create them that way.

So the real question is how you are outputting the title. If you are using the normal Zenphoto functions you should see normal text. If you are directly using the database you will have to process the data properly. There is a function to do so called getLanguageString().

Member
Member
digheal   04-08-2014, 13:09
#12

Thank you very much for your response. I should have mentioned that everything appears fine within the ZP galleries, etc. I am doing a direct manual PHP query against the database for another part of my site, which would explain why I am getting the extra characters. Here's what I am doing:

$result = mysql_query("SELECT filename, title FROM.imagesWHERE albumid = 5") or trigger_error(mysql_error());

Is getLanguageString a PHP or a ZP function? I haven't been able to find anything about this command for ZP or PHP.

Administrator
Administrator
acrylian   04-08-2014, 13:20
#13

Quite important information actually! Of course getLanguageString is a ZP specific function because that kind of storage belongs to the multilingual capabilities.

Of course direct mysql queries can bypass ZP functionality like this or for example rights management. A recommended way would be the "Zenphoto as a plugin" way on our user guide so you can use the actual object model (if possible on your site): http://www.zenphoto.org/news/integration-with-existing-sites-and-other-cms

Besides that what you see is just a seralized string. There are standard php functions to unserialize it and use it as a normal array.

Member
Member
digheal   04-08-2014, 14:15
#14

I'm actually using the queries to output HTML files that I PHP include in with a separate mobile theme I purchased. So, ZP powers my main site and I grab filenames and titles from the database to turn this:

$result = mysql_query("SELECT filename, title FROM.imagesWHERE albumid = 5") or trigger_error(mysql_error());

`
while ($row = mysql_fetch_array($result)) {
echo "

[*][img]images/boston_rockshots/peterbuzzelle.jpg[/img]`

I'll check the Zenphoto as plugin thing. Thanks again.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.