Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 16th, 2003, 01:35 PM
HriBB HriBB is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Slovenia
Posts: 15 HriBB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Notepad's image gallery+GD

SYSTEM: winxp, easyphp (apace 1.3, php 4.3.3, mysql 4.xxx)

ME: beginner

php Code:
Original - php Code
  1.  
  2. function display_body($navtree)
  3. {
  4.     if(isset($GLOBALS['nav']))
  5.     {
  6.         for($i=1; $i<count($GLOBALS['crunch']); $i++)
  7.         $uri .= !is_numeric($GLOBALS['crunch'][$i]) ? $GLOBALS['crunch'][$i].'/' : '';
  8.     }
  9.  
  10.     if(is_array($navtree))
  11.     {
  12.         if(!is_numeric(implode('', array_keys($navtree))))
  13.         {
  14.             print('<tr><td>');
  15.             foreach($navtree as $key=>$value)
  16.             {
  17.                 if(!is_int($key))
  18.                 {
  19.                     if(is_array($value))
  20.                         print('<a href="'.$_SERVER['PHP_SELF']
  21.                         .'?nav='.rawurlencode($GLOBALS['nav']
  22.                         .'>'.$key).'">'.$key.'</a><br />');
  23.                     else
  24.                         print($key.'<br />');
  25.                 }
  26.             }
  27.         print('</td></tr>');
  28.     }
  29.     else
  30.     {
  31.         $total = count($navtree);
  32.         if(isset($GLOBALS['viewall']))
  33.         {
  34.             $check = $total / COLS;
  35.             $rows = is_int($check) ? $check : floor($check) + 1;
  36.         }
  37.         else
  38.             $rows = ROWS;
  39.  
  40.             navigator($total);
  41.             for($i=0; $i<$rows; $i++)
  42.             {
  43.                 print('<tr>');
  44.                 for($n=0; $n<COLS; $n++)
  45.                 {
  46.                     $index = $GLOBALS['start']++;
  47.                     $image = $index < $total ? $navtree[$index] : '&nbsp;';
  48.                     print('<td align="center" width="'.THMBWIDTH.'" height="'.THMBHEIGHT.'">');
  49.                     if($image != '&nbsp;')
  50.                     {
  51.                         print('<a href="'.$_SERVER['PHP_SELF']
  52.                         .'?nav='.rawurlencode($GLOBALS['nav']
  53.                         .'>'.$index).'">');
  54.                         print('<img src="imgsrc.php?src='.PATH.rawurlencode
  55.                         ($uri).$image.'" border="0" />');
  56.                         print('</a>');
  57.                     }
  58.                             else
  59.                         print($image);
  60.                                 print('</td>');
  61.                 }
  62.                 print('</tr>');
  63.             }
  64.             navigator($total);
  65.         }
  66.     }
  67.     elseif(file_exists(PATH.$uri.$navtree))
  68.     {
  69.         $root = explode('/', dirname(PATH.'.'));
  70.         print('<tr><td><img src="'.end($root).'/'.$uri.$navtree.'"></td></tr>');
  71.     }
  72.     else
  73.         print('<tr><td>invalid request</td></tr>');
  74. }


Ok this is the same code which notepad used in his tutorial. I get this error message:
Notice: Undefined variable: uri in d:wwwimages.php on line 85

I notice a dot(.) before = ($uri .= !is_numeric...)
If I remove it (but this probably is not OK) the error is gone. But then when i click the thumbnail i get: invalid request (i knew it was not OK)

Please help me.

Reply With Quote
  #2  
Old December 16th, 2003, 03:02 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Notepad's image gallery+GD

it's just a notice, put an '@' before it:

@$uri .= etc..

kinda weird tho yah, of course it's an undefined variable.. that's why we're defining it

Reply With Quote
  #3  
Old December 16th, 2003, 09:14 PM
HriBB HriBB is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Slovenia
Posts: 15 HriBB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Notepad's image gallery+GD

what does the dot in front of = mean?

Reply With Quote
  #4  
Old December 16th, 2003, 09:42 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Notepad's image gallery+GD

it's a concatination, it means add onto the existing value rather than redefine the variable completely..

for example:
php Code:
Original - php Code
  1.  
  2. $uri = 'one';
  3. $uri = 'two';
  4. echo $uri; // prints two
  5.  
  6. $uri = 'one';
  7. $uri .= 'two';
  8. echo $uri; // prints onetwo
  9.  

Reply With Quote
  #5  
Old December 17th, 2003, 12:04 AM
HriBB HriBB is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Slovenia
Posts: 15 HriBB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Notepad's image gallery+GD

thanx 4 the explanations guys.
but now i have another problem. GD library won't display the thumbnails. I can open the images, but the thumbnails aren't there. GD library works fine, i tested it..
this code:
php Code:
Original - php Code
  1. <?php
  2.         header ("Content-type: image/png");
  3.         $img_handle = ImageCreate (230, 20) or die ("Cannot Create image");
  4.         $back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
  5.         $txt_color = ImageColorAllocate ($img_handle, 233, 114, 191);
  6.         ImageString ($img_handle, 31, 5, 5"My first Program with GD", $txt_color);
  7.         ImagePng ($img_handle);
  8.     ?>

Outputs a black image saying: "My first Program with GD"
I updated php to 4.3.4, apache is v. 1.3 (i use easyphp), and i run winXP (is this the problem). I studied GD library tutorial and studied the code in both images.php and imgsrc.php carefully but i cant find the solution.

is there a problem in this line?
php Code:
Original - php Code
  1. print('<img src="imgsrc.php?src='.PATH.rawurlencode($uri).$image.'"


Notepad u said that .= adds a value to the variable $uri (which is at the time NULL, or am i wrong). So if the value is added how come there is and error undefined variable uri?

Sorry for asking so many questions, but i really want to finish this great script, which is BTW exactly what i need, and what i've been looking for for a month

here's the code:

IMAGES.PHP
php Code:
Original - php Code
  1. <?php
  2.  
  3. require_once('config.php');
  4.  
  5. $nav = isset($_REQUEST['nav']) ? urldecode($_REQUEST['nav']) : null;
  6. if(isset($nav))
  7. {
  8.     $crunch = explode('>', trim($nav));
  9.     foreach($crunch as $value)
  10.     {
  11.         if(!ctype_alnum(str_replace(' ', '', $value))) {
  12.         $invalid = true;
  13.     } else {
  14.         $invalid = false;
  15.         }
  16.     }
  17.     if($invalid)
  18.     $nav = null;
  19. }
  20.  
  21. $pg = isset($_REQUEST['pg']) && (ctype_digit($_REQUEST['pg']) ||
  22. $_REQUEST['pg'] == 'all') ? $_REQUEST['pg'] : 0;
  23. $viewall = is_numeric($pg) ? null : true;
  24. $pg = intval($pg) <= 0 ? 1 : $pg;
  25.  
  26. $section = ROWS * COLS;
  27. $end = $section * $pg;
  28. $start = $end - $section;
  29. $prev = $pg - 1;
  30. $next = $pg + 1;
  31.  
  32. print('<table border="0" align="center" cellpadding="1" cellspacing="1">');
  33.  
  34. function navigator($total)
  35. {
  36.     $p = '<a href="'.$_SERVER['PHP_SELF'].'?nav='.rawurlencode($GLOBALS['nav']).'&pg='.$GLOBALS['prev'].'"><<</a>';
  37.     $n = '<a href="'.$_SERVER['PHP_SELF'].'?nav='.rawurlencode($GLOBALS['nav']).'&pg='.$GLOBALS['next'].'">>></a>';
  38.     $a = '<a href="'.$_SERVER['PHP_SELF'].'?nav='.rawurlencode($GLOBALS['nav']).'&pg=all">viewall</a>';
  39.  
  40.     print('<tr><td align="center" colspan="' . COLS . '">');
  41.    
  42.     if(($GLOBALS['pg'] == 1 && $GLOBALS['end'] >= $total) || isset($GLOBALS['viewall'])