Re: Photo Gallery Comments.. NOT WORKING

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I see that you try to use $result, which is a resource [i think], as a
normal string.
Try to use the fetch data instead of the resource.


vio-
----- Original Message ----- 
From: "Adam Symonds" <adamsymonds@froggy.com.au>
To: <php-db@lists.php.net>
Sent: Tuesday, September 23, 2003 9:14 AM
Subject:  Photo Gallery Comments.. NOT WORKING


> Hi I have the following code which is a photo gallery, I have set it up so
> users
> can add comments to the photos, what I want to happen is in the gallery if
a
> user
> has posted a comment on the photo, I want it to say comments under the
photo
> in the gallery, I have tried doing this using  IN_ARRAY but I am getting
an
> error msg,
>
> Warning: in_array(): Wrong datatype for second argument
> on line 203
>
> line 203 is this: if(in_array($images[$i],$result))echo "<br><font
> class=blue>Comments</font>";
> will have a play around with a few things and left yuo know if I suceed b4
> you get back.
>
> Can someone see what I am doing wrong with the in_array..
>
> Thanx In advance
> Adam
>
> ==================================================
>
> <?PHP
> //start of comments selection...
>    $mysql_access = mysql_connect("localhost", "username", "password") or
> DIE(mysql_error());
>    mysql_select_db("database", $mysql_access) or DIE(mysql_error());
> $query = "SELECT * FROM comphotolink WHERE comphotolink.PhotoPath =
> $PathVar";
>    $result = mysql_query($query, $mysql_access) or DIE(mysql_error());
> if ($result) {
> while ($r = mysql_fetch_array($result))
> { // Begin While
> extract($r);
> $PhotoName = $PhotoName;
> //echo "$PhotoName <br>";
> } //End While
> } else {
> echo "no comments<br><br>";
> }
>
> //end of comments selection
>
> //page vars
> $total = count($images);
> $limit = 15;
> $page = $_GET['page'];
> $num_prow=3;
>
> //$offset = ($page - 1) * $limit;
>
> //$jpgs=0;
> $handle=opendir($PathVar);
> $index=0;
> $images;
> $last_updated;
>
> while($file=readdir($handle)){
>
> if($file!='.' && $file!='..'){
> $myfile=explode(".",$file);
>
> if($myfile[1]=='jpg' || $myfile[1]=='JPG'){
> $images[$index]=$file;
> //$size[$index]=filesize($file);
> //$date[$index]=filemtime($file);
> $thumb[$index]=$file;
> $index++;
> $jpgs++;
> }
> }
> }
>
> if(!$images){
> print "::<B>Warning</b>::<br>This folder contains no allowed image
files.";
> exit;
> }
>
> $total=count($images);
>
> $numPages = ceil($total / $limit);
>
>
> $j=0;
>
> // Set first set of pictures
> if(!isset($pics)){$pics=$page * $limit;}
>
> //$pics = $page * $limit;
>
>
> $from = $pics-$limit;
> $pp = $pics+$limit;
> // =====OUTPUT=====
>
> $query2 = "SELECT * FROM eventlistings WHERE PhotoPath = $PathVar";
>    $result2 = mysql_query($query2, $mysql_access) or DIE(mysql_error());
> if ($result2) {
> while ($r = mysql_fetch_array($result2))
> { // Begin While
> extract($r);
> echo "";
> }} //End While
>
> echo "<div align=center><strong>$EventName - $EventDate</strong> <br>
> Directory contains a total of ".count($images)." image files </div><BR>";
>
> echo "<div align=center><table cellspacing=10 cellpadding=10
> bordercolor=#CC33CC border=1 class=txt><tr bordercolor=#000000
> bgcolor=White>";
>
> for($i = $from; $i < $pics && $i < $total; $i++){
>
> if($j == $num_prow){
> echo "
> <tr bordercolor=#000000 bgcolor=White><td align=center valign=top><a
> href=\"MainPhoto.php?Image=$thumb[$i]&PhotoPath=$PathVar\">
> <!-- $images[$i]<BR><BR> -->
> <img border=0 src=\"$PathVar/thumb/$thumb[$i]\"></a>";
> if(in_array($images[$i],$result))echo "<br><font
> class=blue>Comments</font>";
> echo "</td>";
> //
> $j = 1;
>
> }else{
> echo "<td align=center valign=top><a
>
href=\"MainPhoto.php?Image=$images[$i]&PhotoPath=$PathVar\"><!--$images[$i]<
> BR><BR> --><img border=0 src=\"$PathVar/thumb/$thumb[$i]\"></a>";
> //
> if(in_array($images[$i],$result))echo "<br><font
> class=blue>Comments</font>";//
>
> $j++;
>
> }
> }
> echo "</tr></table><BR><BR><BR>";
>
> if ($page == 1) // this is the first page - there is no previous page
>         echo "Previous";
>     else            // not the first page, link to the previous page
>         echo "<a href=\"Gallery.php?PathVar=$PathVar&page=" . ($page - 1)
.
> "\" class=cssbtn>Previous</a>";
>
>     for ($i = 1; $i <= $numPages; $i++) {
>         echo " | ";
>         if ($i == $page)
>             echo "$i";
>         else
>             echo "<a
href=\"Gallery.php?PathVar=$PathVar&page=$i\">$i</a>";
>     }
>
>     if ($page == $numPages) // this is the last page - there is no next
page
>         echo " | Next";
>     else            // not the last page, link to the next page
>         echo " | <a href=\"Gallery.php?PathVar=$PathVar&page=" . ($page +
1)
> . "\" class=cssbtn>Next</a>";
> /*
> if($i < $total){echo "<a
> href=\"".$PHP_SELF."?PathVar=$PathVar&page=$pp\">Next</a>";}
> if($page != $total){echo " <a
> href=\"".$PHP_SELF."?PathVar=$PathVar&page=$total\">Last</a></div>";}
> */
> echo "<br><br></body></html>";
>
> closedir($handle);
> ?>
>
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux