Invenzzia »

Pages: [1]   Go Down
  Print  
Author Topic: OPT: Blank page  (Read 3429 times)
0 Members and 2 Guests are viewing this topic.
PanGuzol
User

Offline Offline

Posts: 7


View Profile
« on: April 19, 2008, 17:37:32 »

I edited example2 to try it with my data and i get blank page.
sources:

news.php
Code:
<?php
define('OPT_DIR''./opt/');
require(OPT_DIR.'opt.class.php'); 
try

$tpl = new optClass
$tpl -> root './templates/';
$tpl -> compile './templates_c/';
$tpl -> gzipCompression 1;
$tpl -> httpHeaders(OPT_HTML); 

require('class.news.php');
$news = new news($db);
$result $news->getnews();
$list = array(); 
while($row $result -> fetch_row()) 

// add the next item 
$list[] = array( 
'newsid' => $row[0], 
'title' => $row[1],
'content' => $row[2],
'date' => $row[3]
);
}

$tpl -> assign('news'$list); 
$tpl -> parse('news.tpl'); 
$db -> close();
}catch(optException $exception){ 
optErrorHandler($exception); 
}
?>

news.tpl
Code:
<html>
<head>
  <title>News</title>
</head>
<body>
<h1>News</h1>

<table>
<tr>
<td>ID</td>
<td>Title</td>
<td>Content</td>
<td>Date</td>
</tr>
{section=news}
<tr>
<td>{$news.newsid}</td>
<td>{$news.title}</td>
<td>{$news.content}</td>
<td>{$news.date}</td>
</tr>
{/section}
</table>


</body>
</html>

%%news.tpl.php
Code:
<html>
<head>
  <title>News</title>
</head>
<body>
<h1>News</h1>

<table>
<tr>
<td>ID</td>
<td>Title</td>
<td>Content</td>
<td>Date</td>
</tr>
<?php  if(is_array($this -> data['news']) && ($__news_cnt sizeof($this -> data['news'])) > 0){    foreach($this -> data['news'] as $__news_id => &$__news_val){  ?>
<tr>
<td><?php echo $__news_val['newsid']; ?></td>
<td><?php echo $__news_val['title']; ?></td>
<td><?php echo $__news_val['content']; ?></td>
<td><?php echo $__news_val['date']; ?></td>
</tr>
<?php  } }  ?>
</table>


</body>
</html>
« Last Edit: April 19, 2008, 19:55:55 by eXtreme » Logged
eXtreme
Invenzzia
Administrator
User
*****
Offline Offline

Posts: 129

Jacek Jędrzejewski


View Profile WWW
« Reply #1 on: April 19, 2008, 20:06:10 »

At first glance everything looks OK, so check your news class.

Debug your code: try to eliminate each part of your script: comment out database connection, SQL operations, try to place exit("test"); before single operations - to find out which part of your script works incorrectly.
Logged

PanGuzol
User

Offline Offline

Posts: 7


View Profile
« Reply #2 on: April 19, 2008, 20:51:03 »

My news class is working i was using it before here u have it if want check

Code:
<?php
class news
{
public function __construct($db)
{
$this->db $db;
}

public function getnews()
{
$query "SELECT * FROM news ORDER BY date DESC";
$result $this->db->query($query);
return $result;
}

public function addnews($title$content)
{
$date date('Y-m-d G:i:s');
$query "INSERT INTO news (title, content, date) VALUES ('$title', '$content', '$date')";
$result $this->db->query($query);
return $result;
}

public function editnews($id$title$content)
{
$query "UPDATE news SET title='$title' content='$content' WHERE id='$id'";
$result $this->db->query($query);
return $result;
}

public function delnews($id)
{
$query "DELETE news WHERE id='$id'";
$result $this->db->query($query);
return $result;
}
}
?>

For connection I'm using standard Mysqli class.

Edit: I deleted 'try' and i don't get any error, still blank page. I have turned on reporting all errors in php.ini.
« Last Edit: April 20, 2008, 00:08:06 by PanGuzol » Logged
eXtreme
Invenzzia
Administrator
User
*****
Offline Offline

Posts: 129

Jacek Jędrzejewski


View Profile WWW
« Reply #3 on: April 20, 2008, 11:45:47 »

I've tested your code and everything works on my PC. Dunno. Make sure you have error reporting on. Put
Code:
error_reporting(E_ALL);
at the beggining of you news file.

As I said before, debug your code with exit("test"); Try to display something with OPT without your news class. Dobule check paths and write rights, DB credentials.
Logged

PanGuzol
User

Offline Offline

Posts: 7


View Profile
« Reply #4 on: April 20, 2008, 12:19:47 »

news.php
Code:
error_reporting(E_ALL);
define('OPT_DIR', './opt/');
require(OPT_DIR.'opt.class.php');
try
{
$tpl = new optClass;
$tpl -> root = './templates/';
$tpl -> compile = './templates_c/';
$tpl -> gzipCompression = 1;
$tpl -> httpHeaders(OPT_HTML);

$tpl -> parse('news.tpl');
}catch(optException $exception){
optErrorHandler($exception);
}

news.tpl
Code:
<html>
<head>
  <title>News</title>
</head>
<body>
<h1>News</h1>

<table>
<tr>
<td>ID</td>
<td>Title</td>
<td>Content</td>
<td>Date</td>
</tr>
</table>


</body>
</html>

Still blank page.

PS: Examples are working.
Logged
eXtreme
Invenzzia
Administrator
User
*****
Offline Offline

Posts: 129

Jacek Jędrzejewski


View Profile WWW
« Reply #5 on: April 20, 2008, 12:44:53 »

hmmm. No idea. Maybe change
Code:
define('OPT_DIR', './opt/');
require(OPT_DIR.'opt.class.php');
to
Code:
define('OPT_DIR', 'opt/');
require(OPT_DIR.'opt.class.php');

Otherwise we have to wait for Zyx ;)
Logged

PanGuzol
User

Offline Offline

Posts: 7


View Profile
« Reply #6 on: April 20, 2008, 13:32:29 »

Still blank :/
Logged
Zyx
Your programmer
Administrator
User
*****
Offline Offline

Posts: 291



View Profile WWW
« Reply #7 on: April 20, 2008, 20:20:37 »

PanGuzol -> this problem has nothing to do with OPT. First of all, check the "display_errors" directive in php.ini file. If it is set to "off", your scripts will not show even fatal errors, but just a blank page.

Assuming, that this is all the code you have, the problem is that you forgot to initialize the $db object and the class.news.php file tries to call some methods from a null variable.
Logged

PozDrX, Zyx
---Invenzzia group---
PanGuzol
User

Offline Offline

Posts: 7


View Profile
« Reply #8 on: April 20, 2008, 21:59:00 »

I have display_errors on.
And i init $db i show here only class news.

Look that:

Code:
<?php
require ('class.news.php');

$news = new news($db);

$result $news -> getnews();
echo 
'<table><tr><td>ID</td><td>Title</td><td>Content</td><td>Date</td></tr>';
while(
$r $result -> fetch_assoc())
{
echo '<tr><td>'.$r['newsID'].'</td><td>'.$r['title'].'</td><td>'.$r['content'].'</td><td>'.$r['date'].'</td></tr>';
}
echo 
'</table>';


?>
That is working.

Code:
<?php

define('OPT_DIR''./opt/');
require('./opt/opt.class.php');
try

$tpl = new optClass
$tpl -> root './templates/';
$tpl -> compile './templates_c/';
$tpl -> gzipCompression 1;
$tpl -> httpHeaders(OPT_HTML); 

require ('class.news.php');
$news = new news($db);
$result $news -> getnews();
$list = array(); 
while($r $result -> fetch_row())
{
$list[] = array( 
'newsid' => $r[0], 
'name' => $r[1],
'description' => $r[2],
'date' => $r[3]
);
}

$tpl -> assign('news'$list); 
$tpl -> parse('news.tpl'); 
$db -> close();
}
catch(optException $exception)
{
optErrorHandler($exception); 
}

?>
That is giving me blank page.

Oh and if You still are thinking that i have display_errors off let You know that this script
Code:
<?php
blebleble
?>
give me error
Quote
Notice: Use of undefined constant blebleble - assumed 'blebleble' in F:\Server\htdocs\libs\news.php on line 2
Logged
Zyx
Your programmer
Administrator
User
*****
Offline Offline

Posts: 291



View Profile WWW
« Reply #9 on: April 22, 2008, 21:08:10 »

PanGuzol -> the problem definietly does not lie in OPT. As you say, the rest of examples work and the problem began when you connected it with your class. I've tested the class and the rest of your code - it works. I cannot tell you, what is wrong, because it seems that you did not provide all the sources. Check out the rest - maybe there is something that ifluences OPT (maybe output buffering or a mysterious die() call?).
Logged

PozDrX, Zyx
---Invenzzia group---
PanGuzol
User

Offline Offline

Posts: 7


View Profile
« Reply #10 on: April 23, 2008, 13:53:38 »

Can it be differences in php or apache configuration??
Check again my 3rd post i don't use there my class and it's too blank.

And now the most freak thing, i chcecked again examples and now examples 1,4,5,6,9,12,14,15,16,18,19 work but 2,3,7,8,10,11,13 are blank and 17 give me this error
Code:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in F:\Server\htdocs\opt\examples\example17.php on line 15

Warning: optClass::include(./templates_c/%%db__example17.php) [function.optClass-include]: failed to open stream: No such file or directory in F:\Server\htdocs\opt\lib\opt.class.php on line 749

Warning: optClass::include() [function.include]: Failed opening './templates_c/%%db__example17.php' for inclusion (include_path='.;C:\php5\pear') in F:\Server\htdocs\opt\lib\opt.class.php on line 749

I don't have any idea why i didn't change any settings.
Logged
Zyx
Your programmer
Administrator
User
*****
Offline Offline

Posts: 291



View Profile WWW
« Reply #11 on: April 23, 2008, 16:33:30 »

Oh, some examples use the database. There should be an SQL file with a simple table and a shared configuration file with the database settings. Just import the file and set the correct settings and those examples should work.

Ad. your question -> a veeeery long time ago, when people used buggy PHP 5.0.x, I experienced similar problem: the library perfectly worked on my home computer, but on one server I had a blank page. When the admin updated the PHP version, the problem disappeared.

BTW. There is also one more thing you can try: disabling gzip compression.
Logged

PozDrX, Zyx
---Invenzzia group---
PanGuzol
User

Offline Offline

Posts: 7


View Profile
« Reply #12 on: April 23, 2008, 16:54:45 »

Finally, i disabled gzip compresion as You said and it works. Thanks ;]
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Subject Started by Replies Views Last post
OPTv2: Main tpl parced but opt:include view not parce amichelin 5 1969 Last post May 03, 2009, 16:03:37
by eXtreme
OPTv2: How to build a main layout amichelin 5 1103 Last post April 28, 2009, 13:27:10
by amichelin
OPTv2: Tworzenie bloków Wojnar 5 587 Last post December 19, 2010, 18:55:52
by Wojnar
OPTv2: nieścisłości w dokumentacji js29a 1 226 Last post February 27, 2011, 13:10:05
by Zyx
OPTv2: Problem po wyłączeniu konsoli chordspl 2 484 Last post July 06, 2011, 13:31:08
by chordspl