Jump to content

Twysted

Members
  • Posts

    25
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

Contact Methods

  • Yahoo
    x_twysted_x

Twysted's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. actually with WAMP you don't have all those issues. To OP right click the wamp icon in taskbar and set to run all services then try again. thuis is a common problem with many new users of wamp
  2. Son Of A ...... Long pause.... i fixed it. it wasn't a foreach i needed it was a section....geesh. all i wanted was poited in the right diraction.
  3. after examining it for some time i have noticed that it is splitting the results between all the tables. I am lost as to how this is happening. some help would be appreciated.
  4. I will try your suggestion i have tried naming them but it still doesn't work. that didn't work very well did grab data but here is a screenshot
  5. http://www.smarty.net/docsv2/en/language.variables.tpl#language.variables.assoc.arrays http://www.smarty.net/docsv2/en/language.variables.tpl#language.variables.array.indexes
  6. I have fixed the php and it is showing there should be a row but it's not showing the data. i have not changed the tpl file anymore so what you see above is how it still is but here is the update i made to the php and also an image showing what i see. php <?php if($Auth->isLogged()) { $aid = $Auth->loggedAid(); $limit = 10; $row = array(); $db->query('SELECT * FROM ptc WHERE active = 1'); if($db->returned_rows >= 1) { $username = $Auth->loggedUsername(); $time = time(); $row = $db->fetch_assoc_all(); $smarty->assign('row', $row); $smarty->assign('username', $username); $smarty->assign('time', $time); } else { //set var not to display ptc ads $smarty->assign("row", "No PTC are available"); } } $smarty->display('ptc_view.tpl'); ?>
  7. Ok so i have made the page to load the data and i have my tpl file loading i just can't figure out for the life of me why it is not displaying correctly. what it is displaying php for the page <?php if($Auth->isLogged()) { $aid = $Auth->loggedAid(); $limit = 10; //grab available PTC links from db output in json $db->select('*', 'ptc', 'active = 1'); if($db->returned_rows >= 1) { $username = $Auth->loggedUsername(); $time = time(); //$row = $db->fetch_assoc_all(); $smarty->assign('row', $db->fetch_assoc()); $smarty->assign('username', $username); $smarty->assign('time', $time); } else { //set var not to display ptc ads $smarty->assign("row", "No PTC are available"); } } $smarty->display('ptc_view.tpl'); ?> tpl file <!-- START content-container --> <section id="content-container" class="clearfix"> <div id="main-wrap" class="clearfix"> <div class="page_content"> <table class="table table-hover"> <tr> <th>Ad Link</th> <th>Earnings | Points</th> <th>Times Completed</th> <th>Total Visits</th> <th>Date Added</th> </tr> {foreach key=pid item=ri from=$row} <tr> <td><a href="Pages/ptcview/{$ri[0]}">{$ri[1]}</a><br/>{$ri[3]}</td> <td>{$ri[5]} | {$ri[6]} pts</td> <td>{$ri[8]}</td> <td>{$ri[7]}</td> <td>{$ri[13]}</td> </tr> {foreachelse} <tr> <td colspan="5">Sorry there are no PTC ads available right now</td> </tr> {/foreach} can someone please show me where i have gone wrong? BTW the db table does exist and there is 1 record in it.
  8. compare.php <?php /** * * Class \webdof\Text\diff\Compare * * Compares two texts, finds the diffrences and patches back to * the original version using a minimal ammount of data. * * Version: 4.0.0 * * @Author: Till Wehowski, http://www.webfan.de * @Author: php Community, http://php.net * @License: Do What The Fuck You Want To Public License * * */ namespace webdof\Text\diff; /** * Example: $text_1 = 'Dies ist ein Test uber Hackfleisch.<br />Dies ist ein Text uber Hackfleisch.'; $text_2 = "Dies ist Text uber Kackfleisch.<br />Dies ist Test uber Kackfleisch."; $newversion = $text_2; $comp = new \webdof\Text\diff\Compare(); $diff = $comp->calcdiffer($text_1, $text_2); echo $text_1.'<br />'; echo $text_2.'<br />'; echo '<pre>'.print_r($diff, true).'</pre>'; $back = ''; foreach( $diff as $step => $d) { if($d[0] === '=' || $d[0] === '-')$back.= $d[1]; } echo 'Patching:<br />'; echo $back.'<br />'; echo '<br />'; echo 'Patching Rüwärts nur mit Änderungen und strlen(equals):<br />'; $diff = $comp->minimize( $diff ); $oldversion = $comp->patch( $text_2, $diff ); echo '<pre>'.print_r($diff, true).'</pre>'; echo $oldversion.'<br />'; echo '<br /><br />Test 2<br />'; $text_1 = 'An einem Sommertag fuhr ich mit dem Fahrrad über die Straße nach Hause.'; $text_2 = 'An einem schönen Sommertag ging ich mit dem Auto über die Straße spazieren.'; echo $text_1.'<br />'; echo $text_2.'<br />'; $comp = new \webdof\Text\diff\Compare(); $diff = $comp->calcdiffer($text_1, $text_2); $diff = $comp->minimize( $diff ); $oldversion = $comp->patch( $text_2, $diff ); echo $oldversion.'<br />'; * */ class Compare { const ADD = 0; // = '+'; const DEL = 1; // = '-'; const EQUAL = 2; // = '='; protected $data = array( 'old' => NULL, 'version' => array( 'new' => NULL, 'diff' => NULL, ), ); function __construct($old = NULL, $new = NULL) { if(is_string($old) && is_string($new))return $this->diff($old, $new); } public function data($data = NULL) { if(is_array($data) && (isset($data['old']) || isset($data['version'])))$this->data = $data; return $this->data; } public function diff($old, $new, $returns = 'version'){ $this->data = array( 'old' => $old, 'version' => array( 'new' => $new, 'diff' => $this->minimize( $this->calcdiffer($old, $new) ), ), ); switch($returns){ case 'version' : $result = $this->data['version']; break; case 'minimized' : case 'diff' : $result = $this->data['version']['diff']; break; case 'all' : case 'max' : $this->data['sha1'] = array( 'old' => sha1($old), 'new' => sha1($new), ); $this->data['strlen'] = array( 'old' => strlen($old), 'new' => strlen($new), ); $result = $this->data; break; case 'data' : default : $result = $this->data; break; } return $result; } /* * Alias for patch * */ public function rollback($newversion, $diff) { return $this->patch($newversion, $diff); } public function patch($newversion, $diff) { $back = array_reverse($diff); $str = ''; $r = strrev($newversion); $offset = 0; foreach($back as $step => $d) { if($d[0] === self::DEL)$d[1] = strrev($d[1]); if($d[0] === self::EQUAL)$str.= substr($r, $offset, $d[2] ); if($d[0] === self::DEL)$str.= $d[1]; if($d[0] === self::ADD || $d[0] === self::EQUAL)$offset += $d[2]; } $oldversion = strrev($str); return $oldversion; } /* * * minimize * compress the diff data, we only need the the added and equal strings position and length * and the value of the deleted strings * */ public function minimize($diff) { foreach($diff as $step => $d) { if($diff[$step][0] !== self::DEL)$diff[$step][1] = NULL; } return $diff; } /* * Returns the differences of $a and $b */ public function calcdiffer($a, $b) { $alen = strlen($a); $blen = strlen($b); $aptr = 0; $bptr = 0; $ops = array(); while($aptr < $alen && $bptr < $blen) { $matchlen = $this->matchlen(substr($a, $aptr), substr($b, $bptr)); if($matchlen) { $str = substr($a, $aptr, $matchlen); $ops[] = array(self::EQUAL, $str, strlen($str) ); $aptr += $matchlen; $bptr += $matchlen; continue; } /* Difference found */ $bestlen=0; $bestpos=array(0,0); for($atmp = $aptr; $atmp < $alen; $atmp++) { for($btmp = $bptr; $btmp < $blen; $btmp++) { $matchlen = $this->matchlen(substr($a, $atmp), substr($b, $btmp)); if($matchlen>$bestlen) { $bestlen=$matchlen; $bestpos=array($atmp,$btmp); } if($matchlen >= $blen-$btmp)break; } } if(!$bestlen)break; $adifflen = $bestpos[0] - $aptr; $bdifflen = $bestpos[1] - $bptr; if($adifflen) { $str = substr($a, $aptr, $adifflen); $ops[] = array(self::DEL, $str, strlen($str) ); $aptr += $adifflen; } if($bdifflen) { $str = substr($b, $bptr, $bdifflen); $ops[] = array(self::ADD, $str, strlen($str) ); $bptr += $bdifflen; } $str = substr($a, $aptr, $bestlen); $ops[] = array(self::EQUAL, $str, strlen($str) ); $aptr += $bestlen; $bptr += $bestlen; } if($aptr < $alen) { /* b has too much stuff */ $str = substr($a, $aptr); $ops[] = array(self::DEL, $str, strlen($str) ); } if($bptr < $blen) { /* a has too little stuff */ $str = substr($b, $bptr); $ops[] = array(self::ADD, $str, strlen($str) ); } return $ops; } protected function matchlen(&$a, &$b) { $c=0; $alen = strlen($a); $blen = strlen($b); $d = min($alen, $blen); while($a[$c] == $b[$c] && $c < $d) $c++; return $c; } } //eof example.php <?php $text_1 = 'Dies ist ein Test uber Hackfleisch.<br />Dies ist ein Text uber Hackfleisch.'; $text_2 = "Dies ist Text uber Kackfleisch.<br />Dies ist Test uber Kackfleisch."; $newversion = $text_2; $comp = new \webdof\Text\diff\Compare(); $diff = $comp->calcdiffer($text_1, $text_2); $html.= $text_1.'<br />'; $html.= '<hr noshade>'; $html.= $text_2.'<br />'; $html.= '<pre>'.print_r($diff, true).'</pre>'; $back = ''; foreach( $diff as $step => $d) { if($d[0] === '=' || $d[0] === '-')$back.= $d[1]; } $html.= 'Patching:<br />'; $html.= $back.'<br />'; $html.= '<br />'; $html.= 'Patching Rüwärts nur mit Änderungen und strlen(equals):<br />'; $diff = $comp->minimize( $diff ); $oldversion = $comp->patch( $text_2, $diff ); $html.= '<pre>'.print_r($diff, true).'</pre>'; $html.= $oldversion.'<br />'; $html.= '<br /><br />Test 2<br />'; $text_1 = 'An einem Sommertag fuhr ich mit dem Fahrrad über die Straße nach Hause.'; $text_2 = 'An einem schönen Sommertag ging ich mit dem Auto über die Straße spazieren.'; $html.= $text_1.'<br />'; $html.= $text_2.'<br />'; $comp = new \webdof\Text\diff\Compare(); $diff = $comp->calcdiffer($text_1, $text_2); $diff = $comp->minimize( $diff ); $oldversion = $comp->patch( $text_2, $diff ); $html.= $oldversion .'<br />'; echo $html; ?> include compare.php in example.php and this solution should fix it for you.
  9. try using a num_rows method in your sql and then using an if statement to check if the query was successful. if the if statement you can add the while loop.
  10. after this $count=mysql_num_rows($result); add this $row=mysql_fetch_array($result);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.