Page 1 of 1
How do I include outside scripts?
Posted: Wed Jul 26, 2006 10:56 pm
by sds
I run a news aggregator by hand and the add article section is way to slow to add 20-30 links a day. So, I would rather keep using my current setup, but include the output on a CMSMS page. How is this done? How can I run my php scripts from inside CMSMS and to a lesser extent, just insert a flat file when necessary?
Re: How do I include outside scripts?
Posted: Thu Jul 27, 2006 9:14 am
by tsw
Create new user defined tag copy paste your script into it and remove , then you can call it on your page with {yourtagname}
Re: How do I include outside scripts?
Posted: Thu Jul 27, 2006 12:02 pm
by sds
thanks. I kind of did that, but it broke some things.
http://www.sabresreport.com/cms/index.p ... t_newswire
the footer broke.
What I did was call the function in my tag. Then, in the file content.functions.php, I inserted my "require file" line. The file has the function listed in my tag. This is less than ideal, since this file will always be called regardless of page being vieng viewed and it also broke the smarty footer.
I guess I can include the entire function, calls to a database, etc... all in one function w/o problems?
Re: How do I include outside scripts?
Posted: Thu Jul 27, 2006 3:27 pm
by tsw
You shouldnt have to edit any files when creating user defined tags, have you read these wiki pages about udt's
http://wiki.cmsmadesimple.org/index.php ... fined_Tags
and
http://wiki.cmsmadesimple.org/index.php ... _tags_here
Re: How do I include outside scripts?
Posted: Fri Jul 28, 2006 3:41 am
by sds
so, I'm trying to include my functions in (mytag} and it is getting hung up on the db query. Here is the top snippet where it stops....
$name = "xxxx";
$server = "localhost";
$user = "xxxx";
$pass = "xxxx";
function MySQLConnect($errmsg, $msg="") {
$success = mysql_connect($GLOBALS["server"], $GLOBALS["user"],
$GLOBALS["pass"]);
if (!$success) {
mail($GLOBALS["Err_Mail"], "[Connect Failure] $errmsg", mysql_errno(). ": ".mysql_error(), "From: AutoError");
die();
}
}
function MySQLQuery($query, $errmsg, $msg="") {
$success = mysql_db_query($GLOBALS["name"], $query);
if (!$success) {
mail($GLOBALS["Err_Mail"], "[Query failure] $errmsg", mysql_errno(). ": ".mysql_error(), "From: AutoError");
echo $msg;
die();
}
return $success;
}
global $show, $view;
MySQLConnect ("An error occured!", "Sorry, this service is temporarily unavailable.");
$result = MySQLQuery ("select count(*) from mytable", "There was an error!", "Sorry, this service is temporarily unavailable..");
the last line returns the "Sorry, this service is temporarily unavailable.." error.... what could be wrong here? the script works fine outside of CMSMS.
Re: How do I include outside scripts?
Posted: Fri Jul 28, 2006 6:17 pm
by tsw
Is there some reason not to use cmsms db connection?
example follows
Code: Select all
//get db connection
global $gCms;
$db = &$gCms->db;
//some output
$output = "Your query has returned: ";
//mysql query
$q = "SELECT count(*) FROM ".cms_db_prefix()."content";
//execute it!
$dbresult = $db->Execute( $q );
//oh noes, something went wrong
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
//lets go through the results
while ($dbresult && $result_row = $dbresult->FetchRow())
{
//add to output
$output .= $result_row['count(*)'];
}
//lets say it out loud
echo $output;
Re: How do I include outside scripts?
Posted: Fri Jul 28, 2006 6:24 pm
by sds
I didn't know how...
it looks like if I cut and paste this I should have working output. What if I use a different dBase? Any issues there?
Re: How do I include outside scripts?
Posted: Fri Jul 28, 2006 11:22 pm
by sds
So, that worked, but I need to connect to a different dBase and I don't have a clue how to change that setting. Even the table being queried looks odd to me in your example.
Re: How do I include outside scripts?
Posted: Sat Jul 29, 2006 1:21 am
by sds
Ok, I have the proper table and db selected, but I am having a hell of a time getting the rest of the queries and code to run.
Now I get:
Fatal error: Call to a member function on a non-object in /home/xxx/xxx.com/xxx/xxx/lib/content.functions.php(653) : eval()'d code on line 95
What does that mean?
Line 95 in my tag is:
while ($result && $result_row = $row->FetchRow()) {
Re: How do I include outside scripts?
Posted: Sun Jul 30, 2006 8:00 pm
by Elijah Lofgren
sds wrote:
Ok, I have the proper table and db selected, but I am having a hell of a time getting the rest of the queries and code to run.
Now I get:
Fatal error: Call to a member function on a non-object in /home/xxx/xxx.com/xxx/xxx/lib/content.functions.php(653) : eval()'d code on line 95
What does that mean?
Line 95 in my tag is:
while ($result && $result_row = $row->FetchRow()) {
Maybe try this line instead:
Code: Select all
while ($dbresult && $result_row = $dbresult->FetchRow()) {
If that does not work, please paste the entire UDT (without passwords of course) and I will take a look at it.
