Código PHP:
   {
    if ($dir = @opendir("images/")) 
    { 
    Código PHP:
   <?php 
$direct ="".$reg['c_path']."";//  
function loadPics($pics)
{
    if ($dir = @opendir("$direct/")) 
    {    hice la prueba al final mostrar la variable
Código PHP:
   <?php echo "$direct"; ?>    les dejo el codigo completo para ver si me podrian hechar una mano, gracias y saludos a todos
galeria.php
Código PHP:
   <?php 
session_start();
include ('config.php');
$c_capitulo = $_GET['capitulo']; // Esto recoje los datos de la variable id en la url.
$registros=mysql_query("SELECT * FROM capitulos WHERE c_capitulo='$c_capitulo'",  
           $db_link) or
  die("Problemas en el select:".mysql_error());
while ($reg=mysql_fetch_array($registros))
{
 
 
?>
<?php 
$direct ="".$reg['c_path']."";//  
function loadPics($pics)
{
    if ($dir = @opendir("$direct/")) 
    {
        while($file = readdir($dir)) 
        {
            if(ereg("\.jpg|\.gif|\.bmp|\.pnc$", $file))
                array_push($pics, $file);
        }  
        
        closedir($dir);
    }
    
    sort($pics);
    return $pics;
}
function listPics($pics)
{
    while(list($num, $pic) = each($pics))
    {
        echo "<option value='".$PHP_SELF."?c=$num'>".getPicName($num, $pics)."</option>\n";
    }
}
function showPic($c, $pics)
{
    $pic = $pics[$c];
    echo "<!-- $c -->\n";
    echo "<img src=\"$direct/$pic\">";
}
function getPrev($c, $pics)
{
    $len = count($pics);
    $ret = 0;
    if($len > 1)
    {
        if($c == 0)
            $ret = $len - 1;
        else
            $ret = $c - 1;
    }
    else
    {
        $ret = $c;
    }
    return $ret;
}
function getNext($c, $pics)
{
    $len = count($pics);
    $ret = 0;
    if($len > 1)
    {
        if($c == $len -1)
            $ret = 0;
        else
            $ret = $c + 1;
    }
    else
    {
        $ret = $c;
    }
    return $ret;
}
function getPicName($c, $pics)
{
    return preg_replace("/\.jpg$|\.gif$|\.png$/i", "", $pics[$c]);
}
$pics = array();
$pics = loadPics($pics);
if(!isset($_REQUEST['c'])) $_REQUEST['c'] = 0;
?>
<!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>
<title>"<?=getPicName($_REQUEST['c'], $pics)?>"</title>
<style type="text/css">
body {
    background: #212020;
    font: 11px/16px arial, helvetica, sans-serif;
    color: #363333;
    margin: 0;
    padding: 0;
    }
table, tr, td {
    font: 11px/16px arial, helvetica, sans-serif;
    color: #363333;
    border-collapse: collapse;
    border: none;
    margin: 0;
    padding: 0;
    }
    
#header { background: url(images/backgroundHeader.gif) top repeat-x; }
#title {
    font-size: 24px;
    color: #fff;
    padding: 30px;
    margin-top: 2px;
    }
#dropdownNav {
    background: #212020;
    float: right;
    font-weight: bold;
    color: #959595;
    border-left: 1px solid #2b2a2a;
    padding: 30px 30px 25px 30px;
    }
    
.navigation {
    background: #959595 url(images/backgroundNavigation.gif) top repeat-x;
    border-top: 2px solid #b6b6b6;
    border-bottom: 2px solid #b6b6b6;
    width: 100%;
    }
.navLeft {
    text-align: left;
    padding: 10px 20px;
    width: 50%;
    font-weight: bold;
    font-size: 12px;
    }
.navRight {
    text-align: right;
    padding: 10px 20px;
    width: 50%;
    font-weight: bold;
    font-size: 12px;
    }
#container {
    background: #fff;
    margin: 0;
    padding: 0;
    width: 100%;
    }
#index {
    background: #e7e7e7;
    vertical-align: top;
    padding: 0;
    border-right: 1px dashed #d7dee2;
    white-space: nowrap;
    width: 200px;
    }
#index ul {
    margin: 0;
    padding: 0;
    }
#index ul li {
    list-style: none;
    font-weight: bold;
    border-bottom: 1px dashed #d5d5d5;
    }
    
#design {
    vertical-align: top;
    padding: 20px;
    text-align: center;
    }
    
p, h1 { margin-top: 0; }
a:link, a:active, a:visited {
    color: #004f86;
    text-decoration: none;
    }
a:hover {
    color: #0072c1;
    text-decoration: none;
    }
.navigation a:link, .navigation a:active, .navigation a:visited {
    color: #fff;
    text-decoration: none;
    }
.navigation a:hover {
    color: #ddd;
    text-decoration: none;
    }
    
#index a:link, #index a:active, #index a:visited {
    background: #f3f3f3;
    text-decoration: none;
    padding: 5px 10px;
    display: block;
    }
#index a:hover {
    background: #f9f9f9;
    text-decoration: none;
    padding: 5px 10px;
    display: block;
    }
    
img { border: none; }
#design img {
    padding: 4px;
    border: 1px dashed #d7dee2;
    }
    
#footer {
    padding: 20px;
    color: #858585;
    font-size: 11px;
    }
#footer a:link, #footer a:active, #footer a:visited {
    color: #858585;
    text-decoration: none;
    }
#footer a:hover { color: #a1a1a1;}
form {
    margin: 0;
    padding: 0;
    }
select {
    font: 11px/16px arial, helvetica, sans-serif;
    color: #363333;
    margin: 0 0 0 5px;
    padding: 0;
    }
    
</style>
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<div id="header">
    <div id="dropdownNav">
        <form name="menu">
        Chose Design: 
          <select name="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
              <option><?=getPicName($_REQUEST['c'], $pics)?></option>
            <? listPics($pics); ?>
          </select>
        </form>
    </div>
    <div id="title"><?=getPicName($_REQUEST['c'], $pics)?></div>
    
</div>
<table class="navigation">
    <tr>
        <td class="navLeft"><a href=<?=$PHP_SELF?>?c=<?=getPrev($_REQUEST['c'], $pics)?>>« previous design</a></td>
        <td class="navRight"><a href=<?=$PHP_SELF?>?c=<?=getNext($_REQUEST['c'], $pics)?>>next design »</a></td>
    </tr>
</table>
<table id="container">
    <tr>
        <td id="design">
            <a href=<?=$PHP_SELF?>?c=<?=getNext($_REQUEST['c'], $pics)?>>
            <?
                if(isset($_REQUEST['c']))
                showPic($_REQUEST['c'], $pics);
            ?>
            </a>
            
        </td>
    </tr>
</table>
<table class="navigation">
    <tr>
        <td class="navLeft"><a href=<?=$PHP_SELF?>?c=<?=getPrev($_REQUEST['c'], $pics)?>>« previous design</a></td>
        <td class="navRight"><a href=<?=$PHP_SELF?>?c=<?=getNext($_REQUEST['c'], $pics)?>>next design »</a></td>
    </tr>
</table>
<div id="footer"><a href="http://imgview.com/">IMGView Photo Viewer</a></div>
<?php echo "$direct"; ?>
<?php 
}
?>
</body>
</html>    
 

 Agregar Variable a function
 Agregar Variable a function 
 
 

