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?
Comments
$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 "<span>" . $row['title'] . "</span>";
}
The result prints on my page as "a:1:{s:5:"en_US";s:9:"my album title";}" instead of just "my album title".
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 themeing 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.
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.
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.
`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.
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()`.
`$result = mysql_query("SELECT filename, title FROM`.images`WHERE 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.
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.
`$result = mysql_query("SELECT filename, title FROM`.images`WHERE albumid = 5") or trigger_error(mysql_error());`
`
while ($row = mysql_fetch_array($result)) {
echo "
\r\n";
}'
`
Into this:
``
I'll check the Zenphoto as plugin thing. Thanks again.