在其他文件中定义的功能有问题

时间:2012-09-27 20:37:23

标签: php function

我的页面根本不会加载,浏览器说它以无法加载的方式重定向。正如标题所暗示的那样,我认为问题在于我在require_once()中包含的一个php文件。我来告诉你:

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); ?>

我想将图像插入到jquery轮播中,以便访问者可以浏览他们想要购买的商品。我从来没有使用过jcarousel因此我不知道我的工作是否有效,我很确定这不是问题所在。我猜它只是你需要第二双眼睛的东西之一。 thumbnail.php中的die语句让我相信这是罪魁祸首,但它不会使它成为函数的第一行,这实在令人困惑。我不知道php preorcessor如何工作,除了它的客户端。

0 个答案:

没有答案