Joomla Module Trouble

Error creating Joomla Module

Page 1 of 1

3 Replies - 1018 Views - Last Post: 15 February 2009 - 04:00 PM Rate Topic: -----

#1 im@geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 94
  • Joined: 18-February 05

Joomla Module Trouble

Post icon  Posted 13 February 2009 - 12:38 PM

Hi Everybody,

I am writing a Joomla module to make a bride between two of my sites: SpinePodium.com and OneSpine.org. When I activate the module I get the following message in firefox when I load SpinePodium.com:

Posted Image

Here is the code for the module. Please let me know if you see any obvious errors:

mod_onespine_patient.php
<style media="screen" type="text/css">
	.me 		{ margin: 0 auto; color: #06569d; width: 160px; height: auto; border: #00F thin solid; }
	.pic 		{ margin: 0 auto; }
	.top_bg		{ background:url(http://www.onespine.org/images/header_img.png) bottom no-repeat; } 
	.top_bg1 	{ background:url(http://www.onespine.org/images/header_img.png) bottom no-repeat; }
	.top_bg1 	{ background:url(http://www.onespine.org/images/header_img.png) bottom no-repeat; }
	.donor		{ background:url(http://www.onespine.org/images/Lenders_img.png) center no-repeat; }
	.style7 	{ color: #3B3B3B; }
	.style8 	{ color: #333333; }
	.top_bg		{ background:url(http://www.onespine.org/images/header_img.png) bottom no-repeat; }
</style>

<?php	
include( "constants.php" );
include( "database.php" );
$db 		= new Database1();
$db->connect_db();
// ============================= USER DEFINED FUNCTIONS ===============================================//
function get_country($id)
{
	$sql_country 	= "select * from tbl_country where country_id = $id";
	$result_country = mysql_query($sql_country);
	$rs_country 	= @mysql_fetch_object($result_country); 
	return $rs_country->country_name;
}
function get_reco( $id , $user_type )
{
	if($user_type == 4)
	{
		$sql	   = "Select * from tbl_organization where org_id = $id";
		$result	= mysql_query( $sql );
		$rs = @mysql_fetch_object( $result );
		return "Organization ".$rs->org_name;
	}
	if($user_type == 1)
	{
		$sql	   = "Select * from tbl_surgeon where surgeon_id = $id";
		$result	= mysql_query( $sql );
		$rs = @mysql_fetch_object( $result );
		return "Dr. ".$rs->sfirst_name." ".$rs->slast_name;
	}
}
//=======================================================================================================//

// how many rows to show per page
$rowsPerPage = 4;
// by default we show first page
$pageNum 	= 1;
// if $_GET['page'] defined, use it as page number
if($_GET['page']!="")
{
	$pageNum = $_GET['page'];
}
// counting the offset
$offset		= ($pageNum - 1) * $rowsPerPage;
$query		= " SELECT * FROM tbl_patient as p1, tbl_loan as l1 WHERE p1.patient_id = l1.patient_id and "."
			  "." (pfirst_name like '".$q."%' or plast_name like '".$q."%') and patient_status = 1 order by l1.amount_left desc";
$result1	= mysql_query($query);
$total_rows	= @mysql_num_rows($result1);

$q		  = $_GET[ 'q' ]; 
$sql		= " SELECT * FROM tbl_patient as p1, tbl_loan as l1 WHERE p1.patient_id = l1.patient_id and "."
			  "." (pfirst_name like '".$q."%' or plast_name like '".$q."%') and patient_status = 1 order by l1.amount_left desc limit  $offset, $rowsPerPage";
$result	 = mysql_query( $sql );
$numrows	= @mysql_num_rows($result);
?>

<div class="me">
	<a href="http://www.onespine.org/detail_patient.php?patient_id=<?php echo $rs->patient_id; ?>" class="bodymenu" style="background-image:url(http://www.onespine.org/images/container.jpg) "><img src="http://www.onespine.org/admin/images/<?php echo $rs->pimage;?>" width="80" height="80" border="0"></a><br />
	
	<p><a href="http://www.onespine.org/detail_patient.php?patient_id=<?php echo $rs->patient_id; ?>"><?php echo $rs->pfirst_name." ".$rs->plast_name; ?></a></p>
	<p><?php echo get_country($rs->pcountry); ?></p>
	<p><?php echo $rs->diagnosis; ?></p>
	<p><?php $reco = get_reco( $rs->reco_surgeon_id , $rs->user_type );?></p>
	<p><a href="http://www.onespine.org/detail_surgeon.php?surgeon_id=<?php echo $rs->reco_surgeon_id; ?>">
	<?php echo $reco;?></a></p>
	  <p>
		<table>
			<td width="174">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:2px solid #0099FF; border-left:0px;">
				  <tr>
						<td style="padding:2px 2px 2px 0px; ">
						  <?php $rs->raised_amount." of ".$rs->loan_amount." Raised "; ?>
						  <?php $percentage = ( ( $rs->raised_amount / $rs->loan_amount )*100 ); ?>
						  <table width="<?php echo $percentage;?>%"  border="0" cellspacing="0" cellpadding="0" bgcolor="#b36b93">
							<tr>
							  <td height="10px"></td>
							</tr>
						</table>
					</td>
				  </tr>
			   </table>
			</td>  
		</table>
		<?php $per = round($percentage,2); ?><br />
		<?php echo $per;?>%
	</p>
	<p>
		$ <?php echo $rs->raised_amount; ?> Donated<br />
		$ <?php echo $rs->amount_left; ?> Still Needed
	</p>
	<p>
		<a href="http://www.onespine.org/patient.php" class="somelink"><strong>View All Patients >>></a>
	<p>
</div>



constants.php
<?php
/****************************************************************************************************
*	Filename: Constants.php
*	Purpose: All the site constants are defined in this file so that variable repeating is avoid. Reference to change from previous
*	constants this file will only contain the database access information
*	Author: Abhijeet Surana
*	Creation Date: 15/12/2007
****************************************************************************************************/

//$application = "local";
$application = "web";
if ($application == "local")
//if ($application == "local")
{
	define("HST", "localhost");
	define("USR", "root");
	define("PWD", "");
	define("DBN", "db_onespine");
	define("DBTYPE", "mysql");
}
else
{
	/*
	this means that the application is on the web hence enter correct parameters for
	the following entries.*/
	//  for manik engineers server
	define("HST", "external-db.88888888.gridserver.com");
	define("USR", "8888888");
	define("PWD", "8888888");
	define("DBN", "db41065_one_spine");
	define("DBTYPE", "mysql");
}

?>



database.php
[code]
<?php
ob_start();
/*******************************************************************************************************
* Filename: database.php
* Purpose: All the generic database related functions and global object functions are located in this
* file. The main pages call the global database functions and depending on the parameters passed,
* queries are generated dynamically and results are returned to the processing script.
* Author: Abhijeet Surana
* Creation Date: 15/03/2007
*******************************************************************************************************/

include_once("constants.php");

class Database1 {

function connect_db()
{
mysql_connect(HST, USR, PWD) OR die("Failed Connecting To Mysql");
mysql_select_db(DBN) OR die("Failed Connecting To Database");
}

/*****************************************************************************************************************
* Table of Contents: Global Database functions 5/4/2006
* Author(s) : Abhijeet Surana
* 1. globalselect($tblname, $wherefields, $wherevalues, $orderbyfield, $ad)
*
*****************************************************************************************************************/

function cgs($tbl, $sf, $wf, $wv, $ob, $ot, $prn)
{

$sql = "SELECT ";
if(is_array($sf))
{
$fields = implode(",", $sf);
}
else
{
if($sf)
$fields = $sf;
else
$fields = "*";
}
if(is_array($wf))
{
if(sizeof($wf) > 0)
{
for($j=0; $j<sizeof($wf); $j++)
{
if(strstr($wv[$j],".") && !strstr($wv[$j],"@"))
$condition.= " $wf[$j] = $wv[$j] ";
else
$condition.= " $wf[$j] = '$wv[$j]' ";

if($j<sizeof($wf)-1)
$condition .= " and ";
}
}
}
else
{
if($wf)
$condition = " $wf = '$wv' ";
else
$condition ="1";
}


$query = $sql.''.$fields." FROM ".$tbl." WHERE ".$condition;
if($ob)
{
$query.=" ORDER BY ".$ob;
}

if($ot)
{
$query.=" ".$ot;
}
if($prn)
{
echo $query;
}

$result = @mysql_query($query) or die(mysql_error());
$num = mysql_num_rows($result);
if($num<1)
{
$retval = $result;
}
else
{
$retval = $result;
}

return $retval;
}

/*****************************************************************************************************************
* Table of Contents: Global Database functions 5/4/2006
* Author(s) : Abhijeet Surana
* 1. globalinsert($tblname, $fields,$values);
*
*****************************************************************************************************************/
function cgi($tbl, $fl, $vl, $prn)
{

$tblname = $tbl;
$fields = $fl;
$values = $vl;

$sql.= "INSERT INTO ".$tblname." ";

$fieldnames.="(";
if(is_array($fields))
{
for($i=0; $i<sizeof($fields); $i++)
{
$fieldnames.= $fields[$i];
if($i<sizeof($fields)-1)
$fieldnames.= ", ";
}
$fieldnames.= ") ";

$value.= " VALUES (";
if(sizeof($values) > 0)
{
for($i=0; $i<sizeof($values); $i++)
{
$value.= "'".$values[$i]."'";
if($i<sizeof($values)-1)
$value.= ", ";
}
}
$value.= ")";
}
else
{
$fieldnames .= $fields.')';
$value = " VALUES "."('".$values."')";
}
$query = $sql.$fieldnames.$value;
if($prn)
{
echo $query;
}

$result = @mysql_query($query) or die(mysql_error());
return mysql_insert_id();
}


/*****************************************************************************************************************
* Table of Contents: Global Database functions 5/4/2006
* Author(s) : Abhijeet Surana
* 1. globaldropdown($tblname, $valfield, $showfield, $orderbyfield, $condition, $selvalue)
*
*****************************************************************************************************************/

function cdd($tbl, $valfield, $showfield, $ob, $cdn, $selvalue, $prn)
{


$query.=" SELECT ".$showfield.", ".$valfield." FROM ".$tbl;
$query.=" WHERE $cdn ORDER BY ".$ob;
if($prn)
{
echo $query;
}

$result = @mysql_query($query) or die(mysql_error());

for($k=0; $k<mysql_num_rows($result); $k++)
{
$row=mysql_fetch_array($result);
echo $selvalue ."==".$row[$valfield];
if($selvalue == $row[$valfield])
$selected = " selected";
else
$selected = "";

echo "<option value='".$row[$valfield]."' ".$selected.">".$row[$showfield]."</option>\n";

}

}

/*****************************************************************************************************************
* Table of Contents: Global Database functions 5/4/2006
* Author(s) : Abhijeet Surana
* 1. globalauth($tblname,$fieldnames,$values);
*
*****************************************************************************************************************/

function globalauth($tblname, $wherefields, $wherevalues)
{
$query.=" SELECT * FROM ".$tblname;
if(is_array($wherefields))
{
if(sizeof($wherefields) > 0)
{
for($j=0; $j<sizeof($wherefields); $j++)
{
$condition.= " $wherefields[$j] = '$wherevalues[$j]' ";

if($j<sizeof($wherefields)-1)
$condition .= " and ";
}
}
}
else
{
if($wherefields)
$condition = $wherefields." = '".$wherevalues."'";
$condition = "1";
}

$query.=" WHERE $condition ";

$result = @mysql_query($query) or die(mysql_error());
return (@mysql_num_rows($result) > 0)?true:false;
}

/*****************************************************************************************************************
* Table of Contents: Global Database functions 5/4/2006
* Author : Abhijeet Surana
* 1. globalchkexist($tblname,$wherefield,$wherevalue);
*
*****************************************************************************************************************/

function globalchkexist($tblname, $wherefields, $wherevalues)
{
$query.=" SELECT * FROM ".$tblname;


if(is_array($wherefields))
{
if(sizeof($wherefields) > 0)
{
for($j=0; $j<sizeof($wherefields); $j++)
{
if(strstr($wherevalues[$j],".") && !strstr($wherevalues[$j],"@"))
$condition.= " $wherefields[$j] = $wherevalues[$j] ";
else
$condition.= " $wherefields[$j] = '$wherevalues[$j]' ";

if($j<sizeof($wherefields)-1)
$condition .= " and ";
}
}
}
else
{
if($wherefields)
$condition = " $wherefields = '$wherevalues' ";
else
$condition ="1";
}

/*if($wherefield)
{
$condition.=" $wherefield = '$wherevalue' ";
}
else
{
$condition ="1";
}*/

$query.=" WHERE $condition ";
//echo "<br>asa".$query;
//die;
$result = @mysql_query($query) or die(mysql_error());

return (@mysql_num_rows($result) > 0)?true:false;
}

/*****************************************************************************************************************
* Table of Contents: Global Database functions 5/4/2006
* Author(s) : Abhijeet Surana
* 1. globaldelete($tblname,$wherefield,$wherevalue);
*
*****************************************************************************************************************/

function gdel($tbl, $wf, $wv, $prn)
{

$query.=" DELETE FROM ".$tbl;
if(is_array($wf))
{
if(sizeof($wf) > 0)
{
for($j=0; $j<sizeof($wf); $j++)
{

$condition.=" $wf[$j] = '$wv[$j]'";
if($j<sizeof($wf)-1)

$condition.=" and";

}
}
}
else
{
$condition = "$wf = '$wv'";
}
$query.=" WHERE $condition ";
if($prn)
{
echo $query;
}
$result = @mysql_query($query) or die(mysql_error());
return $result;

}

/*****************************************************************************************************************
* Table of Contents: Global Database functions 5/4/2006
* Author(s) : Abhijeet Surana
* 1. cupdt($tblname,$setfield,$setvalue,$wherefields,$wherevalues);
*
*****************************************************************************************************************/

function cupdt($tbl, $sf, $sv, $wf, $wv, $prn)
{
$query.=" UPDATE ".$tbl." SET ";

/* Here updating fields and values are composed */

if(is_array($sf))
{
if(sizeof($sf) > 0)
{
for($j=0; $j<sizeof($sf); $j++)
{
$update_vars.= " $sf[$j] = '$sv[$j]' ";

if($j<sizeof($sf)-1)
$update_vars .= ", ";
}
}
}
else
{
$update_vars.= " $sf = '$sv' ";
}

$query.= $update_vars;

/*Here condition is created*/

if(is_array($wf))
{
if(sizeof($wf) > 0)
{
for($k=0; $k<sizeof($wf); $k++)
{
$condition.= " $wf[$k] = '$wv[$k]' ";

if($k<sizeof($wf)-1)
$condition .= " and ";
}
}
}
else
{
if($wf)
$condition = $wf." = '$wv' ";
else
$condition="1";
}
$query.= " WHERE $condition ";
if($prn==1)
{
echo $query;
}
$result = @mysql_query($query) or die(mysql_error());
return $result;
}

/*********************************************************************************
* Function : Creating for complex join query by passing directly condition string
*
* Validation Type: PHP Server Side
* globaljoinquery($tblname, $selectfields , $condition, $orderbyfield, $groupby, $ad, $limit)
* Author(s) : Abhijeet Surana 15/03/2007
*********************************************************************************/

function gj($tbl, $sf , $cd, $ob, $gb, $ad, $l, $prn)
{
if(is_array($sf))
{
$fields = implode(",", $sf);
}
else
{
if($sf)
$fields = $sf;
else
$fields = "*";
}

$query.=" SELECT ".$fields." FROM ".$tbl;

$query.=" WHERE $cd ";

if($gb)
$query.=" group by ".$gb;

if($ob)
$query.=" order by ".$ob." ".$ad;



if($l)
$query.=" limit ".$l;
if($prn!="")
{
echo $query;
}

$result = @mysql_query($query) or die(mysql_error());
$num = @mysql_num_rows($result);
if($num<1)
{
$result = 'n';
}
return $result;
}




/*********************************************************************************
* Function : Creating for complex join query by passing directly condition string
*
* Validation Type: PHP Server Side
* countnoofrow($tblname,$wherefields,$wherevalues)
* Author(s) : Abhijeet Surana
*********************************************************************************/


function globalcountnoofrow($tblname,$wherefield,$wherevalue)

{
$query.=" SELECT count(*) FROM ".$tblname;
if(is_array($wherefield))
{
if(sizeof($wherefield) > 0)
{
for($j=0; $j<sizeof($wherefield); $j++)
{

$condition.=" $wherefield[$j] = '$wherevalue[$j]'";
if($j<sizeof($wherefield)-1)

$condition.=" and";
&nb

Is This A Good Question/Topic? 0
  • +

Replies To: Joomla Module Trouble

#2 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: Joomla Module Trouble

Posted 13 February 2009 - 07:36 PM

Honestly, I have no idea what Joomla is. However, I did a literal search on Google with the error message you recieved, and found this page. I think it may help.
Was This Post Helpful? 0
  • +
  • -

#3 im@geek  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 94
  • Joined: 18-February 05

Re: Joomla Module Trouble

Posted 15 February 2009 - 03:48 PM

View Postbsaunders, on 13 Feb, 2009 - 06:36 PM, said:

Honestly, I have no idea what Joomla is. However, I did a literal search on Google with the error message you recieved, and found this page. I think it may help.



Thanks
Was This Post Helpful? 0
  • +
  • -

#4 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Re: Joomla Module Trouble

Posted 15 February 2009 - 04:00 PM

I've had so many problems with Joomla it's not even funny. I can remember 5-6 jobs I got on RentACoder all relating to Joomla problems. Unfortunately, Joomla doesn't provide the best support for their major problems. As it is an OS project with volunteer programmers... it doesn't make for the best Tech Support.


If you fix the problem with the previous post, let us know, as I will also try and help if you can't figure it out.

Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1