Système de pagination sous template
Salut,

Bon ca fait 2 jours que je seche et je n'y arrive pas!

Voila je code un site, avec un système de news

Donc mon système de news fonctions à 100%

Mais la pagination !

Donc je vous mes déjà mes codes:

Code PHP :
<?php
public function News($Template){
        
        
$this->RequeteRecupTitreNews mysql_query('SELECT * FROM '.$this->NewsTables.' ORDER BY Dates DESC');
        while (
$this->ResultRecupTitreNews mysql_fetch_array($this->RequeteRecupTitreNews)) {
            
            
$this->Message stripslashes($this->ResultRecupTitreNews['Message']); // On enl?ve les slash qui se seraient ajout?s automatiquement
            
$this->Message htmlspecialchars($this->Message); // On rend inoffensives les balises HTML que le visiteur a pu rentrer
            
$this->Message nl2br($this->Message); // On cr?e des <br /> pour conserver les retours ? la ligne
            
            
$this->Message preg_replace('#<gras>(.+)</gras>#isU''<strong>$1</strong>'$this->Message); 
            
$this->Message preg_replace('#<italique>(.+)\</italique>#isU''<em>$1</em>'$this->Message); 
            
$this->Message preg_replace('#<barre>(.+)\</barre>#isU''<del>$1</del>'$this->Message); 
            
$this->Message preg_replace('#<clignote>(.+)\</clignote>#isU''<blink>$1</blink>'$this->Message);
            
$this->Message preg_replace('#<lien=&quot;(.+)&quot;>(.+)\</lien\>#isU''<a href="$1" target="_blank">$2</a>'$this->Message);
            
$this->Message preg_replace('#<images>(.+)\</images\>#isU''<img src="$1" alt="$1" />'$this->Message); 
            
$this->Message preg_replace('#<citation nom=(.+)>(.+)\</citation\>#isU'"<table border= \"1\" width=\"100%\"><tr><th align=\"left\">Citation de: $1</th></tr><tr><td align=\"left\">$2</td></tr></table>"$this->Message);
            
$this->Message preg_replace('#<ttpetit>(.+)\</ttpetit\>#isU''<span style="font-size: 7px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<tpetit>(.+)\</tpetit\>#isU''<span style="font-size: 12px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<petit>(.+)\</petit\>#isU''<span style="font-size: 15px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<gros>(.+)\</gros\>#isU''<span style="font-size: 20px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<tgros>(.+)\</tgros\>#isU''<span style="font-size: 30px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<ttgros>(.+)\</ttgros\>#isU''<span style="font-size: 40px">$1</span>'$this->Message);
            
$this->Message preg_replace('#<ttgros>(.+)\</ttgros\>#isU''<span style="font-size: 40px">$1</span>' $this->Message);
            
$this->Message preg_replace('#\<align=(left|center|right)\>(.+)\</align\>#isU''<div style="float:$1">$2</span>'$this->Message);
            
$this->Message preg_replace('#\<color=(red|green|blue|yellow|purple|olive)\>(.+)\</color\>#isU''<span style="color:$1">$2</span>'$this->Message);
            
$this->SmiliesName = array(':magicien:'':colere:'':diable:'':ange:'':ninja:''>_<'':pirate:'':zorro:'':honte:'':soleil:'':\'\\('':waw:'':\\)'':D'';\\)'':p'':lol:'':euh:'':\\('':o'':colere2:''o_O''\\^\\^'':sifflote:');
            
$this->SmiliesUrl  = array('magicien.png''angry.gif''diable.png''ange.png''ninja.png''pinch.png''pirate.png''zorro.png''rouge.png''soleil.png''pleure.png''waw.png''smile.png''heureux.png''clin.png''langue.png''rire.gif''unsure.gif''triste.png''huh.png''mechant.png''blink.gif''hihi.png''siffle.png');
            
$this->SmiliesPath "http://www.siteduzero.com/Templates/images/smilies/";
        
            for (
$this->0$this->count($this->SmiliesName); $this->$this->c$this->i++) {
                
$this->Message preg_replace('`' $this->SmiliesName[$this->i] . '`isU''<img src="' $this->SmiliesPath $this->SmiliesUrl[$this->i] . '" title="'$this->SmiliesName[$this->i] .'" alt="smiley" />'$this->Message);
            }            
            
            
$this->Final['Titre'] = $this->ResultRecupTitreNews['Titre'];
            
$this->Final['Id'] = $this->ResultRecupTitreNews['Id'];
            
$this->Final['Auteur'] = $this->ResultRecupTitreNews['Auteur'];
            
$this->Final['Message'] = $this->Message;
            
$this->Final['Dates'] = $this->ResultRecupTitreNews['Dates'];

            
$Template->setVar('News'$this->Final);
            
$Template->render('News');
            
        }
?>

Code PHP :
<?php

$Template
->importFile('News/Accueil.tpl');

$News = new News;
$News->NewsTitre($Template);
$News->News($Template);

echo 
$Template->render();

?>

et le template:
Code :
<div id="Content">
                <!-- BLOCK::ON::News -->
                <div class="News" id="NewsId{$News.Id}">
                    <div id="Header">
                    {$News.Titre}
                        <div id="ByAndDate">
                            Par {$News.Auteur} / Le {$News.Dates}
                        </div>
                    </div>
                    <div id="Message">
                        {$News.Message}
                    </div>
                </div>
                <!-- BLOCK::OFF::News -->
            </div>

Donc je ne c'est pas quel code utiliser et ou le placer

Donc j'ai essayer de mettre :

Code PHP :
<?php
public function News($Template){
        
        
        
$retour_total mysql_query('SELECT COUNT(*) AS total FROM '.$this->NewsTables.'');
        
$messagesParPage 5;
        
$donnees_total mysql_fetch_assoc($retour_total);
        
$total $donnees_total['total']; 
        
$nombreDePages ceil($total/$messagesParPage);
        if(isset(
$_GET['Page'])) {
            
            
$pageActuelle intval($_GET['Page']);
            
            if(
$pageActuelle $nombreDePages){
            
                
$pageActuelle $nombreDePages;
            
            }
        
        }
                        
        else{
            
            
$pageActuelle 1
        
        }
        
        
$premiereEntree = ($pageActuelle-1) * $messagesParPage; ;
        
        
$this->RequeteRecupTitreNews mysql_query('SELECT * FROM '.$this->NewsTables.' ORDER BY Dates DESC LIMIT '.$premiereEntree.','.$messagesParPage.'');
        while (
$this->ResultRecupTitreNews mysql_fetch_array($this->RequeteRecupTitreNews)) {
            
            
$this->Message stripslashes($this->ResultRecupTitreNews['Message']); // On enl?ve les slash qui se seraient ajout?s automatiquement
            
$this->Message htmlspecialchars($this->Message); // On rend inoffensives les balises HTML que le visiteur a pu rentrer
            
$this->Message nl2br($this->Message); // On cr?e des <br /> pour conserver les retours ? la ligne
            
            
$this->Message preg_replace('#<gras>(.+)</gras>#isU''<strong>$1</strong>'$this->Message); 
            
$this->Message preg_replace('#<italique>(.+)\</italique>#isU''<em>$1</em>'$this->Message); 
            
$this->Message preg_replace('#<barre>(.+)\</barre>#isU''<del>$1</del>'$this->Message); 
            
$this->Message preg_replace('#<clignote>(.+)\</clignote>#isU''<blink>$1</blink>'$this->Message);
            
$this->Message preg_replace('#<lien=&quot;(.+)&quot;>(.+)\</lien\>#isU''<a href="$1" target="_blank">$2</a>'$this->Message);
            
$this->Message preg_replace('#<images>(.+)\</images\>#isU''<img src="$1" alt="$1" />'$this->Message); 
            
$this->Message preg_replace('#<citation nom=(.+)>(.+)\</citation\>#isU'"<table border= \"1\" width=\"100%\"><tr><th align=\"left\">Citation de: $1</th></tr><tr><td align=\"left\">$2</td></tr></table>"$this->Message);
            
$this->Message preg_replace('#<ttpetit>(.+)\</ttpetit\>#isU''<span style="font-size: 7px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<tpetit>(.+)\</tpetit\>#isU''<span style="font-size: 12px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<petit>(.+)\</petit\>#isU''<span style="font-size: 15px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<gros>(.+)\</gros\>#isU''<span style="font-size: 20px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<tgros>(.+)\</tgros\>#isU''<span style="font-size: 30px">$1</span>'$this->Message); 
            
$this->Message preg_replace('#<ttgros>(.+)\</ttgros\>#isU''<span style="font-size: 40px">$1</span>'$this->Message);
            
$this->Message preg_replace('#<ttgros>(.+)\</ttgros\>#isU''<span style="font-size: 40px">$1</span>' $this->Message);
            
$this->Message preg_replace('#\<align=(left|center|right)\>(.+)\</align\>#isU''<div style="float:$1">$2</span>'$this->Message);
            
$this->Message preg_replace('#\<color=(red|green|blue|yellow|purple|olive)\>(.+)\</color\>#isU''<span style="color:$1">$2</span>'$this->Message);
            
$this->SmiliesName = array(':magicien:'':colere:'':diable:'':ange:'':ninja:''>_<'':pirate:'':zorro:'':honte:'':soleil:'':\'\\('':waw:'':\\)'':D'';\\)'':p'':lol:'':euh:'':\\('':o'':colere2:''o_O''\\^\\^'':sifflote:');
            
$this->SmiliesUrl  = array('magicien.png''angry.gif''diable.png''ange.png''ninja.png''pinch.png''pirate.png''zorro.png''rouge.png''soleil.png''pleure.png''waw.png''smile.png''heureux.png''clin.png''langue.png''rire.gif''unsure.gif''triste.png''huh.png''mechant.png''blink.gif''hihi.png''siffle.png');
            
$this->SmiliesPath "http://www.siteduzero.com/Templates/images/smilies/";
        
            for (
$this->0$this->count($this->SmiliesName); $this->$this->c$this->i++) {
                
$this->Message preg_replace('`' $this->SmiliesName[$this->i] . '`isU''<img src="' $this->SmiliesPath $this->SmiliesUrl[$this->i] . '" title="'$this->SmiliesName[$this->i] .'" alt="smiley" />'$this->Message);
            } 
            
            for(
$iPage=1$i<=$nombreDePages$iPage++) {
        
                if(
$iPage==$pageActuelle) {
                
                    
$this->Final['MessagePagination'] = $iPage;
            
                }
                else {
                
                    
$this->Final['MessagePagination'] = $iPage;
            
                }
        
            }
            
            
$this->Final['Titre'] = $this->ResultRecupTitreNews['Titre'];
            
$this->Final['Id'] = $this->ResultRecupTitreNews['Id'];
            
$this->Final['Auteur'] = $this->ResultRecupTitreNews['Auteur'];
            
$this->Final['Message'] = $this->Message;
            
$this->Final['Dates'] = $this->ResultRecupTitreNews['Dates'];

            
$Template->setVar('News'$this->Final);
            
$Template->render('News');
            
        }        
        
    }
?>

Donc j'ai cette erreur :

Citation :Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\xamppnouveaux\htdocs\zack-style.fr\Fonctions\News\News.class.php on line 62

Ma ligne 62 :
Code PHP :
<?php
while ($this->ResultRecupTitreNews mysql_fetch_array($this->RequeteRecupTitreNews))
?>

Ce qui renvoie à :
Code PHP :
<?php
$this
->RequeteRecupTitreNews mysql_query('SELECT * FROM '.$this->NewsTables.' ORDER BY Dates DESC LIMIT '.$premiereEntree.','.$messagesParPage.'');
?>

Voila merci de votre aide

PS: merci de pas critiquer mon code
Quel parseur de template utilises-tu ?
Code PHP :
<?php

/**
 * @author D34Th4Rt
 * @copyright 2011
 * @date 05/08/2011
 */

/*
    This file is part of Hyla
    Copyright (c) 2004-2010 Charles Rincheval.
    All rights reserved

    Hyla is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License,
    or (at your option) any later version.

    Hyla is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Hyla; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/**
 *  Refer to http://www.digitalspirit.org/ or http://www.hyla-project.org/ for update
 *  Standalone version 0.7.0
 */

class Hyla_Tpl {

    private 
$path;
    private 
$file;

    private 
$current_file;
    private 
$tmp_current_file;
    private 
$current_parsed_file;

    private 
$remove_unknow_var;
    private 
$display_error;

    private 
$errors;

    private 
$block_cache;
    private 
$block_parsed;

    private 
$vars;

    private 
$functions;
    private 
$user_functions;

    private 
$var_functions;
    private 
$user_var_functions;

    private 
$l10n_callback;

    const 
VERSION '0.7.0';

    function 
__construct($path '.') {

        
$this->path $path;

        
$this->file null;
        
$this->current_file null;
        
$this->tmp_current_file null;
        
$this->current_parsed_file null;

        
$this->remove_unknow_var true;
        
$this->display_error true;
        
$this->log_error false;

        
$this->errors = array();

        
$this->block_cache = array();
        
$this->block_parsed = array();

        
$this->l10n_callback = array('self''_l10n');

        
$this->vars = array();

        
$this->user_var_functions = array();
        
$this->var_functions = array(
            
'ucfirst'   => 'ucfirst',
            
'ucwords'   => 'ucwords',
            
'lower'     => 'strtolower',
            
'upper'     => 'strtoupper',
            
'trim'      => 'trim',
            
'rtrim'     => 'rtrim',
            
'ltrim'     => 'ltrim',
            
'escape'    => 'htmlspecialchars',
            
'test'      => array('self''_func_test'),
        );

        
$this->user_functions = array();
        
$this->functions = array(
            
'cycle'     => array('self''_func_cycle'),
            
'include'   => array($this'_getFileContent'),
            
'import'    => array($this'_func_import'),
            
'errors'    => array($this'_func_getErrors'),
            
'setvar'    => array($this'setVar'),
            
'l10n'      => &$this->l10n_callback,
        );
    }

    
/**
     *  Get library version
     */
    
public function getVersion() {
        return 
self::VERSION;
    }

    
/**
     *  Import new file
     *  @param  string  $name   File handler
     *  @param  string  $name   Filename
     *  @param  string  $path   Path
     */
    
public function importFile($name$file null$path null) {
        
$ret null;
        
$path $path $path $this->path;
        
$file = ($file) ? $file $name;

        if (
$this->_testFile($path '/' $file)) {
            
$this->file[$name] = $this->_getFileContent($file$path);
            
$ret $name;

            
// Now, current file is this new file
            
$this->current_file $ret;
        }
        return 
$ret;
    }

    
/**
     *  Set current file
     *  @param mixed    $file   New current file
     */
    
public function setCurrentFile($file) {
        
$ret false;
        if (
array_key_exists($file$this->file)) {
            
$this->current_file $file;
        }
        return 
$ret;
    }

    
/**
     *  Set var
     *  @param  string  $name   Variable name
     *  @param  string  $value  Variable value
     */
    
public function setVar($name$value) {
        if (
is_array($value) || is_object($value)) {
            foreach (
$value as $key => $val) {
                if (
is_array($val)) {
                    
$this->setVar($name '.' $key$val);
                } else {
                    
$this->vars[$name '.' $key] = $val;
                }
            }
        } else {
            
$this->vars[$name] = $value;
        }
    }

    
/**
     *  Set multiple vars
     *  @param  array   $vars   Variable array
     */
    
public function setVars(array $vars) {
        foreach (
$vars as $key => $val) {
            
$this->setVar($key$val);
        }
    }

    
/**
     *  Remove unknow var ?
     *  @param  bool    $bool   Yes or no
     */
    
public function removeUnknowVar($bool) {
        return (
$this->remove_unknow_var $bool);
    }

    
/**
     *  Display error ?
     *  @param  bool    $bool   Yes or no
     */
    
public function displayError($bool) {
        return (
$this->display_error $bool);
    }

    
/**
     *  Log error ?
     *  @param  bool    $bool   Yes or no
     */
    
public function logError($bool) {
        return (
$this->log_error $bool);
    }

    
/**
     *  Set l10n callback function
     *  @param  string  $function   Function
     */
    
public function setL10nCallback($function) {
        
$ret false;
        if (
is_callable($function)) {
            
$this->l10n_callback $function;
            
$ret true;
        }
        return 
$ret;
    }

    
/**
     *  Get block content
     *  @param  string  $block_name Block name
     */
    
public function get($block_name null) {
        return 
$this->render($block_namefalse);
    }

    
/**
     *  Render block
     *  @param  string  $block_name Block name
     *  @param  bool    $render     Render (private)
     */
    
public function render($block_name null$render true) {

        
// Load block content...
        
$data $this->_loadBlock($block_name$block_path);

        
// A-t-on un block contenu ?
        
if (strpos($data'<!-- BLOCK::ON::') !== false) {
            
$reg "/<!-- BLOCK::ON::([a-zA-Z0-9\._]*) -->(\s*?\n?\s*.*?\n?\s*)<!-- BLOCK::OFF::\\1 -->/sm";
            
$data preg_replace_callback($reg, array('self''_pregGetBlockContent'), $data);
        }

        
// Variable replace
        
if ($data) {
            
$this->_prepareReplaceArray($search$replace);

            
// Replace var
            
$data str_replace($search$replace$data);

            
// Run function on var
            // First, run set var function (&xxx)
            
$data preg_replace('/{&([a-zA-Z_\-0-9]*)\:((\\\\}|\\\\|[^}])*)}/e'"\$this->setVar('$1', self::_skipQuote(stripslashes('$2')))"$data);

            
$data preg_replace('/{([$|!|_|#])(([a-zA-Z_\-0-9]*)\:?((\\\\}|\\\\|[^}])*))}/e'"\$this->_parseFuncVar('$2', '$1')"$data);
        }

        
// Get content and add it !
        
if ($render) {
            if (!
array_key_exists($block_path$this->block_parsed) || $this->block_parsed[$block_path] == -1) {
                
$this->block_parsed[$block_path] = null;
            }

            
$this->block_parsed[$block_path] .= $data;
            
$data $this->block_parsed[$block_path];
        }

        return 
$data;
    }

    
/**
     *  Register a user variable function tpl
     *  @param  string  $name   Name
     *  @param  string  $func   Function
     */
    
public function registerVarFunction($name$func) {
        
$ret false;
        if (
is_callable($func)) {
            
$this->user_var_functions[$name] = $func;
            
$ret true;
        }
        return 
$ret;
    }

    
/**
     *  Register a user function tpl
     *  @param  string  $name   Name
     *  @param  string  $func   Function
     *  @param  bool    $var    Register also as var function
     */
    
public function registerFunction($name$func$var false) {
        
$ret false;
        if (
is_callable($func)) {
            
$this->user_functions[$name] = $func;
            
$ret true;

            if (
$var) {
                
$ret $this->registerVarFunction($name$func);
            }
        }

        return 
$ret;
    }

    
/**
     *  Get the available function in tpl
     *  @param  bool    $user_func  With user function if true
     */
    
public function getFunctionList($user_func false) {
        return 
array_keys(($user_func) ? array_merge($this->var_functions$this->user_var_functions) : $this->var_functions);
    }

    
/**
     *  Test if file exists
     *  @param  string  $file   File
     *  @param  bool    $error  Print error if file not found if true
     */
    
private function _testFile($file$error true) {
        if (!(
$status file_exists($file))) {
            if (
$error) {
                
$this->_error('Le fichier "%s" n\'existe pas !'$file);
            }
        }
        return 
$status;
    }

    
/**
     *  Preg wrapper for _getFileContent
     */
    
private function _getFileContentWrapper($var) {
        return 
$this->_getFileContent($var[1]);
    }

    
/**
     *  Get file content
     *  @param string $file  File
     */
    
private function _getFileContent($file$path null) {

        
$content null;
        
$file self::_skipQuote($file);

        
/**
         *  Scan :
         *   1. Scan first in current path
         *   2. Scan in Tpl root
         */
        
$try = array(
            
dirname($this->current_parsed_file),
            ((
$path) ? $path $this->path),
        );

        
$i 1;
        foreach (
$try as $f) {

            if (!
$f) {
                continue;
            }

            
$pfile $f '/' $file;

            
// File exists ? Print error only for last test !
            
if ($this->_testFile($pfile, ($i == count($try)))) {
                
$old $this->current_parsed_file;
                
$this->current_parsed_file $pfile;
                
$content file_get_contents($pfile);
                
$content preg_replace_callback('/\{\!include\:([^}]+)(\[a-Z|]?)\}/', array($this'_getFileContentWrapper'), $content);
                
$this->current_parsed_file $old;
                break;
            }
    
            
$i++;
        }

        return 
$content;
    }

    
/**
     *  Resolve path block
     *  Block can be in other file, in this case, use the selector ":"
     *  Example :
     *      - Access to toto block in current file :
     *          " toto "
     *      - Access to bar block in foo.tpl :
     *          " foo.tpl:bar "
     *  @param  string  $path           Path to resolve
     *  @param  string  &$file          Reference to file variable
     *  @param  string  &$block_name    Reference to block name
     *  @param  string  &$block_path    Reference to block path
     */
    
private function _resolveBlock($path, &$file, &$block_name, &$block_path null) {
        if ((
$pos strpos($path':')) === false) {
            
$file $this->current_file;
        } else {
            
// File
            
$file substr($path0$pos);
            
$block_name substr($path$pos 1);
        }

        
$block_path $file ':' $block_name;
    }

    
/**
     *  Load block content
     */
    
private function _loadBlock($block_name, &$block_path null) {

        
// Test file...
        
$this->_resolveBlock($block_name$file$block_name$block_path);

        
$this->tmp_current_file $file;

        if (!
array_key_exists($block_path$this->block_cache)) {
            if (
$block_name) {
                
$reg "/[ \t]*<!-- BLOCK::ON::" preg_quote($block_name) . " -->\s*?\n?(\s*.*?\n?)\s*<!-- BLOCK::OFF::"
                                            
preg_quote($block_name) . " -->\s*?\n?/sm";
                if (!
preg_match($reg$this->file[$file], $match)) {
                    
$this->_error('Le block "%s" : n\'existe pas !'$block_name);
                    return 
null;
                }

                
$data = &$match[1];
            } else {
                
$data = &$this->file[$file];
                
$block_name '.';
            }
        } else {
            
$data $this->block_cache[$block_path];
        }

        
$this->block_cache[$block_path] = $data;

        return 
$data;
    }

    
/**
     *  Parse func var
     *  @param  string  $str    Variable with func
     *  @param  int     $pos    Offset while start func
     */
    
private function _parseFuncVar($val$type) {

        static 
$cache = array();
        
$out null;

        switch (
$type) {
            
// Variable
            
case '$':

                
// Get default value
                
if (!preg_match("/^([a-zA-Z0-9\-\.\_]+)[\s]*(_)?(\([\S\s]*\))*([\s]*\|[\s]*(.*?))*$/iUs"$val$m)) {
                    return 
null;
                }

                
$name = isset($m[1]) ? $m[1] : null;
                
$l10n = isset($m[2]) ? ($m[2] == '_') : null;
                
$default = isset($m[3]) ? $m[3] : null;
                
$funcs = isset($m[4]) ? $m[4] : null;

                
// Format default
                
if ($default) {
                    
$default trim(stripslashes($default));
                    if (
$default[0] == '(' && $default[strlen($default) - 1] == ')') {
                        
$default substr($default1strlen($default) - 2);
                    }

                    if (
$l10n) {
                        
$default call_user_func($this->l10n_callback$default);
                    }
                }

                
// Variable exists ?
                
if (array_key_exists($name$this->vars)) {
                    
$value $this->vars[$name];
                } else {
                    if (
$default) {
                        
$value $default;
                    } else {
                        return (
$this->remove_unknow_var) ? null '{$' $name '}';
                    }
                }

            
// Function
            
case '!':
                if (
$type == '!') {
                    
$funcs $val;
                    
$value null;
                }

                if (
$funcs) {
                    
$crc crc32($funcs);
                    if (!
array_key_exists($crc$cache)) {
                        
$funcs self::_extract($funcs);
                        
$cache[$crc] = $funcs;
                    } else {
                        
$funcs $cache[$crc];
                    }
                }

                
$out $value;

                if (
$funcs) {
                    
$i 0;
                    foreach (
$funcs as $func => $args) {

                        
// Replace args
                        
if (count($args)) {
                            foreach (
$args as &$arg) {
                                if (
$arg == '$0') {
                                    
$arg $value;
                                } else if (
$arg == '$1') {
                                    
$arg $out;
                                }
                            }
                        }

                        if (
$type == '$') {
                            
array_unshift($args$out);
                        } else if (!
count($args) && $out) {
                            
$args[] = $out;
                        }

                        
$out $this->_runFunc(substr($func1), $args, ($type == '$' || $i));
                        
$i++;
                    }
                }

                break;
            
// L10n
            
case '_':
                
$out call_user_func($this->l10n_callback$val);
                break;
            
// Comment, setVar
            
case '#':
            case 
'&':
        }

        return 
$out;
    }

    
/**
     *  Extract functions and params
     *  @param  string  $in     Data in
     */
    
private static function _extract($in) {
        
$out null;
        
$in str_replace('\"''"'$in);

        
// Split funcs and args
        
if (preg_match_all('/((["\']).*?[^\\\]\\2)|((\|)*[\s]*[\w$]+)/s'$in$m)) {
            
$out = array();
            
$i $f 0;

            
$func $f . ($m[0][0][0] == '|' substr($m[0][0], 1) : $m[0][0]);

            if (
count($m[0]) > 1) {
                foreach (
$m[0] as $item) {

                    
$item stripslashes(trim($item));

                    if (
$item[0] == '"' || $item[0] == "'") {
                        
$out[$func][] = self::_skipQuote($item);
                    } else if (
$item[0] == '|') {
                        
$func trim(substr($item1));
                        
$func $f $func;
                        
$out[$func] = array();
                        
$f++;

                    
// $0 is the first variable
                    
} else if ($item == '$0' || $item == '$1') {
                        
$out[$func][] = $item;
                    } else {
                        if (
$i) {
                            
$out[$func][] = self::_skipQuote($item);
                        }
                    }

                    
$i++;
                }
            } else {
                
$out[$func] = array();
            }
        }

        return 
$out;
    }

    
/**
     *  Extract parameter from string
     */
    
private function _extractParam($str$original null$alternate null) {

        
$param null;

        if (
$str[0] == '\\') {
            
$str substr($str1);
        }

        
// Explode on ,
        
if (preg_match_all("/(['\"])([^\\1]|(\\1(?!,|$))?)*\\1|[^,]+/"$str$param)) {
            
$param $param[0];
            foreach (
$param as &$f) {
                switch (
$f) {
                    
// $0 is the first variable
                    
case '$0':  $f $alternate; break;
                    
// $1 is the return var from last function
                    
case '$1':  $f $original;  break;
                    default:
                        
$f self::_skipQuote($f);
                        break;
                }
            }
        }

        return 
$param;
    }

    private static function 
_skipQuote($str) {
        
// Delete quote
        
$str trim($str);
        if (
$str[0] == "'" && $str[strlen($str) - 1] == "'" ||
            
$str[0] == '"' && $str[strlen($str) - 1] == '"') {
            
$str substr($str1strlen($str) - 2);
        }
        return 
stripslashes($str);
    }

    
/**
     *  Run internal function
     *  @param  string  $name   Function name
     *  @param  array   $param  Parameter
     */
    
private function _runFunc($name$param null$type true) {
        
$var null;
        
$functions = ($type) ? array_merge($this->var_functions$this->user_var_functions) : array_merge($this->functions$this->user_functions);

        if (
array_key_exists($name$functions) && is_callable($functions[$name])) {
            if (
$param) {
                
$param = !is_array($param) ? array($param) : $param;
                
$var call_user_func_array($functions[$name], $param);
            } else {
                
$var call_user_func($functions[$name]);
            }
        } else {
            
$this->_error('Fonction "%s" invalide !'$name);
        }

        return 
$var;
    }

    
/**
     *  Callback function for get content block
     *  @param  array   $match  Preg search content
     */
    
private function _pregGetBlockContent($match) {

        
$out null;
        
$else false;
        
$block_name $match[1];

        
$block_path $this->tmp_current_file ':' $block_name;

        
// Block exits ?
        
if (array_key_exists($block_path$this->block_parsed)) {

            if (
$this->block_parsed[$block_path] == -1) {
                
$else true;
            } else {
                
$out $this->block_parsed[$block_path];
            }

        } else {
            
$else true;
        }

        
// Get else block content
        
if ($else && ($pos strpos($match[2], '<!-- ELSE::'.$block_name.' -->')) !== false) {
            
$out substr($match[2], $pos strlen('<!-- ELSE::'.$block_name.' -->'));
        }

        
$this->block_parsed[$block_path] = -1;
        return 
$out;
    }

    
/**
     *  Prepare var array
     *  @param  array   $search     Search array
     *  @param  array   $replace    Replace array
     */
    
private function _prepareReplaceArray(&$search, &$replace) {

        
$i 0;
        
$search = array();
        
$replace = array();

        foreach (
$this->vars as $key => $val) {
            
$search[] = '{$'.$key.'}';
            
$replace[] = $val;
            
$i++;
        }

        return 
$i;
    }

    
/**
     *  L10n default function
     *  Call setL10nCallback method to define your l10n function...
     *  @param  string  $str    String
     */
    
private static function _l10n($str) {
        return 
$str;
    }

    
/**
     *  Include tpl file not in tpl root path
     *  @param  string  $file   File to include
     */
    
private function _func_import($file) {
        
$pos strrpos($file'/');
        
$path './';
        if (
$pos !== false) {
            
$path substr($file0$pos 1);
            
$file substr($file$pos 1);
        }
        return 
$this->_getFileContent($file$path);
    }

    
/**
     *  Test function
     */
    
private static function _func_test($var$test$out$else null) {
        return (
$var == $test $out $else);
    }

    
/**
     *  Cycle function
     */
    
private static function _func_cycle($even$odd$cycle 2) {
        static 
$a = array();
        
$key $even ' - ' $odd;
        if (!
array_key_exists($key$a)) {
            
$a[$key] = 0;
        }
        return (++
$a[$key] % $cycle) ? $even $odd;
    }

    
/**
     *  Get errors
     */
    
private function _func_getErrors($html true) {
        
$str null;
        foreach (
$this->errors as $error) {
            
$str .= $error;
            if (
$html) {
                
$str .= '<br />';
            }
        }
        return 
$str;
    }

    
/**
     *  Print error
     */
    
private function _error() {

        if (
$this->log_error) {
            
$param func_get_args();
            
$this->errors[] = call_user_func_array('sprintf'$param);
        }

        if (
$this->display_error) {
            
$param func_get_args();
            echo 
'<strong>' __CLASS__ ' erreur : </strong>' call_user_func_array('sprintf'$param) . "<br />\n";
        }
    }
}

$Template = new Hyla_Tpl('Templates');

?>

Hyla template
Édition :
J'ai regarder et je me suis avancer:

J'ai fait un mysql error

Code PHP :
<?php
$this
->RequeteRecupTitreNews mysql_query('SELECT * FROM '.$this->NewsTables.' ORDER BY Dates DESC LIMIT '.$premiereEntree.','.$messagesParPage.'');
        while (
$this->ResultRecupTitreNews mysql_fetch_array($this->RequeteRecupTitreNews)or die(mysql_error())) {
?>

Ca me renvoie

Citation :Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\xamppnouveaux\htdocs\zack-style.fr\Fonctions\News\News.class.php on line 62
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-5, 5' at line 1

Je m'apercoie que le problème venais de:

Code PHP :
<?php
$premiereEntree 
= ($pageActuelle-1) * $messagesParPage;
?>
Salut,

Alors moi j'aurais pas tourner le script comme ça mais bon je vais essayer de voir pour le modifier.
Pour commencer, tu devrais utilisé mysqli_* ou PDO car mysql_* reste un peut juste à un moment donné.

Pour en revenir à ce bout de code:
[code=php]<?php
$this->RequeteRecupTitreNews = mysql_query('SELECT * FROM '.$this->NewsTables.' ORDER BY Dates DESC LIMIT '.$premiereEntree.','.$messagesParPage.'');
while ($this->ResultRecupTitreNews = mysql_fetch_array($this->RequeteRecupTitreNews)or die(mysql_error())) {
?>[/code]

Moi je le ferais comme ça (Enfin niveau propreté je parle):
[code=php]<?php
$query = sprintf("SELECT * FROM " . $this->NewsTables . " ORDER BY Dates DESC LIMIT %s,%s", $premiereEntree, $messagesParPage);
$this->RequeteRecupTitreNews = mysql_query($query);
while ($this->ResultRecupTitreNews = mysql_fetch_assoc($this->RequeteRecupTitreNews)) {}
?>[/code]

Alors j'ai utilisé la fonction sprintf pour séparer les variables de la requête et sa permet aussi de définir le type de variable dont tu te sert.
A la place de "mysql_fetch_array", j'ai utilisé "mysql_fetch_assoc" car c'est plus rapide.
Ensuite pour des raisons de sécurité, je pense qu'il serait mieux de préciser la ou les colonnes que tu veux récupérer au niveau de la requête parce que de tout récupérer et bien c'est pas top, enfin surtout de cette façon là !
En modifiant comme je l'ai fait, le script ne sera pas plus fonctionnel mais il sera déjà plus présentable.
Après ça reste limité au moment ou tu ne te tourne pas vers des fonctions orienté objet.

Pour ce qui est du calcul qui définit la variable "premiereEntree" et bien je trouve bizarre que ça te retourne une valeur négative tel que la tienne.

Donne nous plus d'informations sur tes scripts et à se moment je pense qu'on pourra t'aider ...
Parfois, il suffit de lire.

Citation :Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\xamppnouveaux\htdocs\zack-style.fr\Fonctions\News\News.class.php on line 62

Il t'indique que ta variable $this->RequeteRecupTitreNews n'est pas une ressource mysql mais un boolean.

[code=php]$this->RequeteRecupTitreNews = mysql_query('SELECT * FROM '.$this->NewsTables.' ORDER BY Dates DESC LIMIT '.$premiereEntree.','.$messagesParPage.'');[/code]

mysql_query renvoie soit une ressource soit un boolean. Il suffit de lire la documentation pour voir qu'elle renvoie un boolean sous 2 conditions :
- En cas d'erreur (elle renvoie false)
- Dans le cadre d'une requête INSERT, REPLACE, UPDATE, etc ... (elle renvoie true pour indiquer que tout s'est bien passer)

Il n'y a donc pas 36 solutions : ta requête MySQL est fausse et provoque une erreur. D'après ton message d'erreur, le problème viendrait d'un "-5" en offset dans la clause LIMIT.

[code=php]$premiereEntree = ($pageActuelle-1) * $messagesParPage;[/code]

Laisse moi deviner. $messagesParPage vaut 5. $pageActuelle vaut 0. Et donc tu fais -1 * 5, c'est ça ?
@Allan
sprintf(), dans un script critique est très pratique afin d'assurer la sécurité et la fiabilité du code.

Cependant dans un script amené à être exécuté souvent sur un site (notamment ici apparemment pour la page de news) tu va y perdre beaucoup en performance.

Il vaut donc parfois mieux se rabattre sur une bonne vielle string toute simple : $toto = "lalalal".$var1." lololol ".$var2;

Ta remarque concernant mysql_* est très juste, cependant l'utilisation de PDO n'est réellement utile que si tu as affaire à la gestion simultanée dans le même site de plusieurs SGBD différents. Cela te permet de n’avoir à utiliser qu'une interface unique pour les données dont la syntaxe reste la même.

La classe mysqli reste grande gagnante en terme de performance si tu n'as affaire qu'à un site utilisant MySQL.
Ah ba tu me débloque quand meme et merci du tuto , je connaissais pas cette maniere Erf

Bon maintenant il y a une partit qui affiche des titres dans un menu (c'est une fonction à part)
Mais pour les news principaux:

Citation :Notice: Undefined variable: query in E:\xamppnouveaux\htdocs\zack-style.fr\Fonctions\News\News.class.php on line 64

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in E:\xamppnouveaux\htdocs\zack-style.fr\Fonctions\News\News.class.php on line 65

-5 5
Tu as lu mon post au moins deathart ? Je t'ai dit d'où venait l'erreur ...
Toujours le même souci : tu donne un argument du mauvais type "Warning: mysql_fetch_assoc() expects parameter 1 to be resource"
Il faut que tu lui donne le résultat de ton query ....
@magus j'avais pas vue désoler Hihi
Édition :
@magus je c'est trés bien que ca vien d'ici :
Code PHP :
$premiereEntree = ($pageActuelle-1) * $messagesParPage
Mais si on regarde le code $pageActuelle revien à 1 donc 1-1 = 0 et pas -0 à la normal
Ah les calcul en php --"
Édition :
Sinan j'ai fait un bou de code:
Pour voir ce que premiere entré et message par page affiche avec ca:

Code PHP :
$Template->setVar('TEST_FIRST_ENTRY'$this->premiereEntree );
        
$Template->setVar('TEST_MESSAGE'$this->messagesParPage); 

Et il me renvoie rien Erf

Retourner en haut Accueil