Instagram API pagination - php

I am using the below code which works well at loading all the images that match the #spproject tag. What i'd like to do is load 9 photos at a time and then either load more with ajax or just link to previous/next pages. Problem is i dont quite understand how to do it using the API, can you help?
CODE:
<?PHP
function get_instagram($next=null,$width=160,$height=160){
if($next == null ) {
$url = 'https://api.instagram.com/v1/tags/spproject/media/recent?access_token=[TOKEN]&count=10';
}
else {
$url .= '&max_tag_id=' . $next;
}
//Also Perhaps you should cache the results as the instagram API is slow
$cache = './'.sha1($url).'.json';
//unlink($cache); // Clear the cache file if needed
if(file_exists($cache) && filemtime($cache) > time() - 60*60){
// If a cache file exists, and it is newer than 1 hour, use it
$jsonData = json_decode(file_get_contents($cache));
}else{
$jsonData = json_decode((file_get_contents($url)));
file_put_contents($cache,json_encode($jsonData));
}
$result = '<ul id="instagramPhotos">'.PHP_EOL;
if (is_array($jsonData->data))
{
foreach ($jsonData->data as $key=>$value)
{
$result .= '<li><div class="album">
<figure class="frame">
<i><img src="'.$value->images->standard_resolution->url.'" alt="" width="'.$width.'" height="'.$height.'" name="'.$value->user->username.'"></i>
</figure>
<span class="count">#SPproject</span>
<figcaption class="name">'.$value->user->username.'</figcaption>
</div></li>'.PHP_EOL;
}
}
$result .= '</ul>'.PHP_EOL;
if(isset($jsonData->pagination->next_max_tag_id)) {
$result .= '<div>Next</div>';
}
return $result;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>#SPproject - A worldwide instagram idea</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
var totalPhotos = $('#instagramPhotos > li').size();
$('#result').text('Total tagged images: '+totalPhotos);
});
</script>
</head>
<body>
<div id="container">
<?=get_instagram(#$_GET['next']);?>
<div id="result"></div>
</div>
</body>
</html>
website: http://www.spproject.info/

The JSON object which Instagram is returning contains a pagination variable and in turn, a "next_url" variable. next_url is the API URL you need to call to get the next page of results.
Here is a good tutorial on pagination with Instagram.
Also, a tip for the future - don't post your API access codes on the internet...
The (revised) code below should be a good starting point for you.
<?PHP
function get_instagram($next=null,$width=160,$height=160){
$url = 'https://api.instagram.com/v1/tags/spproject/media/recent?access_token=[token]&count=9';
if($url !== null) {
$url .= '&max_tag_id=' . $next;
}
//Also Perhaps you should cache the results as the instagram API is slow
$cache = './'.sha1($url).'.json';
//unlink($cache); // Clear the cache file if needed
if(file_exists($cache) && filemtime($cache) > time() - 60*60){
// If a cache file exists, and it is newer than 1 hour, use it
$jsonData = json_decode(file_get_contents($cache));
}else{
$jsonData = json_decode((file_get_contents($url)));
file_put_contents($cache,json_encode($jsonData));
}
$result = '<ul id="instagramPhotos">'.PHP_EOL;
foreach ($jsonData->data as $key=>$value) {
$result .= '<li><div class="album">
<figure class="frame">
<i><img src="'.$value->images->standard_resolution->url.'" alt="" width="'.$width.'" height="'.$height.'" name="'.$value->user->username.'"></i>
</figure>
<span class="count">#SPproject</span>
<figcaption class="name">'.$value->user->username.'</figcaption>
</div></li>'.PHP_EOL;;
//$result .= '<li><img src="'.$value->images->standard_resolution->url.'" alt="" width="'.$width.'" height="'.$height.'" name="'.$value->user->username.'" /></li>'.PHP_EOL;
}
$result .= '</ul>'.PHP_EOL;
if(isset($jsonData->pagination->next_max_tag_id)) {
$result .= '<div>Next</div>';
}
return $result;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>#SPproject - A worldwide instagram idea</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
var totalPhotos = $('#instagramPhotos > li').size();
$('#result').text('Total tagged images: '+totalPhotos);
});
</script>
</head>
<body>
<div id="container">
<?=get_instagram(#$_GET['next']);?>
<div id="result"></div>
</div>
</body>
</html>

Related

Google sign in redirect back to login page if email not in the database

i am kinda new to PHP and not sure if this has been answered before i cant really find anything. what im asking for help with is with a google sign in if the email address is not in the database i would like it to redirect the user back to the login page, i have attached the code for the login below if anyone can help it will be highly appreciated thank you.
//session_start();
//index.php
include('classDev.php');
//Include Configuration File
include('config.php');
$login_button = '';
if(isset($_GET["code"]))
{
$token = $google_client->fetchAccessTokenWithAuthCode($_GET["code"]);
if(!isset($token['error']))
{
$google_client->setAccessToken($token['access_token']);
$_SESSION['access_token'] = $token['access_token'];
$google_service = new Google_Service_Oauth2($google_client);
$gData = $google_service->userinfo->get();
if(!empty($gData['given_name']))
{
$_SESSION['user_first_name'] = $gData['given_name'];
}
if(!empty($gData['family_name']))
{
$_SESSION['user_last_name'] = $gData['family_name'];
}
//if (empty(($data->select_where("user",$where_condition)))) {
// header("location: index.php?status=failure");
//}
if(!empty($gData['email']))
{
$where_condition = array("email" => $gData['email']);
if (($data->select_where("user",$where_condition))) {
$_SESSION['user_email_address'] = $gData['email'];
}
}
if (empty($_SESSION['email'])) {
//echo "please enter an email address that is valid.";
//header('location: index.php?status=failure');
}
if(!empty($gData['gender']))
{
$_SESSION['user_gender'] = $gData['gender'];
}
if(!empty($gData['picture']))
{
$_SESSION['user_image'] = $gData['picture'];
}
}
}
if(!isset($_SESSION['access_token']))
{
$login_button = 'Login With Google';
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Login using Google Account</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<br />
<h2 align="center">PHP Login using Google Account</h2>
<br />
<div class="panel panel-default">
<?php
if($login_button == '')
{
echo '<div class="panel-heading">Welcome User</div><div class="panel-body">';
echo '<img src="'.$_SESSION["user_image"].'" class="img-responsive img-circle img-thumbnail" />';
echo '<h3><b>Name :</b> '.$_SESSION['user_first_name'].' '.$_SESSION['user_last_name'].'</h3>';
echo '<h3><b>Email :</b> '.$_SESSION['user_email_address'].'</h3>';
echo '<h3><a href="logout.php">Logout</h3></div>';
//header('location: home.php');
include('home.php');
}
else
{
echo '<div align="center">'.$login_button . '</div>';
}
?>
</div>
</div>
</body>
</html>```

Is there a way to automatically use another image as a temporary placeholder for missing images sitewide?

I am working on building a site, but right now it has several images that I don't have actual images for yet. As this site has thousands of images or places where images should be, I don't want to have to manually change each of them and then change them again when I find the correct image. Is there a way to create a function that will look for the missing images and replace them with a specified image until the correct image is found?
Update: Since I am still a bit confused as to where to even place this function, I am going to add the code for one of the pages that I need this for then maybe someone can help me figure out how to place it.
Here is the code for one of the pages:
<?php
require_once('dbconnection.php');
mysqli_select_db($conn, $dbname);
$query_master = "SELECT DISTINCT * FROM `master_list` INNER JOIN types_join ON master_list.join_id=types_join.join_id WHERE `type_id` = 171 ORDER BY `item_id`";
$master = mysqli_query($conn, $query_master) or die(mysqli_error());
$row_master = mysqli_fetch_assoc($master);
$totalrows_master = mysqli_num_rows($master);
?>
<!doctype html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flower Trees</title>
<link href="/css/styles.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" type="image/png" href="img/favicon.png">
</head>
<body>
<div class="wrapper">
<a id="top"></a>
<?php require_once('header.php'); ?>
<?php require_once('nav.php'); ?>
<div class="category"><h2>Flower Trees</h2></div>
<div class="display">
<?php do { ?>
<ul>
<li><a href="details.php?recordID=<?php echo $row_master['master_id']; ?>"><img class="thumb" src="img/<?php echo $row_master['img']; ?>"/>
<br />
<span class="name"><?php echo $row_master['name']; ?></span></a></li>
</ul>
<?php } while ($row_master = mysqli_fetch_assoc($master)); ?>
<!-- end .display --></div>
<?php
mysqli_free_result($master);
?>
<?php require_once('footer.php'); ?>
<!-- end .wrapper --></div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</body>
</html>
Since this is as simple as a foreach loop, and not tons of images scattered across your webpage, you can use something like:
$image = file_exists('img/' . $row_master['img']) ? 'img/' . $row_master['img'] : 'placeholder.png';
Full code:
<?php
require_once('dbconnection.php');
mysqli_select_db($conn, $dbname);
$query_master = "SELECT DISTINCT * FROM `master_list` INNER JOIN types_join ON master_list.join_id=types_join.join_id WHERE `type_id` = 171 ORDER BY `item_id`";
$master = mysqli_query($conn, $query_master) or die(mysqli_error());
$row_master = mysqli_fetch_assoc($master);
$totalrows_master = mysqli_num_rows($master);
?>
<!doctype html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flower Trees</title>
<link href="/css/styles.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" type="image/png" href="img/favicon.png">
</head>
<body>
<div class="wrapper">
<a id="top"></a>
<?php require_once('header.php'); ?>
<?php require_once('nav.php'); ?>
<div class="category"><h2>Flower Trees</h2></div>
<div class="display">
<?php do {
$image = file_exists('img/' . $row_master['img']) ? 'img/' . $row_master['img'] : 'placeholder.png';
?>
<ul>
<li><a href="details.php?recordID=<?php echo $row_master['master_id']; ?>"><img class="thumb" src="<?php echo $image; ?>"/>
<br />
<span class="name"><?php echo $row_master['name']; ?></span></a></li>
</ul>
<?php } while ($row_master = mysqli_fetch_assoc($master)); ?>
<!-- end .display --></div>
<?php
mysqli_free_result($master);
?>
<?php require_once('footer.php'); ?>
<!-- end .wrapper --></div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</body>
</html>
I don't want to have to manually change each of them and then change them again when I find the correct image. Is there a way to create a function that will look for the missing images and replace them with a specified image until the correct image is found?
Such a function might be written as:
function im($imgName) {
$pathToImgs = "images/";
if (file_exists( $pathToImgs . $imgName )) {
echo $pathToImgs . $imgName;
}
else {
echo $pathToImgs . "placeholder.jpg";
}
}
Then in your html:
<img src="<?php im("product1.jpg"); ?>">
<img src="<?php im("product2.jpg"); ?>">
<img src="<?php im("product3.jpg"); ?>">
As a start.
***Edit 1:
Given your code where it says:
<img class="thumb" src="img/<?php echo $row_master['img']; ?>"/>
You might modify it with a conditional that inserts the placeholder image in the event that the target image simply doesn't exist, yet.
<img class="thumb" src="<?php
if (file_exists("img/" . $row_master['img'])) {
echo "img/" . $row_master['img'];
}
else {
echo 'img/placeholder.jpg';
}
?>">
You could reuse this functionality by turning the conditional into a php function, so described as a starter above.
Using jQuery, you can accomplish something easy enough using a global $('img') handler when errors occur. Simply swap them out with your placeholder image afterwards.
$('img').on('error', function() {
const oldSrc = encodeURIComponent($(this).attr('src'));
$(this).attr('src', `https://via.placeholder.com/300/000000/FFFFFF/?text=${oldSrc}`);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img src="imagethatdoesntexist.jpg"><br />
<img src="anotherimage.jpg">
Here I use placeholder.com (A convenient site for placeholder images such as this), and inject the old image source into the query string, which the site will render in the image itself.

Moving selected images using ajax in php

I am using an API (php) provided by Instagram to import user's images to my webpage.
It is working perfectly. But I want to add one functionality to it of moving selected images to user's folder (or anywhere). I thought it doing the post method but as the OAuth code is working only once this will not help.
So I decided to do it with ajax... but still no success... Please help me solve this.
I am pasting my index.php and success.php below.
index.php
<?php
require 'instagram.class.php';
// initialize class
$instagram = new Instagram(array(
'apiKey' => 'YOUR_API_KEY',
'apiSecret' => 'YOUR_API_SECRET',
'apiCallback' => 'http://localhost/MyApi/Instagram/success.php' // must point to success.php
));
// create login URL
$loginUrl = $instagram->getLoginUrl();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Instagram - OAuth Login</title>
<link rel="stylesheet" type="text/css" href="assets/style.css">
<style>
.login {
display: block;
font-size: 20px;
font-weight: bold;
margin-top: 50px;
}
</style>
</head>
<body>
<div class="container">
<header class="clearfix">
<h1>Instagram <span>display your photo stream</span></h1>
</header>
<div class="main">
<ul class="grid">
<li><img src="assets/instagram-big.png" alt="Instagram logo"></li>
<li>
<a class="login" href="<? echo $loginUrl ?>">ยป Login with Instagram</a>
<h>Use your Instagram account to login.</h4>
</li>
</ul>
</div>
</div>
</body>
</html>
success.php
<?php
ini_set("display_errors",1);
/**
* Instagram PHP API
*
* #link https://github.com/cosenary/Instagram-PHP-API
* #author Christian Metz
* #since 01.10.2013
*/
require_once 'instagram.class.php';
// initialize class
$instagram = new Instagram(array(
'apiKey' => 'YOUR_API_KEY',
'apiSecret' => 'YOUR_API_SECRET',
'apiCallback' => 'http://localhost/MyApi/Instagram/success.php' // must point to success.php
));
// receive OAuth code parameter
$code = $_GET['code'];
// check whether the user has granted access
if (isset($code)) {
// receive OAuth token object
$data = $instagram->getOAuthToken($code);
$username = $username = $data->user->username;
// store user access token
$instagram->setAccessToken($data);
// now you have access to all authenticated user methods
$result = $instagram->getUserMedia();
} else {
// check whether an error occurred
if (isset($_GET['error'])) {
echo 'An error occurred: ' . $_GET['error_description'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Instagram - photo stream</title>
<link href="https://vjs.zencdn.net/4.2/video-js.css" rel="stylesheet">
<link href="assets/style.css" rel="stylesheet">
</head>
<body>
<div class="container">
<header class="clearfix">
<img src="assets/instagram.png" alt="Instagram logo">
<h1>Instagram photos <span>taken by <? echo $data->user->username ?></span></h1>
</header>
<form method="POST" action="">
<table>
<tr>
<?php
$i=0;
// display all user likes
foreach ($result->data as $media) {
if($i==0 || $i%5 == 0)
{
echo "</tr><tr>";
}
// output images
if ($media->type === 'image') {
// image
$image = $media->images->low_resolution->url;
?>
<td align="center"><input type="checkbox" id="instagram_<?=$i;?>" name="instagram[]" value="<?php echo $image ?>"></td>
<td><img src="<?php echo $image ?>" width="200px" height="200px"/></td>
<?php
}
$i++;
}
?>
</tr>
</table>
<input type="submit" name="copy" id="copy" value="Copy Selected Files"><!-- onClick="copyImage('instagram[]', '1')" > -->
</form>
</div>
</body>
</html>
<!-- <script type="text/javascript">
$("#copy").click(function(e) {
e.preventDefault();
var name = $("#name").val();
var last_name = $("#last_name").val();
var dataString = 'name='+name+'&last_name='+last_name;
$.ajax({
type:'POST',
data:dataString,
url:'success.php',
success:function(data) {
alert(data);
}
});
});
</script> -->
<?php
if(isset($_POST['copy']))
{
/*$content = file_get_contents("https://scontent-b.xx.fbcdn.net/hphotos-xpf1/t1.0-9/10341463_1428435114089500_7065440848492935201_n.jpg ");
//Store in the filesystem.
$fp = fopen("/var/www/tmpImages/image.jpg", "w");
fwrite($fp, $content);
fclose($fp);*/
$imgArray = $_POST['instagram'];
$i=1;
foreach ($imgArray as $img)
{
$content = file_get_contents($img);
//Store in the filesystem.
$toPath = "/var/www/tmpImages/image".$i.".jpg";
$fp = fopen($toPath, "w");
fwrite($fp, $content);
fclose($fp);
$i++;
}
}
?>
Please help me out with this...
Thank you,

Cookies for popup handling

I would like to make a site where a popup appears once in 24h for every unique user. For this I use bPopup and cookies. I have tried lot of things and for now I am kind of "lost" in the code. Could you help me to make it work how it is supposed to be?
The code:
<?php
if (!isset($_COOKIE["Seen"])){
if ($_COOKIE['Seen'] != 'true') {
setcookie('Seen', 'false');
}
}
?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>
<script type="text/javascript" src="js/popup.js"> </script>
<LINK REL=StyleSheet HREF="style/style.css" TYPE="text/css" MEDIA=screen>
<html>
<head> </head>
<body>
<!-- Element to pop up -->
<div <?php if(isset($_COOKIE["Seen"])) {
if ($_COOKIE['Seen'] == 'true') {echo 'style="all:none; visibility:hidden; display:none">';}
else {
echo ' id="element_to_pop_up">';
$value = 'true';
$expire = time()+60*60*24;
setcookie('Seen', $value, $expire);
}
}
?>
<a href="#"class="b-close" style="position:absolute; margin-top:5px; margin-left:550px;"><img src="./image/close.png"><a/>
<iframe frameBorder="0" name="iFrame" width="600" height="500" src="welcome.php" scrolling="no"></iframe>
</div>
</body>
</html>
What about something like:
if(!isset($_COOKIE['popup']))
{
setcookie('popup', time());
echo '<script>alert(\'Here is your daily cookie :)\');</script>';
}
else
{
if((time() - $_COOKIE['popup']) > (60*60*24))
{
setcookie('popup', time());
echo '<script>alert(\'I see you enjoy our cookies, thanks for returning :)\');</script>';
}
}
Try this code. You don't need to check twice if the cookie is set since you're accounting for this at the top and setting to false. This code will set it to false if it is not set OR if (for some reason) it is not 'true'. Then, half way down, it will only need to check if it is true or not.
It's also best to just have a separate opening div open for each conditional, otherwise it can get very confusing and sloppy real fast.
<?php
if (!isset($_COOKIE['Seen']) || $_COOKIE['Seen'] != 'true') {
setcookie('Seen', 'false');
}
?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>
<script type="text/javascript" src="js/popup.js"> </script>
<LINK REL=StyleSheet HREF="style/style.css" TYPE="text/css" MEDIA=screen>
<html>
<head> </head>
<body>
<!-- Element to pop up -->
<?php
if ($_COOKIE['Seen'] == 'true') {echo '<div style="all:none; visibility:hidden; display:none">';}
else {
echo '<div id="element_to_pop_up">';
$value = 'true';
$expire = time()+60*60*24;
setcookie('Seen', $value, $expire);
}
?>
<a href="#"class="b-close" style="position:absolute; margin-top:5px; margin-left:550px;"><img src="./image/close.png"><a/>
<iframe frameBorder="0" name="iFrame" width="600" height="500" src="welcome.php" scrolling="no"></iframe>
</div>
</body>
</html>

Having problems with function defined in other file

My page won't load at all, browser says its redirecting in a way that is not loading. As the title suggests I think the issue is with one of the php files I include with require_once(). Let me just show you:
thumbnail.php:
<?php
if(!function_exists("makethumbnail"))
{
//die("right before function definition");
function makethumbnail($src,$new_name,$new_width,$new_height)
{
die("inside makethumbnail");
$si = imagecreatefromjpeg($src);
$w = imagesx($si);
$h = imagesy($si);
$vi = imagecreatetruecolor($new_width,$new_height);
imagecopyresampled($vi,$si,0,0,0,0,$new_width,$new_height,$w,$h);
imagejpeg($vi,$new_name);
}
}
?>
checksession.php:
<?php
session_start();
$session_name = "forces";
$com=0;
if(!function_exists("logout"))
{
function logout()
{
$_SESSION = array();
session_destroy();
header('Location:http://cs4.sunyocc.edu/~j.d.dancks/index.php');
}
}
if(!isset($_SESSION['time']) || !isset($_SESSION['nick']))
{
$com=2;
logout();
}
else if($_SESSION['time'] < time())
{
$com=3;
logout();
}
//redirect back to main whatever ignore this line
?>
index.php:
<?php
require_once("shopsite/thumbnail.php");
require_once("shopsite/checksession.php");
die("made it past the require_once");
$con = mysql_connect('localhost','jddancks','csc255');
mysql_select_db('test',$con);
$q = mysql_query("select prod_name,image_name,type1,type2 from Product",$con) or die("its the mysql");
$row = mysql_fetch_assoc($q);
$totalRows_Recordset1 = mysql_num_rows($q);
?>
<!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>Welcome to the shopsite</title>
<script type="text/javascript" src="shopsite/lib/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="shopsite/lib/jquery.jcarousel.min.js"></script>
<link rel="stylesheet" type="text/css" href="shopsite/skins/ie7/skin.css" />
<script type="text/javascript">
JQuery(document).ready(function() {
JQuery('#mycarousel').jcarousel({
itemLoadCallback:itemLoadCallbackFunction,
start:1,
auto:3,
animation:"slow",
wrap:"both"
});
});
</script>
</head>
<body>
<?php
session_start();
if(isset($_SESSION['nick']))
{
echo "<p>Welcome, ".$_SESSION['nick']."</p>";
}
die("Made it past the first php");
?>
<h1>Welcome to the one-stop shop for your every need!</h1>
<div class="jcarousel-ie7">
<p>Browse Items:</p>
<div class="jcarousel-container">
<div class="jcarousel-clip">
<ul id="mycarousel" class="jcarousel-skin-ie7">
<?php
$cnt=1;
do
{
$i=$row['image_name'];
$name=preg_split("/.jpg/",$i);
$name = "shopsite/thumb/".$name[0]."-index.jpg";
if(!file_exists($name))
{
makethumbnail("shopsite/images/".$row['image_name'],$name,50,50);
}
echo " <li class=\"jcarousel-item-".$cnt."\"><img src=\"".$name."\" /></li>\n";
$cnt=$cnt+1;
if($cnt>12) die("cnt larger than 12");
}
while($row = mysql_fetch_assoc($q));
?>
</ul>
</div>
<div disabled="disabled" class="jcarousel-prev jcarousel-prev-disabled"></div>
<div class="jcarousel-next"></div>
</div>
</div>
</body>
</html>
<?php mysql_free_result($row);
mysql_close($con); ?>
I want to insert images into a jquery carousel so a visitor can browse items they may want to purchase. I've never used jcarousel so I don't know if what I have works, I'm pretty sure thats not the problem. I guess its just one of those things you need a second pair of eyes for. The die statements in thumbnail.php make me believe that is the culprit, but it won't make it to the first line of the function, which is really confusing. I don't know how the php preporcessor works, other than its client-side.

Categories