Page 1 of 1
Possible Bug with Stylesheets and User Defined Tags
Posted: Mon Jan 03, 2011 9:05 pm
by skarni
Hey Gang,
Normally, my user defined tags that contain php work well when planted into the content of a site via a smarty tag.
However, recently, I tried putting my search process into a page. While the search displays results, it breaks the template and does not show the footer or the background graphics.
Any idea why this is happening?
If your curious to see it in action, goto:
http://setelbrochure9.setel.com/index.p ... ating_info
click on any drop down and select any option, click "submit".
===
I've added the smarty tag in the template with the same results.
Any ideas?
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Mon Jan 03, 2011 9:31 pm
by Wishbone
It looks like your output is being truncated. No 'head' and the body is cut short. I had this happen to me once, but can't remember what it was.
Your 'process' page works fine by itself, so I'm guessing that the UDT to get the POST data is doing something wonky.. You might want to post your UDT.
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Mon Jan 03, 2011 9:45 pm
by skarni
I censored my user pass. My UDT is:
==============================
Code: Select all
//echo $_POST["restname"];
function db_connect()
{
$db= mysql_pconnect("tourpikecounty10.db.6811152.hostedresource.com","(Censored)","(Censored)");
if (!db)
{echo 'Unable to open database';exit;}
else {
mysql_select_db("(Censored");
}
}
function db_close()
{
mysql_close($db);
}
function getRestByName($name)
{
db_connect();
//$query='select * from `eat` where name LIKE \'%'.addslashes($name).'%\'';
$query= 'select distinct e.* ';
$query.='from eat e ';
$query.='left join eat_keyword ek on e.id = ek.eat_id ';
$query.='where ek.keyword like \'%'.addslashes($name).'%\'';
echo $query.'<br>';
@ $result=mysql_query($query);
if (!$result)
{
$problem=mysql_error();
echo 'The following error occured '.$problem;
}
else
{
$numresults=mysql_num_rows($result);
echo '<br><br>numresults='.$numresults.'<br><br>';
for($x=1;$x<=$numresults;$x++)
{
$data=mysql_fetch_array($result);
//echo 'id='.$data[id]."<br>";
echo 'name='.$data[name]."<br>";
echo 'address='.$data[address]."<br>";
echo 'city='.$data[city]."<br>";
echo 'type='.$data[type]."<br>";
echo '<img src=\''.$data[imgpath].'\'>';
echo 'map='.$data[map]."";
echo "<br><br>";
}
//$str=$id.'|'.$date.'|'.$title.'|'.$entry;
}
//return $str;
//db_close();
}
function getRestByAll($name,$type,$location)
{
db_connect();
$query= 'select distinct e.* ';
$query.='from eat e ';
$query.='left join eat_keyword ek on e.id = ek.eat_id ';
$query.='where ek.keyword like \'%'.addslashes($name).'%\' ';
$query.='AND e.type LIKE \'%'.$type.'%\' AND e.location = \''.$location.'\'';
echo $query.'<br>';
@ $result=mysql_query($query);
if (!$result)
{
$problem=mysql_error();
echo 'The following error occured '.$problem;
}
else
{
$numresults=mysql_num_rows($result);
echo '<br><br>numresults='.$numresults.'<br><br>';
for($x=1;$x<=$numresults;$x++)
{
$data=mysql_fetch_array($result);
echo 'id='.$data[id]."<br>";
echo 'name='.$data[name]."<br>";
echo 'address='.$data[address]."<br>";
echo 'city='.$data[city]."<br>";
echo 'type='.$data[type]."<br>";
echo '<img src=\''.$data[imgpath].'\'>';
echo "<br><br>";
}
//$str=$id.'|'.$date.'|'.$title.'|'.$entry;
}
}
function getRestByEither($type,$location)
{
db_connect();
$query='select * from `eat` where type LIKE \'%'.$type.'%\' AND location = \''.$location.'\'';
echo $query.'<br>';
@ $result=mysql_query($query);
if (!$result)
{
$problem=mysql_error();
echo 'The following error occured '.$problem;
}
else
{
$numresults=mysql_num_rows($result);
echo '<br><br>numresults='.$numresults.'<br><br>';
for($x=1;$x<=$numresults;$x++)
{
$data=mysql_fetch_array($result);
echo 'id='.$data[id]."<br>";
echo 'name='.$data[name]."<br>";
echo 'address='.$data[address]."<br>";
echo 'city='.$data[city]."<br>";
echo 'type='.$data[type]."<br>";
echo '<img src=\''.$data[imgpath].'\'>';
echo "<br><br>";
}
//$str=$id.'|'.$date.'|'.$title.'|'.$entry;
}
}
function getRestByLocation($location)
{
db_connect();
$query='select * from `eat` where location = \''.$location.'\'';
echo $query.'<br>';
@ $result=mysql_query($query);
if (!$result)
{
$problem=mysql_error();
echo 'The following error occured '.$problem;
}
else
{
$numresults=mysql_num_rows($result);
echo '<br><br>numresults='.$numresults.'<br><br>';
for($x=1;$x<=$numresults;$x++)
{
$data=mysql_fetch_array($result);
echo 'id='.$data[id]."<br>";
echo 'name='.$data[name]."<br>";
echo 'address='.$data[address]."<br>";
echo 'city='.$data[city]."<br>";
echo 'type='.$data[type]."<br>";
echo '<img src=\''.$data[imgpath].'\'>';
echo "<br><br>";
}
//$str=$id.'|'.$date.'|'.$title.'|'.$entry;
}
//return $str;
//db_close();
}
function getRestByBoth($name,$type)
{
db_connect();
$query= 'select distinct e.* ';
$query.='from eat e ';
$query.='left join eat_keyword ek on e.id = ek.eat_id ';
$query.='where ek.keyword like \'%'.addslashes($name).'%\' ';
$query.='AND e.type LIKE \'%'.$type.'%\'';
echo $query.'<br>';
@ $result=mysql_query($query);
if (!$result)
{
$problem=mysql_error();
echo 'The following error occured '.$problem;
}
else
{
$numresults=mysql_num_rows($result);
echo '<br><br>numresults='.$numresults.'<br><br>';
for($x=1;$x<=$numresults;$x++)
{
$data=mysql_fetch_array($result);
echo 'id='.$data[id]."<br>";
echo 'name='.$data[name]."<br>";
echo 'address='.$data[address]."<br>";
echo 'city='.$data[city]."<br>";
echo 'type='.$data[type]."<br>";
echo '<img src=\''.$data[imgpath].'\'>';
echo "<br><br>";
}
//$str=$id.'|'.$date.'|'.$title.'|'.$entry;
}
}
function getRestByNameLoc($name,$location)
{
db_connect();
$query= 'select distinct e.* ';
$query.='from eat e ';
$query.='left join eat_keyword ek on e.id = ek.eat_id ';
$query.='where ek.keyword like \'%'.addslashes($name).'%\' ';
$query.='AND e.location = \''.$location.'\'';
echo $query.'<br>';
@ $result=mysql_query($query);
if (!$result)
{
$problem=mysql_error();
echo 'The following error occured '.$problem;
}
else
{
$numresults=mysql_num_rows($result);
echo '<br><br>numresults='.$numresults.'<br><br>';
for($x=1;$x<=$numresults;$x++)
{
$data=mysql_fetch_array($result);
echo 'id='.$data[id]."<br>";
echo 'name='.$data[name]."<br>";
echo 'address='.$data[address]."<br>";
echo 'city='.$data[city]."<br>";
echo 'type='.$data[type]."<br>";
echo '<img src=\''.$data[imgpath].'\'>';
echo "<br><br>";
}
//$str=$id.'|'.$date.'|'.$title.'|'.$entry;
}
}
function getRestByType($type)
{
db_connect();
$query='select * from `eat` where type LIKE \'%'.$type.'%\'';
echo $query.'<br>';
@ $result=mysql_query($query);
if (!$result)
{
$problem=mysql_error();
echo 'The following error occured '.$problem;
}
else
{
$numresults=mysql_num_rows($result);
echo '<br><br>numresults='.$numresults.'<br><br>';
for($x=1;$x<=$numresults;$x++)
{
$data=mysql_fetch_array($result);
echo 'id='.$data[id]."<br>";
echo 'name='.$data[name]."<br>";
echo 'address='.$data[address]."<br>";
echo 'city='.$data[city]."<br>";
echo 'type='.$data[type]."<br>";
echo '<img src=\''.$data[imgpath].'\'>';
echo "<br><br>";
}
//$str=$id.'|'.$date.'|'.$title.'|'.$entry;
}
//return $str;
//db_close();
}
foreach($_POST as $key=>$value)
echo $key."=".$value."<br>";
if($_POST["restname"]!="" && $_POST["resttype"]=="" && $_POST["restlocation"]=="")
{
//echo '1';
getRestByName($_POST["restname"]);
exit;
}
if($_POST["restname"]=="" && $_POST["resttype"]=="" && $_POST["restlocation"]!="")
{
//echo '2';
getRestByLocation($_POST["restlocation"]);
exit;
}
if($_POST["restname"]=="" && $_POST["resttype"]!="" && $_POST["restlocation"]=="")
{
//echo '3';
getRestByType($_POST["resttype"]);
exit;
}
if($_POST["restname"]!="" && $_POST["resttype"]!="" && $_POST["restlocation"]!="")
{
//echo '4';
getRestByAll($_POST["restname"],$_POST["resttype"],$_POST["restlocation"]);
exit;
}
if($_POST["restname"]!="" && $_POST["resttype"]!="" && $_POST["restlocation"]=="")
{
//echo '5';
getRestByBoth($_POST["restname"],$_POST["resttype"]);
exit;
}
if($_POST["restname"]=="" && $_POST["resttype"]!="" && $_POST["restlocation"]!="")
{
//echo '6';
getRestByEither($_POST["resttype"],$_POST["restlocation"]);
exit;
}
if($_POST["restname"]!="" && $_POST["resttype"]=="" && $_POST["restlocation"]!="")
{
//echo '7';
getRestByNameLoc($_POST["restname"],$_POST["restlocation"]);
exit;
}
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Mon Jan 03, 2011 9:47 pm
by Jeff
Edit your config.php turn debug mode on. More than likely your search is producing an error which will cause php to stop processing the page.
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Mon Jan 03, 2011 10:03 pm
by Wishbone
Are defining functions supported in UDTs? What if there is a db_connect already defined?
After trying Jeff's suggestion, try removing everything from the UDT and start putting it slowly back until you find what breaks it.
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Tue Jan 04, 2011 4:39 am
by skarni
Thanks to you guys, I have identified the code that is breaking the template. However, I do not know how to fix it, and if it is a compatibility issue with CMS MS.
The template only breaks when results are returned by the code below. It may be worth noting that the MySQL database I am drawing from is not hosting on the same hosting as the website I am working with. I don't know? Any suggestions?
The code is the following:
Code: Select all
if($_POST["restname"]!="" && $_POST["resttype"]=="" && $_POST["restlocation"]=="")
{
//echo '1';
getRestByName($_POST["restname"]);
exit;
}
if($_POST["restname"]=="" && $_POST["resttype"]=="" && $_POST["restlocation"]!="")
{
//echo '2';
getRestByLocation($_POST["restlocation"]);
exit;
}
if($_POST["restname"]=="" && $_POST["resttype"]!="" && $_POST["restlocation"]=="")
{
//echo '3';
getRestByType($_POST["resttype"]);
exit;
}
if($_POST["restname"]!="" && $_POST["resttype"]!="" && $_POST["restlocation"]!="")
{
//echo '4';
getRestByAll($_POST["restname"],$_POST["resttype"],$_POST["restlocation"]);
exit;
}
if($_POST["restname"]!="" && $_POST["resttype"]!="" && $_POST["restlocation"]=="")
{
//echo '5';
getRestByBoth($_POST["restname"],$_POST["resttype"]);
exit;
}
if($_POST["restname"]=="" && $_POST["resttype"]!="" && $_POST["restlocation"]!="")
{
//echo '6';
getRestByEither($_POST["resttype"],$_POST["restlocation"]);
exit;
}
if($_POST["restname"]!="" && $_POST["resttype"]=="" && $_POST["restlocation"]!="")
{
//echo '7';
getRestByNameLoc($_POST["restname"],$_POST["restlocation"]);
exit;
}
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Tue Jan 04, 2011 4:51 am
by calguy1000
This is an obvious issue with the code that you are trying to use in the UDT and not with CMSMS itself.
Please contact the author of that code for assistance.
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Tue Jan 04, 2011 4:56 am
by skarni
Thank you. Is it something you could point out to me? The author of the code knows nothing about CMSMS and maintains that it should work.
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Tue Jan 04, 2011 5:05 am
by Wishbone
I would suggest editing one of the GetRestBy<whatever> functions and comment out all the "echo" statements to see if it is outputting something objectionable. If the template works when the echo statements are gone, we have somewhere to start with. The next step would be to comment out the sql queries and set up some fake data in $data to iterate over. If the template works when you do this, it could be something with the SQL call.
It might be due to the subroutine definitions in the UDT.. I've never heard of that before.
Re: Possible Bug with Stylesheets and User Defined Tags
Posted: Tue Jan 04, 2011 5:12 am
by calguy1000
a: A UDT is merely a uniquely named PHP function that is dynamically created on load given the content in the database.
b: Creating functions within a function is valid within PHP. However it is my experience (as much as I hate it) that the functions created have global scope (which seriously sucks IMnsHO, but that's a PHP flaw not a CMSMS thing).
c: The problem here is not those functions. When working in PHP within 'any package' you need a reasonable understanding of PHP. Grabbing a script/hack/patch/file from 'somewhere' and putting it into 'any package'' without a knowledge of what it does, what it effects, and how to diagnose and fix the problems that doing this may cause is not something that we can or will support.