Jump to content

NewB - Can anybody tell me what's wrong with this Flickr php?


TC_uk

Recommended Posts

Hello.

I've just started work on my first website design in 10 years!

To say that I'm new to PHP would be an exaggeration...

 

I plan to have a private web page for tech image reference, so when I saw a magazine article showing how to incorporate a Flickr gallery on to a site, using php and "phpFlickr", I thought, yeah, let's give it a try.

 

Unfortunately (for me) all the PHP appears on a printed page, and I've had to recreate it by sight, and without a clue what it ought to look like and then why it's not working.

 

As this uses Flickr.com (which needs an account) along with downloaded files from phpFlickr (https://sourceforge.net/project/showfiles.php?group_id=139987), I don't really expect anybody can do anymore than tell me what might be wrong with the following...

 

What happens is that I get a parsing error on the require_once line.

However, I've successfully run an alternate class from this self-same line (which at least proves that the require_once directory call is working), so I suspect that the problem is somewhere else...[i just don't know how to take this to pieces to see what's wrong...]

 

If anybody would be kind enough to check the parsing/syntax for the attached and let me know what might be wrong, that would be truly great.

 

      Tim

 

[attachment deleted by admin]

Link to comment
Share on other sites

What's the full error?

 

My browser returns...

Parse error: syntax error, unexpected T_REQUIRE_ONCE in /home/blah/public_html/pictures.php on line 12

 

Okay...Thanks for your speed...I'll strip out the line numbers and re-post...10 minutes...

Link to comment
Share on other sites

Hopefully you read this before you try to do it by hand.

 

<!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>PHP Flickr Viewer</title>
</head>
<body>

<?php
require_once("phpFlickr/phpFlickr.php");
$flickr = new phpFlickr("long flickr api number");
$username="my_Flickr_username_w_underscores_-_case_sensitive?";

$open=$_GET["o"];
$page=$_GET["p"];
$viewpage=$_GET["v"];
if($open=="") {
			$page="1";
			$viewpage="1";
}
$width=10

$user = $flickr->people_findByUsername($username);

if($user['id']==NULL){
echo "<div class=\"thumbnails\">\n";
echo "invalid username, or the Flickr API is down";
echo "</div>\n";
}

$pics = $flickr->people_getPublicPhotos($user['id'], NULL, $width, $viewpage);
$baseurl = $flickr->urls_getUserPhotos($user['id']);

if($open=="") {
$first=(current($pics['photo']));
$open=$first[id];
}

echo "<div class=\"bigpic\">\n";

foreach ($pics['photo'] as $workingpic) {
if($workingpic[id]==$open) {
	$workingurl = $flickr->buildPhotoURL($workingpic, "Medium");
	$workingtitle = $workingpic[title];
	echo "<h1>". $workingtitle ."</h1>\n";
	echo "<a href=\"" . $baseurl . $open . "\">";
	echo "<img alt=\"" . $workingtitle . "\"src=\"" . $workingurl . "\"/></a>\n";
}
}

echo "<p>Click on the image to open it's Flickr.com page</p>\n";
echo "</div>\n";
reset($pics);

$pics = $flickr->people_getPublicPhotos($user['id'], NULL, $width, $page);

echo "<div class=\"thumbnails\">\n";
echo "<p>Photostream pictures - click to open:</p>\n";

if($page!="1")
{
//display back link
$linkp=($page-1);
echo "<a href=\"./pictures.php?o=" . $open . "&p=" . $linkp . "&v=" . $viewpage . "\">back</a>\n";
}

foreach ($pics['photo'] as $workingpic) {
$workingurl = $flickr->buildPhotoURL($workingpic, "Square");
$workingtitle = $workingpic[title];
$workinglink = "./pictures.php?o=" . $workingpic[id] . "&p=" . $page . "&v=" . $page;
echo "<a href=\"" . $workinglink . "\">";
echo "<img alt=\"" . $workingtitle . "\"src=\"" . $workingurl . "\"/></a>\n";
}

$linkp=($page+1);
if($linkp<=$pics['pages'])
{
echo "<a href=\"./pictures.php?o=" . $open . "&p=" . $linkp . "&v=" . $viewpage . "\">next</a>\n";
}
?>
</div>
</body>
</html>

 

Macros > making multiple changes by hand.

Link to comment
Share on other sites

Hopefully you read this before you try to do it by hand.

 

Actually I just launched the app I use and clicked 'remove' numbers.

 

Is your code, my code without the numbers?

 

    TC 

 

[attachment deleted by admin]

Link to comment
Share on other sites

The 10 minute hiatus was so I could check the text I'd already uploaded to the server, to see whether the line numbers were there as well - not necessarily - but actually, yes; they were!

 

So I've stripped the numbers out and now the error is as follows:

 

Parse error: syntax error, unexpected T_VARIABLE in /home/blah/public_html/pictures.php on line 25

 

...Which is this:

$user = $flickr->people_findByUsername($username);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.