>>  Site Map >>  Forums >>  Blocks 6x

Forum module - topics in forum:



Blocks 6x - Discussions regarding PHP-Nuke Blocks.



VCard Block Causing Other Blocks Not to Show

Hi all,

I created a block to bring the vcard images to center of my home page(nuke). The code of the block is

Code: :
<?php
if (eregi("block-vcard1.php", $_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

global $nukeurl, $prefix, $startdate, $db;

// hostname or ip of server
$servername='localhost';

// username and password to log onto db server
$dbusername='adminalnukhtha';
$dbpassword='xxxxxx';

// name of database
$dbname='alnukhtha_com2';

//require("$path/config.php");
$dbnew=mysql_connect($servername,$dbusername,$dbpassword) or die("Unable to connect to database");
mysql_select_db($dbname) or die("Unable to select database $dbname");
$imgurl="http://www.alnukhtha.com/cards/images/";

$sql = "SELECT count(cd.card_id) AS score, cd.card_id as cid, cd.card_category AS cname, cd.card_thmfile AS fname, cd.card_caption as Title, cd.card_rating,cd.card_date
FROM vcard_stats AS s
   LEFT JOIN vcard_cards AS cd ON s.card_id=cd.card_id
   LEFT JOIN vcard_category AS ct ON cd.card_category=ct.cat_id
WHERE ct.cat_active='1'
GROUP BY s.card_id
ORDER BY score DESC
LIMIT 0, 4";
$postsresult = mysql_query($sql) or die("Unable to complete query");

$content .= "<table align =center border=1>";
$content .= "<tr><td colspan=3>Cards</td></tr><tr>";


while ($topposters = mysql_fetch_array($postsresult)):

   $content .=  "<td>".$topposters[Title]."<br><a target='_blank' href='http://www.alnukhtha.com/cards/create.php?card_id=".$topposters[cid]."'><img border=0 src='" . $imgurl.$topposters[fname]."'></a></td>";

endwhile;
$content .= "</tr></table>";
?>


the block displays the pics properly, But the problem is it stops displaying the other blocks following it.

Can any one help me out?

Thanks and Regards
Bala






I have redone the code you posted above in the format I would have don it myself if I was making the block. You were using a while function that can sometimes cause continuous loops according to php.net, perhaps that had something to do with it.

Also, if the table for the vcards is in the same database as the nuke tables then you don’t have to use a connection script to connect to the database, just use the $db variable as shown below.

Code: :
 <?PHP

if (eregi("block-vcard1.php", $_SERVER['PHP_SELF']))
   {
    Header("Location: index.php");
    die();
   }
   
global $db;

$imgurl="http://www.alnukhtha.com/cards/images/";

$Q01 = "SELECT count(cd.card_id) AS score, cd.card_id as cid, cd.card_category AS cname, cd.card_thmfile AS fname, cd.card_caption as Title, cd.card_rating,cd.card_date
      FROM vcard_stats AS s
      LEFT JOIN vcard_cards AS cd ON s.card_id=cd.card_id
      LEFT JOIN vcard_category AS ct ON cd.card_category=ct.cat_id
      WHERE ct.cat_active='1'
      GROUP BY s.card_id
      ORDER BY score DESC
      LIMIT 0, 4";
$R01 =  $db -> sql_query($Q01) or die("Bad Q01:".mysql_error());
      
   $content  = "";
   $content  = "<table align =center border=1>";
   $content .= "<tr><td colspan=3>Cards</td></tr><tr>";

while($topposters = mysql_fetch_array($R01))
   {
   $content .=  "<td>".$topposters[Title]."<br><a target='_blank' href='http://www.alnukhtha.com/cards/create.php?card_id=".$topposters[cid]."'><img border=0 src='" . $imgurl.$topposters[fname]."'></a></td>";
   }
 
   $content .= "</tr></table>";
?>


Let me know if this solves the problem




Thanks i try now and let u know

Thanks i try now and let u know




The problem fixed...Thanks a lot...

The problem fixed...Thanks a lot... Razz






No problem Bala1, thanks for letting me know it worked Very Happy




VCard Hack having problem in Nuke

I am doing the site development for my friend...As i mentioned earlier i created my custom VCARD block for nuke and the VCARD Db is separate from Nuke DB.

the block displays the CARDS properly, But the problem is it stops displaying the other blocks following it.


The code of my block
Code: :

<?php
if (eregi("block-vcard1.php", $_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

global $nukeurl, $prefix, $startdate, $db;

// hostname or ip of server
$servername='localhost';

// username and password to log onto db server
$dbusername='adminalnukhtha';
$dbpassword='xxxxxx';

// name of database
$dbname='alnukhtha_com2';

//require("$path/config.php");
$dbnew=mysql_connect($servername,$dbusername,$dbpassword) or die("Unable to connect to database");
mysql_select_db($dbname) or die("Unable to select database $dbname");
$imgurl="http://www.alnukhtha.com/cards/images/";

$sql = "SELECT count(cd.card_id) AS score, cd.card_id as cid, cd.card_category AS cname, cd.card_thmfile AS fname, cd.card_caption as Title, cd.card_rating,cd.card_date
FROM vcard_stats AS s
   LEFT JOIN vcard_cards AS cd ON s.card_id=cd.card_id
   LEFT JOIN vcard_category AS ct ON cd.card_category=ct.cat_id
WHERE ct.cat_active='1'
GROUP BY s.card_id
ORDER BY score DESC
LIMIT 0, 4";
$postsresult = mysql_query($sql) or die("Unable to complete query");

$content .= "<table align =center border=1>";
$content .= "<tr><td colspan=3>Cards</td></tr><tr>";


while ($topposters = mysql_fetch_array($postsresult)):

   $content .=  "<td>".$topposters[Title]."<br><a target='_blank' href='http://www.alnukhtha.com/cards/create.php?card_id=".$topposters[cid]."'><img border=0 src='" . $imgurl.$topposters[fname]."'></a></td>";

endwhile;
$content .= "</tr></table>";
?>


As per Dashe suggestion i got the temporary solution by importing the tables of VCARD to Nuke DB.
But i want to keep the VCARD DB separate from Nuke DB to manage the applications.

can any one know how to create block for external db without affecting the nuke flow?

Thanks
Bala






You know it shouldn’t really affect the flow of nuke as you say, but it just occurred to me that you have
Code: :
$dbname='alnukhtha_com2';


$dbname is a PHP-Nuke variable in the config.php, perhaps you using that variable again is putting nuke out of sink, try not to use any PHP-Nuke variables, rename it and any others to something lile $newdbname

Let me know how you get on 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