xmshanx
September 9, 2011, 7:09am
1
Build An Automated PHP Gallery System In Minutes » SitePoint
I have a problem that when I upload a picture it uploads perfectly but there is error
Notice: Undefined offset: 5 in C:\Users\Mshan\Downloads\Compressed\USBWebserver v8_en\root\gallery\upload.php on line 34
line 34 is
if($photos_uploaded[‘size’][$counter] > 0)
what should I do for this???
:mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad:
xmshanx
September 10, 2011, 12:29pm
2
$cid = (int)($_GET['cid']);
$pid = (int)($_GET['pid']);
here problem is in this two codes how to get cid and pid without using these codes
xmshanx
September 9, 2011, 1:33pm
3
But they didn’t say to create a different page to link those…viewgallery should work properly there is something wrong in the code did you try the ARCHIVE ??? FULL OF ERRORS sigh
The problem is not in those two lines. You can’t get cid and pid without them.
Did you read that article you linked to? To me it seems that part of the application isn’t there. You have to make a page where you link to viewgallery.php like is explained in the part I quoted.
xmshanx
September 9, 2011, 1:05pm
6
guido2004:
Notice: Undefined index: cid in E:\\Usb Web Server v7.0\\Root\\gallery\\[B][COLOR="Red"]viewgallery.php[/COLOR][/B] on line 8
No you don’t. You also have viewgallery.php, otherwise it wouldn’t give you that error
In fact, you should have 5 php files.
From the page you got the script from:
sorry yes there is a viewgallery.php but where should I put that links
Notice: Undefined index: cid in E:\\Usb Web Server v7.0\\Root\\gallery\\[B][COLOR="Red"]viewgallery.php[/COLOR][/B] on line 8
I only have preupload.php and upload.php only
No you don’t. You also have viewgallery.php, otherwise it wouldn’t give you that error
In fact, you should have 5 php files.
From the page you got the script from:
Create Direct Links to Categories and Images
To create direct links from other pages of our site to the categories, we just need to know the Category Id. For example, to link to Category Id = 1 you can use the following URL:
http://www.yoursite.com/gallery/viewgallery.php?cid=1
To link up an image, you need to know its Photo Id and as well as its Category Id:
http://www.yoursite.com/gallery/viewgallery.php?cid=1&pid=1
The above link will open the Photo Id = 1 if that exists in the Category Id 1.
xmshanx
September 9, 2011, 12:39pm
8
guido2004:
How do you run that script? Putting E:\Usb Web Server v7.0\Root\gallery\viewgallery.php in the browser?
That won’t work. It needs values for cid and pid in the query string. For example:
E:\\Usb Web Server v7.0\\Root\\gallery\\viewgallery.php?cid=1&pid=1
I’m sure somewhere in the gallery script you’re working on, there’s a link to viewgallery.php with cid and pid values.
I only have preupload.php and upload.php only when I upload a pictures it shows the uploaded picture and echos a File 1 Added but there is no such link
How do you run that script? Putting E:\Usb Web Server v7.0\Root\gallery\viewgallery.php in the browser?
That won’t work. It needs values for cid and pid in the query string. For example:
E:\\Usb Web Server v7.0\\Root\\gallery\\viewgallery.php?cid=1&pid=1
I’m sure somewhere in the gallery script you’re working on, there’s a link to viewgallery.php with cid and pid values.
xmshanx
September 9, 2011, 11:58am
10
it shows only a
Array ( )
xmshanx
September 9, 2011, 11:56am
11
Array ( )
Notice: Undefined index: cid in E:\\Usb Web Server v7.0\\Root\\gallery\\viewgallery.php on line 9
Notice: Undefined index: pid in E:\\Usb Web Server v7.0\\Root\\gallery\\viewgallery.php on line 10
It appears you are not sending cid and pid in the query string. How are you making the call to this script? Through a link?
And add this to the top of the script:
print_r($_GET);
Oh now its working perfectly
Arrays start with key value 0, so if an array contains 5 elements, the counter should go from 0 to 4.
The while loop accepted the value 5 as well (the number of array elements), but there was no key 5. Instead, it should accept all values less than the number of array elements.
xmshanx
September 9, 2011, 10:54am
14
Notice: Undefined index: cid in E:\Usb Web Server v7.0\Root\gallery\viewgallery.php on line 8
Notice: Undefined index: pid in E:\Usb Web Server v7.0\Root\gallery\viewgallery.php on line 9
<?php
include("config.inc.php");
// initialization
$result_array = array();
$counter = 0;
$cid = (int)($_GET['cid']);
$pid = (int)($_GET['pid']);
// Category Listing
if( empty($cid) && empty($pid) )
{
$number_of_categories_in_row = 4;
$result = mysql_query("
SELECT
c.category_id,
c.category_name,
COUNT(photo_id)
FROM
gallery_category AS c LEFT JOIN
gallery_photos AS p ON
p.photo_category = c.category_id
GROUP BY c.category_id
");
while( $row = mysql_fetch_array( $result ) )
{
$result_array[] = "<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
}
mysql_free_result( $result );
$result_final = "<tr>\
";
foreach($result_array as $category_link)
{
if($counter == $number_of_categories_in_row)
{
$counter = 1;
$result_final .= "\
</tr>\
<tr>\
";
}
else
$counter++;
$result_final .= "\ <td>".$category_link."</td>\
";
}
if($counter)
{
if($number_of_categories_in_row-$counter)
$result_final .= "\ <td colspan='".($number_of_categories_in_row-$counter)."'> </td>\
";
$result_final .= "</tr>";
}
}
// Thumbnail Listing
else if( $cid && empty( $pid ) )
{
$number_of_thumbs_in_row = 5;
$result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'" );
$nr = mysql_num_rows( $result );
if( empty( $nr ) )
{
$result_final = "\ <tr><td>No Category found</td></tr>\
";
}
else
{
while( $row = mysql_fetch_array( $result ) )
{
$result_array[] = "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>";
}
mysql_free_result( $result );
$result_final = "<tr>\
";
foreach($result_array as $thumbnail_link)
{
if($counter == $number_of_thumbs_in_row)
{
$counter = 1;
$result_final .= "\
</tr>\
<tr>\
";
}
else
$counter++;
$result_final .= "\ <td>".$thumbnail_link."</td>\
";
}
if($counter)
{
if($number_of_photos_in_row-$counter)
$result_final .= "\ <td colspan='".($number_of_photos_in_row-$counter)."'> </td>\
";
$result_final .= "</tr>";
}
}
}
// Full Size View of Photo
else if( $pid )
{
$result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
list($photo_caption, $photo_filename) = mysql_fetch_array( $result );
$nr = mysql_num_rows( $result );
mysql_free_result( $result );
if( empty( $nr ) )
{
$result_final = "\ <tr><td>No Photo found</td></tr>\
";
}
else
{
$result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
list($category_name) = mysql_fetch_array( $result );
mysql_free_result( $result );
$result_final .= "<tr>\
\ <td>
<a href='viewgallery.php'>Categories</a> >
<a href='viewgallery.php?cid=$cid'>$category_name</a></td>\
</tr>\
";
$result_final .= "<tr>\
\ <td align='center'>
<br />
<img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
<br />
$photo_caption
</td>
</tr>";
}
}
// Final Output
?>
<html>
<head>
<title>Gallery View</title>
</head>
<body>
<table width='100%' border='0' align='center' style='width: 100%;'>
<?php echo $result_final; ?>
</table>
</body>
</html>
xmshanx
September 9, 2011, 10:51am
15
Oh now its working perfectly
xmshanx
September 9, 2011, 10:13am
16
mannn this is a pain in my ass…who made this Build An Automated PHP Gallery System In Minutes » SitePoint tutorial -__________-
xmshanx
September 9, 2011, 10:12am
17
photo_caption: Array ( [0] => [1] => [2] => [3] => [4] => )
counter: 0
counter: 1
counter: 2
counter: 3
counter: 4
counter: 5
Notice: Undefined offset: 5 in E:\\Usb Web Server v7.0\\Root\\gallery\\upload.php on line 38
File 1 Added
Do it like this (I changed the first echo, and moved the second inside the while loop)
[B][COLOR="Red"]echo "photos_uploaded: "; print_r($photos_uploaded); echo "<br />";[/COLOR][/B]
while( $counter <= count($photos_uploaded) )
{
[B][COLOR="Red"]echo "counter: $counter<br />";[/COLOR][/B]
Never mind, this
while( $counter [B][COLOR="Red"]<=[/COLOR][/B] count($photos_uploaded) )
should be
while( $counter [B][COLOR="Red"]<[/COLOR][/B] count($photos_uploaded) )
You didn’t do what I asked you to do. You didn’t change the first echo. Just copy and paste it:
echo "photos_uploaded: "; print_r($photos_uploaded); echo "<br />";