Hello,
I have following problem:
I try to retrieve images from mysql and show it.
I retrieve them in loop using getData.php.
getData.php uses session variable ($_SESSION['num']) to get image.
However $_SESSION['num'] seems to be always 0.
why?
//showAll.php
<?php
session_start() ;
$num=0;
session_registe r('num');
?>
<html>
<head><title>Sh ow data from SQL Database</title></head>
<body>
<?php
MYSQL_CONNECT(" localhost","roo t","pw");
mysql_select_db ("database") ;
$sql = "SELECT count(id) FROM store;";
$result = MYSQL_QUERY($sq l);
$count = MYSQL_RESULT($r esult,0,"count( id)");
//-------------------------------------------------------------------
//here is loop where $_SESSION['num'] is set and getData.php called
while($count >1) {
$_SESSION['num']=$count--;
echo $_SESSION['num'];
?>
<IMG SRC="getData.ph p">
<?php
}
//-------------------------------------------------------------------
?>
</body>
</html>
//-------------------------------------------------------------------
//getData.php
<?php
session_start() ;
if(isset($_SESS ION['num'])) {
@MYSQL_CONNECT( "localhost","ro ot","pw");
@mysql_select_d b("database") ;
$num=$_SESSION['num'];
$query = "select FileData,filety pe from store where id=$num";
$result = @MYSQL_QUERY($q uery);
$data = @MYSQL_RESULT($ result,0,"FileD ata");
$type = @MYSQL_RESULT($ result,0,"filet ype");
Header( "Content-type: $type");
echo $data;
}
?>
I have following problem:
I try to retrieve images from mysql and show it.
I retrieve them in loop using getData.php.
getData.php uses session variable ($_SESSION['num']) to get image.
However $_SESSION['num'] seems to be always 0.
why?
//showAll.php
<?php
session_start() ;
$num=0;
session_registe r('num');
?>
<html>
<head><title>Sh ow data from SQL Database</title></head>
<body>
<?php
MYSQL_CONNECT(" localhost","roo t","pw");
mysql_select_db ("database") ;
$sql = "SELECT count(id) FROM store;";
$result = MYSQL_QUERY($sq l);
$count = MYSQL_RESULT($r esult,0,"count( id)");
//-------------------------------------------------------------------
//here is loop where $_SESSION['num'] is set and getData.php called
while($count >1) {
$_SESSION['num']=$count--;
echo $_SESSION['num'];
?>
<IMG SRC="getData.ph p">
<?php
}
//-------------------------------------------------------------------
?>
</body>
</html>
//-------------------------------------------------------------------
//getData.php
<?php
session_start() ;
if(isset($_SESS ION['num'])) {
@MYSQL_CONNECT( "localhost","ro ot","pw");
@mysql_select_d b("database") ;
$num=$_SESSION['num'];
$query = "select FileData,filety pe from store where id=$num";
$result = @MYSQL_QUERY($q uery);
$data = @MYSQL_RESULT($ result,0,"FileD ata");
$type = @MYSQL_RESULT($ result,0,"filet ype");
Header( "Content-type: $type");
echo $data;
}
?>
Comment