>>  Site Map >>  Forums >>  Blocks

Forum module - topics in forum:



Blocks - Having problems with a block? Code doesn't work, get help here.



created a block

Ok, i got this code that works, and i would like it in a block, so i used your block creator, and it did not show the info... and anyone tell me why please...

Code: :

<?php
if (eregi("block-CCart_Products.php", $PHP_SELF)) {
Header("Location: index.php");
die();
}
$host = "********";
$user = "********";
$password = "********";
mysql_connect($host, $user, $password)
   or die ("could not make it");
$db = mysql_select_db("cash4kil_psstats")
   or die ("could not get in database");
$query = "SELECT * FROM pstatsplr";
$result = mysql_query($query);
$i=0;
while ( $row = mysql_fetch_array($result, MYSQL_BOTH)) {
extract($row); $sum1 = $skill - $prevskill;
   {
   if ($i <= 10)
   echo "<table width='30%' border='1'><tr><td>$name</td><td width='10%' align='center'>$sum1<br></td></tr></table>";
   }
   $i++; }
?>


this is what the block creator game me:

Code: :

<?php
#### Generated by Block Creator by Disipal Site (www.disipal.net) ###
if (eregi("block-Block_Creator.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}
$content  =  "<?php";
$content  .= "if (eregi(\"block-CCart_Products.php\", $PHP_SELF)) {";
$content  .= "Header(\"Location: index.php\");";
$content  .= "die();";
$content  .= "}";
$content  .= "$host = \"********\";";
$content  .= "$user = \"********\";";
$content  .= "$password = \"********\";";
$content  .= "mysql_connect($host, $user, $password)";
$content  .= "   or die (\"could not make it\");";
$content  .= "$db = mysql_select_db(\"cash4kil_psstats\")";
$content  .= "   or die (\"could not get in database\");";
$content  .= "$query = \"SELECT * FROM pstatsplr\";";
$content  .= "$result = mysql_query($query);";
$content  .= "$i=0;";
$content  .= "while ( $row = mysql_fetch_array($result, MYSQL_BOTH)) {";
$content  .= "extract($row); $sum1 = $skill - $prevskill;";
$content  .= "   {";
$content  .= "   if ($i <= 10)";
$content  .= "   echo \"<table width='30%' border='1'><tr><td>$name</td><td width='10%' align='center'>$sum1<br></td></tr></table>\";";
$content  .= "   }";
$content  .= "   $i++; }";
$content  .= "?>";
?>


thank you.






I would say because you used a php block creater for php scripts that you already had made. Did you try using the code as it was first.






i did, and the block just printed what i put in it....

so the script was shown, not the actions it was meant to perform.






The block creator is to convert HTML into a php-nuke block. YOU CAN NOT USE PHP CODE IN IT!






Thank you Jae Smile

okay... so i have solved most of the prob... but now it only displays the 10th row.. and i would like to show the first 10 only.

Can you see why this is please:

Code: :

mysql_connect($host, $user, $password)
   or die ("could not make it");
$db = mysql_select_db("cash4kil_psstats")
   or die ("could not get in database");
$query = "SELECT * FROM pstatsplr";
$result = mysql_query($query);
$i=0;
while ( $row = mysql_fetch_array($result, MYSQL_BOTH)) {
   if ($i == 10)
   extract($row); $sum1 = $skill - $prevskill;
   {
   $content = "<table><tr><td>$name</td><td width='10%' align='center'>$sum1<br></td></tr></table>";
   $i++; }
   }   
?>


thank you again Smile




Attention! You are currently viewing sitemap page!
We strongly suggest to look at original content

Search from web

Valid HTML 4.01 Valid CSS