How do I include outside scripts?
How do I include outside scripts?
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?
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?
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?
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?
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
http://wiki.cmsmadesimple.org/index.php ... fined_Tags
and
http://wiki.cmsmadesimple.org/index.php ... _tags_here
Re: How do I include outside scripts?
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.
$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?
Is there some reason not to use cmsms db connection?
example follows
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?
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?

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?
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?
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()) {
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()) {
- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
Re: How do I include outside scripts?
Maybe try this line instead: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()) {
Code: Select all
while ($dbresult && $result_row = $dbresult->FetchRow()) {

Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 
