PDA

View Full Version : Some php help if you wouldn't mind...pretty easy


Jace
08-09-2005, 06:41 PM
I am using cnstats for tracking, and need to put the code into my b2evolution blog, and for some reason when I put it in the _main.php like this:

<?
include "/usr/home/tabitha/public_html/jonstern/cnstats/cnt.php";
?>

it brings up some mysql errors, and won't let certain things access the database correctly

here is the page I am trying to put it in...any ideas on how to do this without getting those errors? i know I probably have to tell it to grab that file another way, but I am not sure how

<?php
/**
* This is the main template. It displays the blog.
*
* However this file is not meant to be called directly.
* It is meant to be called automagically by b2evolution.
* To display a blog, you should call a stub file instead, for example:
* /blogs/index.php or /blogs/blog_b.php
*
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2004 by Francois PLANQUE - {@link http://fplanque.net/}
*
* @package evoskins
* @subpackage helsinki
*/
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
include('./usr/home/tabitha/public_html/jonstern/cnstats/cnt.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php locale_charset() ?>" />
<title>
<?php
$Blog->disp('name', 'htmlhead');
arcdir_title( ' - ', 'htmlhead' );
last_comments_title( ' - ', 'htmlhead' );
profile_title( ' - ', 'htmlhead' );
single_cat_title( ' - ', 'htmlhead' );
single_month_title( ' - ', 'htmlhead' );
single_post_title( ' - ', 'htmlhead' );
stats_title( ' - ', 'htmlhead' );
?>
</title>
<base href="<?php skinbase(); // Base URL for this skin. You need this to fix relative links! ?>" />
<meta name="description" content="<?php $Blog->disp( 'shortdesc', 'htmlattr' ); ?>" />
<meta name="keywords" content="<?php $Blog->disp( 'keywords', 'htmlattr' ); ?>" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<meta http-equiv="imagetoolbar" content="no" />
<?php switch( $disp ) {
case 'profile':
case 'stats':
echo '<meta name="robots" content="noindex, nofollow" />'."\n";
break;
case 'arcdir':
echo '<meta name="robots" content="noindex, follow" />'."\n";
break;
}
?>
<meta name="generator" content="b2evolution <?php echo $b2_version ?>" /> <!-- Please leave this for stats -->
<link rel="alternate" type="text/xml" title="RDF" href="<?php $Blog->disp( 'rdf_url', 'raw' ) ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php $Blog->disp( 'rss_url', 'raw' ) ?>" />
<link rel="alternate" type="text/xml" title="RSS 2.0" href="<?php $Blog->disp( 'rss2_url', 'raw' ) ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom" href="<?php $Blog->disp( 'atom_url', 'raw' ) ?>" />
<link rel="pingback" href="<?php $Blog->disp( 'pingback_url', 'raw' ) ?>" />
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
<link rel="stylesheet" type="text/css" media="screen" href="helsinki.css" />
</head>
<body>
!!!!!!!!!!!I AM TRYING TO PUT THE CNSTATS CODE RIGHT HERE!!!!!!!!
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top"><script language='JavaScript' type='text/javascript' src='http://www.jonstern.net/phpAdsNew/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.jonstern.net/phpAdsNew/adjs.php?n=" + phpAds_random);
document.write ("&amp;what=zone:1");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.jonstern.net/phpAdsNew/adclick.php?n=a6024578' target='_blank'><img src='http://www.jonstern.net/phpAdsNew/adview.php?what=zone:1&amp;n=a6024578' border='0' alt=''></a></noscript>
</td>
<td align="center" valign="top"><div class="pageHeader">
<?php require( dirname(__FILE__).'/_bloglist.php'); // BLOG LIST INCLUDED HERE ?><br>
<img src="http://www.jonstern.net/skins/helskinki/img/header.jpg"><br />
| <a href="http://www.jonstern.net">Main Page</a> | <a href="http://www.jonstern.net/index.php?cat=2">Jon's Ramblings</a> | <a href="http://www.jonstern.net/index.php?cat=3">Online News</a> | <a href="http://www.jonstern.net/index.php?cat=14">Forum Chatter</a> |<br />
| <a href="http://www.jonstern.net/index.php?cat=1">Press Releases</a> | <a href="http://www.jonstern.net/index.php?cat=20">Website Reviews</a> | <a href="http://www.jonstern.net/index.php?cat=27">Gossip</a> |
</div></td>
<td align="center" valign="top"><script language='JavaScript' type='text/javascript' src='http://www.jonstern.net/phpAdsNew/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.jonstern.net/phpAdsNew/adjs.php?n=" + phpAds_random);
document.write ("&amp;what=zone:1");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.jonstern.net/phpAdsNew/adclick.php?n=a6024578' target='_blank'><img src='http://www.jonstern.net/phpAdsNew/adview.php?what=zone:1&amp;n=a6024578' border='0' alt=''></a></noscript>
</td>
</tr>
</table>
<div align="center"><?php
if (@include(getenv('DOCUMENT_ROOT').'/phpAdsNew/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:3', 0, '', '', '0', $phpAds_context);
echo $phpAds_raw['html'];
}
?>
</div>
<div class="bPosts">
<h2>
<?php
arcdir_title();
last_comments_title();
profile_title();
single_cat_title();
single_month_title();
single_post_title();
stats_title();
?>
</h2>

<?php // START POSTS
if( isset($MainList) ) $MainList->display_if_empty(); // Display message if no post
if( isset($MainList) ) while( $Item = $MainList->get_item() ) {
locale_temp_switch( $Item->locale ); // Temporarily switch to post locale
$MainList->date_if_changed(); // display post date if it changed
$Item->anchor(); // Anchor for permalinks to refer to
?>

<div class="bPost" lang="<?php $Item->lang() ?>">
<h3 class="bTitle"><?php $Item->title(); ?></h3>

<div class="bSmallHead">
<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>"><img src="img/icon_minipost.gif" alt="<?php echo T_('Permalink') ?>" width="12" height="9" class="middle" /></a>
<?php
$Item->issue_time();
echo ', ', T_('Categories'), ': ';
$Item->categories();
echo ', ';
the_wordcount();
echo ' ', T_('words');
?>
</div>

<div class="bText">
<?php
$Item->content();
link_pages("<br />Pages: ","<br />","number");
?>
</div>

<div class="bSmallPrint">
<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>" class="permalink_right"><img src="img/chain_link.gif" alt="<?php echo T_('Permalink') ?>" width="14" height="14" border="0" class="middle" /></a>
<?php $Item->feedback_link( 'comments' ) // Link to comments ?>
<?php $Item->feedback_link( 'trackbacks', ' &bull; ' ) // Link to trackbacks ?>
<?php $Item->feedback_link( 'pingbacks', ' &bull; ' ) // Link to trackbacks ?>
<?php $Item->trackback_rdf() // trackback autodiscovery information ?>
</div>

<?php // START OF INCLUDE FOR COMMENTS, TRACKBACK, PINGBACK, ETC.
$disp_comments = 1; // Display comments if requested
$disp_comment_form = 1; // Display comments form if requested
if ( get_bloginfo( 'allowtrackbacks' ) == 1 ) {
$disp_trackbacks = 1; // Display trackbacks if requested
$disp_trackback_url = 1; // Display trackback URL if requested
} else {
$disp_trackbacks = 0; // or don't
$disp_trackback_url = 0; // or don't
}
if ( get_bloginfo( 'allowpingbacks' ) == 1 ) {
$disp_pingbacks = 1; // Display pingbacks if requested
} else {
$disp_pingbacks = 0;
}
require( dirname(__FILE__).'/_feedback.php' );

locale_restore_previous(); // Restore previous locale (Blog locale)
?>

</div>

Jace
08-09-2005, 06:43 PM
oh, and as you can see, i have it trying to call the stats on the top of the page, in the first php part

include('./usr/home/tabitha/public_html/jonstern/cnstats/cnt.php');

but that is not working

Trev
08-09-2005, 07:01 PM
I am using cnstats for tracking, and need to put the code into my b2evolution blog, and for some reason when I put it in the _main.php like this:

<?
include "/usr/home/tabitha/public_html/jonstern/cnstats/cnt.php";
?>

it brings up some mysql errors, and won't let certain things access the database correctly

here is the page I am trying to put it in...any ideas on how to do this without getting those errors? i know I probably have to tell it to grab that file another way, but I am not sure how

<?php
/**
* This is the main template. It displays the blog.
*
* However this file is not meant to be called directly.
* It is meant to be called automagically by b2evolution.
* To display a blog, you should call a stub file instead, for example:
* /blogs/index.php or /blogs/blog_b.php
*
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2004 by Francois PLANQUE - {@link http://fplanque.net/}
*
* @package evoskins
* @subpackage helsinki
*
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
include('./usr/home/tabitha/public_html/jonstern/cnstats/cnt.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php locale_charset() ?>" />
<title>
<?php
$Blog->disp('name', 'htmlhead');
arcdir_title( ' - ', 'htmlhead' );
last_comments_title( ' - ', 'htmlhead' );
profile_title( ' - ', 'htmlhead' );
single_cat_title( ' - ', 'htmlhead' );
single_month_title( ' - ', 'htmlhead' );
single_post_title( ' - ', 'htmlhead' );
stats_title( ' - ', 'htmlhead' );
?>
</title>
<base href="<?php skinbase(); // Base URL for this skin. You need this to fix relative links! ?>" />
<meta name="description" content="<?php $Blog->disp( 'shortdesc', 'htmlattr' ); ?>" />
<meta name="keywords" content="<?php $Blog->disp( 'keywords', 'htmlattr' ); ?>" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<meta http-equiv="imagetoolbar" content="no" />
<?php switch( $disp ) {
case 'profile':
case 'stats':
echo '<meta name="robots" content="noindex, nofollow" />'."\n";
break;
case 'arcdir':
echo '<meta name="robots" content="noindex, follow" />'."\n";
break;
}
?>
<meta name="generator" content="b2evolution <?php echo $b2_version ?>" /> <!-- Please leave this for stats -->
<link rel="alternate" type="text/xml" title="RDF" href="<?php $Blog->disp( 'rdf_url', 'raw' ) ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php $Blog->disp( 'rss_url', 'raw' ) ?>" />
<link rel="alternate" type="text/xml" title="RSS 2.0" href="<?php $Blog->disp( 'rss2_url', 'raw' ) ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom" href="<?php $Blog->disp( 'atom_url', 'raw' ) ?>" />
<link rel="pingback" href="<?php $Blog->disp( 'pingback_url', 'raw' ) ?>" />
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
<link rel="stylesheet" type="text/css" media="screen" href="helsinki.css" />
</head>
<body>
!!!!!!!!!!!I AM TRYING TO PUT THE CNSTATS CODE RIGHT HERE!!!!!!!!
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top"><script language='JavaScript' type='text/javascript' src='http://www.jonstern.net/phpAdsNew/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.jonstern.net/phpAdsNew/adjs.php?n=" + phpAds_random);
document.write ("&amp;what=zone:1");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.jonstern.net/phpAdsNew/adclick.php?n=a6024578' target='_blank'><img src='http://www.jonstern.net/phpAdsNew/adview.php?what=zone:1&amp;n=a6024578' border='0' alt=''></a></noscript>
</td>
<td align="center" valign="top"><div class="pageHeader">
<?php require( dirname(__FILE__).'/_bloglist.php'); // BLOG LIST INCLUDED HERE ?><br>
<img src="http://www.jonstern.net/skins/helskinki/img/header.jpg"><br />
| <a href="http://www.jonstern.net">Main Page</a> | <a href="http://www.jonstern.net/index.php?cat=2">Jon's Ramblings</a> | <a href="http://www.jonstern.net/index.php?cat=3">Online News</a> | <a href="http://www.jonstern.net/index.php?cat=14">Forum Chatter</a> |<br />
| <a href="http://www.jonstern.net/index.php?cat=1">Press Releases</a> | <a href="http://www.jonstern.net/index.php?cat=20">Website Reviews</a> | <a href="http://www.jonstern.net/index.php?cat=27">Gossip</a> |
</div></td>
<td align="center" valign="top"><script language='JavaScript' type='text/javascript' src='http://www.jonstern.net/phpAdsNew/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.jonstern.net/phpAdsNew/adjs.php?n=" + phpAds_random);
document.write ("&amp;what=zone:1");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.jonstern.net/phpAdsNew/adclick.php?n=a6024578' target='_blank'><img src='http://www.jonstern.net/phpAdsNew/adview.php?what=zone:1&amp;n=a6024578' border='0' alt=''></a></noscript>
</td>
</tr>
</table>
<div align="center"><?php
if (@include(getenv('DOCUMENT_ROOT').'/phpAdsNew/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:3', 0, '', '', '0', $phpAds_context);
echo $phpAds_raw['html'];
}
?>
</div>
<div class="bPosts">
<h2>
<?php
arcdir_title();
last_comments_title();
profile_title();
single_cat_title();
single_month_title();
single_post_title();
stats_title();
?>
</h2>

<?php // START POSTS
if( isset($MainList) ) $MainList->display_if_empty(); // Display message if no post
if( isset($MainList) ) while( $Item = $MainList->get_item() ) {
locale_temp_switch( $Item->locale ); // Temporarily switch to post locale
$MainList->date_if_changed(); // display post date if it changed
$Item->anchor(); // Anchor for permalinks to refer to
?>

<div class="bPost" lang="<?php $Item->lang() ?>">
<h3 class="bTitle"><?php $Item->title(); ?></h3>

<div class="bSmallHead">
<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>"><img src="img/icon_minipost.gif" alt="<?php echo T_('Permalink') ?>" width="12" height="9" class="middle" /></a>
<?php
$Item->issue_time();
echo ', ', T_('Categories'), ': ';
$Item->categories();
echo ', ';
the_wordcount();
echo ' ', T_('words');
?>
</div>

<div class="bText">
<?php
$Item->content();
link_pages("<br />Pages: ","<br />","number");
?>
</div>

<div class="bSmallPrint">
<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>" class="permalink_right"><img src="img/chain_link.gif" alt="<?php echo T_('Permalink') ?>" width="14" height="14" border="0" class="middle" /></a>
<?php $Item->feedback_link( 'comments' ) // Link to comments ?>
<?php $Item->feedback_link( 'trackbacks', ' &bull; ' ) // Link to trackbacks ?>
<?php $Item->feedback_link( 'pingbacks', ' &bull; ' ) // Link to trackbacks ?>
<?php $Item->trackback_rdf() // trackback autodiscovery information ?>
</div>

<?php // START OF INCLUDE FOR COMMENTS, TRACKBACK, PINGBACK, ETC.
$disp_comments = 1; // Display comments if requested
$disp_comment_form = 1; // Display comments form if requested
if ( get_bloginfo( 'allowtrackbacks' ) == 1 ) {
$disp_trackbacks = 1; // Display trackbacks if requested
$disp_trackback_url = 1; // Display trackback URL if requested
} else {
$disp_trackbacks = 0; // or don't
$disp_trackback_url = 0; // or don't
}
if ( get_bloginfo( 'allowpingbacks' ) == 1 ) {
$disp_pingbacks = 1; // Display pingbacks if requested
} else {
$disp_pingbacks = 0;
}
require( dirname(__FILE__).'/_feedback.php' );

locale_restore_previous(); // Restore previous locale (Blog locale)
?>

</div>

This is more Sarettah's area but I need to point out that you've left a <? out at the begining of the call, it should be:

* @package evoskins
* @subpackage helsinki
*
<?



It might not be the answer but it's a start.

Jace
08-09-2005, 07:04 PM
This is more Sarettah's area but I need to point out that you've left a <? out at the begining of the call, it should be:

* @package evoskins
* @subpackage helsinki
*
<?



It might not be the answer but it's a start.

i didn't write that, it is what b2evolution has in there

and isn't this the <?

* @package evoskins
* @subpackage helsinki
*
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
include('./usr/home/tabitha/public_html/jonstern/cnstats/cnt.php');
?>

Trev
08-09-2005, 07:09 PM
i didn't write that, it is what b2evolution has in there

and isn't this the <?

* @package evoskins
* @subpackage helsinki
*
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
include('./usr/home/tabitha/public_html/jonstern/cnstats/cnt.php');
?>
there's no opening <? to the closeing ?>

We need sarettah.

sarettah
08-09-2005, 07:40 PM
I looked. I don't see anything wrong there (or at least anything that souldn't work from a quick glance)

But, you said that "it brings up some mysql errors, and won't let certain things access the database correctly" when you place it where you want it.

That sounds to me like something in the cnt.php is conflicting somewehere.

Is the cnt.php using calls to the same MYSql connection as the main script, or is it creating a new connection to pull from ?

Does the cnt.php script possibly close the existing MYSql connection ?

Have you tried placing the cnt.php into the same folder as the main script and calling it from there (without the full pathing) ?

Another way to debug stuff like this is to make a copy of the main, cut and paste all of the cnt.php into the copy exactly where you want it and see if it works, if nothing else it might pop a more accurate error for you.

If you want to zap a copy of cnt.php to me I will take a look and see if I can see anything glaring out at me :)

Trev
08-09-2005, 07:44 PM
there's no opening <? to the closeing ?>

We need sarettah.
<?php was the opening, I'm not sure where my mind is :scratchin

Nickatilynx
08-09-2005, 07:46 PM
I looked. I don't see anything wrong there (or at least anything that souldn't work from a quick glance)

But, you said that "it brings up some mysql errors, and won't let certain things access the database correctly" when you place it where you want it.

That sounds to me like something in the cnt.php is conflicting somewehere.

Is the cnt.php using calls to the same MYSql connection as the main script, or is it creating a new connection to pull from ?

Does the cnt.php script possibly close the existing MYSql connection ?

Have you tried placing the cnt.php into the same folder as the main script and calling it from there (without the full pathing) ?

Another way to debug stuff like this is to make a copy of the main, cut and paste all of the cnt.php into the copy exactly where you want it and see if it works, if nothing else it might pop a more accurate error for you.

If you want to zap a copy of cnt.php to me I will take a look and see if I can see anything glaring out at me :)

See they let you out of the "Home for the Elderly or Generally Bewildered" early today...

;-)))

Dravyk
08-09-2005, 08:07 PM
It might also help (those who know, not me) if you report the actual errors that are getting.

Jace
08-09-2005, 08:08 PM
If you want to zap a copy of cnt.php to me I will take a look and see if I can see anything glaring out at me :)

done...thank you so much

i will hook you up with some nice text links and some traffic for your time if you want ;)

Jace
08-09-2005, 08:08 PM
It might also help (those who know, not me) if you report the actual errors that are getting.
i have to add that code back in and pull shit up, give me a minute

Jace
08-09-2005, 08:11 PM
wtf??? now it is working

a week of trying to figure this out, i finally deducted what was causing the problem...i remove it, and shit work...now I put it back in there and all the sudden it works?

fucking wierd

Dravyk
08-09-2005, 08:13 PM
wtf??? now it is working

a week of trying to figure this out, i finally deducted what was causing the problem...i remove it, and shit work...now I put it back in there and all the sudden it works?

fucking wierd
I'll send you my bill! http://oprano.com/msgboard/images/smilies/laugh.gif

Jace
08-09-2005, 08:18 PM
i am comletely lost as to what happened...and my inquisiting mind needs to know why it is working, but I guess I will leave well enough alone

sarettah
08-09-2005, 08:36 PM
I'll send you my bill! http://oprano.com/msgboard/images/smilies/laugh.gif

Fuck you Harry.

I'm the one who fixed it.

I took a look and voila, it all works.

So, I will send my bill.... dammit :yowsa:


(lololol...the last email I sent before I came back here was "Do you have this set up somewhere so I can see the errors you're getting"...lolololol....