PDA

View Full Version : PHP Album. Can't get it to work.



nunofyer bzness
08-24-2009, 04:11 AM
1) Script Title: PHP Photo Album 2.0

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...photoalbum.htm

3) Describe problem:

I've been trying to get the script installed on my web site for a couple of days, and I can't get it to work. Regardless of what I try, I am always getting an error message:

Java Script Error
Description: 'myvacation' is undefined

The error message then points me to the line

new phpimagealbum({
albumvar: myvacation,

in your script. I am using Apache 2.2 and PHP 5.3.

nunofyer bzness
08-24-2009, 04:11 AM
Oh, also: It says:

(make sure the path to it inside ddphpalbum.js is correct).

referring to ddphpalbum.css with "it". What do you mean by that? I cannot find a reference to ddphpalbum.css in ddphpalbum.js.

ddadmin
08-24-2009, 06:41 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.

Beverleyh
08-24-2009, 08:16 AM
Oh, also: It says:

(make sure the path to it inside ddphpalbum.js is correct).

referring to ddphpalbum.css with "it". What do you mean by that? I cannot find a reference to ddphpalbum.css in ddphpalbum.js.

This is referring to the loading gif reference inside the javascript file.

nunofyer bzness
08-24-2009, 06:34 PM
Sorry, the website is not public yet, so I guess I can't give you a website to check the code, but I am following exactly the instructions on the web page.

ddadmin
08-24-2009, 08:11 PM
That particular error message simply means the script cannot locate the dynamically generated array with name "vacation". Most likely the following line in the HEAD section of your page isn't set up correctly:


<script type="text/javascript" src="http://www.mysite.com/myimages/getalbumpics.php?id=myvacation"></script>

Make sure "getalbumpics.php" is correctly uploaded to your server and inside the directory where all your pages are. Also, make sure the path above correctly references this PHP file.

nunofyer bzness
08-24-2009, 11:38 PM
That particular error message simply means the script cannot locate the dynamically generated array with name "vacation". Most likely the following line in the HEAD section of your page isn't set up correctly:


<script type="text/javascript" src="http://www.mysite.com/myimages/getalbumpics.php?id=myvacation"></script>

Make sure "getalbumpics.php" is correctly uploaded to your server and inside the directory where all your pages are. Also, make sure the path above correctly references this PHP file.

I have checked and re-checked this many times. I did have a problem with the webroot of Apache, and not it seems I am not getting the error message anymore, but I don't get the album either. I am almost ready to give up and try something else.

This may not be a problem with the script. I just tested to following:

1) I set up a php file with just the following line:

<?php echo "This is a Test"; ?>

and saved it in the webroot folder, then opened a browser and entered "localhost/test.php" as the URL. I get a Browser Window that says "This is a Test". Looks like php is working and doing well.

2)Then I set up another PHP file with the following content:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 3</title>
</head>

<body>

<script type="text/javascript" src="test.php"></script>

</body>

</html>

I expected to see the same, as I am basically just calling the previous php code from another php file. Nothing. Just a white page. Saving and calling it as an htm file does not change a thing. Why is that? Where am I doing something wrong? I can't figure it out. Help!!!

ddadmin
08-25-2009, 06:51 AM
In the case of:


<script type="text/javascript" src="test.php"></script>

The contents of test.php has to be such that it outputs valid JavaScript code in order for you to see anything on the page, such as:


echo "document.write(\"Hi there\")";

Back to the original topic though, it would really be helpful if you could post a test page online, as this is something that we need to see live to debug.

nunofyer bzness
08-25-2009, 02:19 PM
In the case of:


<script type="text/javascript" src="test.php"></script>

The contents of test.php has to be such that it outputs valid JavaScript code in order for you to see anything on the page, such as:


echo "document.write(\"Hi there\")";

Back to the original topic though, it would really be helpful if you could post a test page online, as this is something that we need to see live to debug.

Thanks for the tip, but still -- nothing.

I will see what I can do about the test page. I'll let you know when I have something. Thanks for the offer to help.

nunofyer bzness
08-25-2009, 11:54 PM
Thanks for the tip, but still -- nothing.

I will see what I can do about the test page. I'll let you know when I have something. Thanks for the offer to help.

OK, I just posted the code to a web site (www.bestrmvacation.com/album.htm), and IT WORKS THERE. It does NOT work on my installation of PHP/Apache. After some snooping on the internet, I turned on some more error reporting and I find the following errors in the error log:

[Tue Aug 25 17:45:53 2009] [error] [client 127.0.0.1] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Denver' for '-6.0/DST' instead in C:\\webdev\\rmv3\\album\\getalbumpics.php on line 12, referer: http://localhost/album.php

[Tue Aug 25 17:45:56 2009] [error] [client 127.0.0.1] File does not exist: C:/webdev/rmv3/favicon.ico

(The first warning is repeated for each image that I have in the folder). Any suggestions?

Thanks.

thetestingsite
08-26-2009, 12:03 AM
PHP 5.3 has a lot of changes that make scripts that worked with earlier version of php not function correctly anymore. I learned this from "trial and error" as well. Anyway, glad that it is working for you now.

nunofyer bzness
08-26-2009, 03:37 AM
OK, I just posted the code to a web site (www.bestrmvacation.com/album.htm), and IT WORKS THERE. It does NOT work on my installation of PHP/Apache. After some snooping on the internet, I turned on some more error reporting and I find the following errors in the error log:

[Tue Aug 25 17:45:53 2009] [error] [client 127.0.0.1] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Denver' for '-6.0/DST' instead in C:\\webdev\\rmv3\\album\\getalbumpics.php on line 12, referer: http://localhost/album.php

[Tue Aug 25 17:45:56 2009] [error] [client 127.0.0.1] File does not exist: C:/webdev/rmv3/favicon.ico

(The first warning is repeated for each image that I have in the folder). Any suggestions?

Thanks.

I just deinstalled apache and php and re-installed it from fresh sources. no change. I can't get the script to work on my computer. Now I get another error in addition:

[Tue Aug 25 21:29:11 2009] [error] [client 127.0.0.1] PHP Deprecated: Function eregi() is deprecated in C:\\webdev\\rmv3\\album\\getalbumpics.php on line 11, referer: http://localhost/album.php

I don't know if this would call the script to fail, but it is definitely not working on my computer.

ddadmin
08-26-2009, 05:09 AM
Are you familiar with PHP? If so, I'd try and modify albumpics.php per the error warnings you've been receiving to see if that changes anything:

1) For the date() function, I don't see any issues mentioned in the documentation (http://ca3.php.net/manual/en/function.date.php), but perhaps I missed something.

2) For eregi(), The docs do say it's deprecated, and I'll most likely be updating the php script officially for this soon. In the meantime, try using preg_match (http://ca3.php.net/manual/en/function.preg-match.php) instead.

nunofyer bzness
08-26-2009, 02:52 PM
Are you familiar with PHP? If so, I'd try and modify albumpics.php per the error warnings you've been receiving to see if that changes anything:

1) For the date() function, I don't see any issues mentioned in the documentation (http://ca3.php.net/manual/en/function.date.php), but perhaps I missed something.

2) For eregi(), The docs do say it's deprecated, and I'll most likely be updating the php script officially for this soon. In the meantime, try using preg_match (http://ca3.php.net/manual/en/function.preg-match.php) instead.

Thanks. I will see if I can do that. I just saw another piece of information. This morning I fired up my computer and started the web page in Firefox while it was still loading up. I guess that slowed it down a bit, and I saw briefly flashing on the page an icon (with a red "X", the "loading.gif, and a text "loading...". I coldn't make out more details as it flashed by prety quickly. I believe that this is from the PHP script, right? So, between that point and the display, something seems to go wrong. I am wondering if the time code inserts some unwanted characters that are then interpreted wrong and the filenames are not right, and then your script cannot load the images. I just don't know how to debug php. I'm familiar with other languages, and there is always a way to insert some comments to see where things might go wrong, or there is a debugger tool that let's you do that and watch variables, for example. How does that work with php?

ddadmin
08-27-2009, 03:49 AM
No, the red "x" and brief animation is from the JavaScript, which isn't the issue. I think you are getting closer earlier as far as those PHP log errors are concerned. Basically some of the code inside getalbumpics.php is incompatible on your home server. You'll need to try modifying some of the code inside the PHP script based on the error messages mentioned.

If and when your PHP code does work, you should be able to call it directly in your browser, and have it return a JavaScript array such as when you click on the below:

http://www.dynamicdrive.com/dynamicindex4/phpgallery/getalbumpics.php?id=jaguar

Loud2004
01-08-2010, 01:07 AM
Found the problem. Had to sign up and post a simple fix for anyone else who needs to show some photos quick :)

Open the file getalbumpics.php and change the first line from

<?

to


<?php
Or you can open php.ini and set


short_open_tag = On

it is off by default and will give you a blank page if not turned on :)

Hope this helps someone else. Took me over an hour to figure it out. Guess I should have started looking at the code first instead of my apache/php settings.