 |
boardom b2 message board
|
View previous topic :: View next topic |
Author |
Message |
Mystis
Joined: 02 Mar 2003 Posts: 74
|
Posted: Sun Mar 23, 2003 8:46 pm Post subject: b2customfields - Custom post field functionality |
|
|
This may have been done before, but I decided that I was going to go all out with a system to manage custom fields in b2. why would someone want to do that? There's lots of possibilities, including adding a mood to each post, a 'currently listening to' field, you could use it to turn your blog into a photoblog, by having a field for an image/thumbnail url, or any of a number of possibilities. It features a full-fledged admin system for managing the fields, and a code generator to generate the code you use to place the field in your templates. Installation isn't exactly easy, but be careful when following the instructions and you should be alright.
Hope you all enjoy! I have a small website up soon with screenshots, faq, and some other small tidbit, located at http://www.mystis.net/b2customfields.html
Download here _________________ - Mystis
[url=tidakada.com/board/viewtopic.php?t=3375]b2customfields v2[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2sql[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2quotes[/url]
Last edited by Mystis on Mon Mar 24, 2003 3:19 am; edited 2 times in total |
|
Back to top |
|
 |
Mystis
Joined: 02 Mar 2003 Posts: 74
|
Posted: Mon Mar 24, 2003 3:16 am Post subject: |
|
|
General information, screenshots, and the latest version will always be found here: http://www.mystis.net/b2customfields.html _________________ - Mystis
[url=tidakada.com/board/viewtopic.php?t=3375]b2customfields v2[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2sql[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2quotes[/url] |
|
Back to top |
|
 |
Lusciousness
Joined: 04 Mar 2003 Posts: 12 Location: Pittsburgh, PA
|
Posted: Mon Mar 24, 2003 5:22 am Post subject: |
|
|
Wow, I LOVE YOU. |
|
Back to top |
|
 |
Reese
Joined: 07 Sep 2002 Posts: 60
|
Posted: Mon Mar 24, 2003 6:33 am Post subject: |
|
|
I would have loved you a few days ago.
But Jen (Lusciousness) and Mike (Cyberian75) know ALL about that.
Nice job finally getting that one accomplished, though. _________________ ---
Last edited by Reese on Mon Mar 24, 2003 11:14 pm; edited 1 time in total |
|
Back to top |
|
 |
Candle
Joined: 23 Dec 2002 Posts: 547
|
Posted: Mon Mar 24, 2003 7:08 am Post subject: oh my |
|
|
Trouble on your site I think.
Warning: ChDir: No such file or directory (errno 2) in /home/mystisn/public_html/index.php on line 30
Warning: Failed opening './write_logs.php' for inclusion (include_path='') in /home/mystisn/public_html/index.php on line 30 _________________ My Game Forum
 |
|
Back to top |
|
 |
cukkoo
Joined: 25 Feb 2003 Posts: 17
|
Posted: Mon Mar 24, 2003 3:47 pm Post subject: |
|
|
Hmmm... I would really like to get this working. I followed all the instructions but am getting this error
Fatal error: Call to undefined function: getcustomfield() in /home/virtual/site71/fst/var/www/html/blog/index.php on line 52
Any help would be appreciated |
|
Back to top |
|
 |
Candle
Joined: 23 Dec 2002 Posts: 547
|
Posted: Mon Mar 24, 2003 8:41 pm Post subject: ummmmm |
|
|
I installed it and all seems fine but when i put something in sya like mood and click the button it refreshs the page but nothing is there so not sure what is wrong ?
And I see nothing it being inputed in to the table in the database . _________________ My Game Forum
 |
|
Back to top |
|
 |
Mystis
Joined: 02 Mar 2003 Posts: 74
|
Posted: Tue Mar 25, 2003 1:55 am Post subject: Re: oh my |
|
|
Candle wrote: | Trouble on your site I think.
Warning: ChDir: No such file or directory (errno 2) in /home/mystisn/public_html/index.php on line 30
Warning: Failed opening './write_logs.php' for inclusion (include_path='') in /home/mystisn/public_html/index.php on line 30 |
Errmm...Where are you getting that error? If you're referring to the mystis.net domain, then that can't be, all that's there right now is an HTML splash. And the site for b2customfields is pure HTML also.
cukkoo wrote: | Hmmm... I would really like to get this working. I followed all the instructions but am getting this error
Fatal error: Call to undefined function: getcustomfield() in /home/virtual/site71/fst/var/www/html/blog/index.php on line 52
Any help would be appreciated |
Hmm... well, make sure that you followed this instruction step correctly.
Code: | In b2template.functions.php
Add this function:
#########################################
function getcustomfield($name){
global $tableposts,$id;
$sql = "SELECT ".$name." from ".$tableposts." where id = ".$id." LIMIT 1";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)){
$output = $row[$name];
}
$output = convert_bbcode(convert_smilies(stripslashes($output)));
echo $output;
}
######################################### |
That's the only likely reason that you're getting that error.
Candle wrote: | I installed it and all seems fine but when i put something in sya like mood and click the button it refreshs the page but nothing is there so not sure what is wrong ?
And I see nothing it being inputed in to the table in the database . |
Hmm...for debugging purposes try replacing this (lines 8-13 in b2fields.php):
Code: | $sql = "INSERT INTO `b2customfields` (`field_name`) VALUES ('".$_POST['newname']."')";
$result = mysql_query($sql);
$sql = "ALTER TABLE `".$tableposts."` ADD `".$_POST['newname']."` TEXT NOT NULL";
$result = mysql_query($sql);
field_list();
createfield_form(); |
with this:
Code: | $sql = "INSERT INTO `b2customfields` (`field_name`) VALUES ('".$_POST['newname']."')";
echo $sql."<br><br>";
$result = mysql_query($sql);
$sql = "ALTER TABLE `".$tableposts."` ADD `".$_POST['newname']."` TEXT NOT NULL";
echo $sql."<br><br>";
$result = mysql_query($sql);
field_list();
createfield_form(); |
And let me know what the SQL queries that are outputted are.
Has anyone actually gotten this working yet? Let me know if you have, I may have had a flaw in my instructions.[/quote] _________________ - Mystis
[url=tidakada.com/board/viewtopic.php?t=3375]b2customfields v2[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2sql[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2quotes[/url] |
|
Back to top |
|
 |
XYboi
Joined: 17 Feb 2003 Posts: 18 Location: Miami, FL.
|
Posted: Tue Mar 25, 2003 4:54 am Post subject: |
|
|
how exactly do u run an SQL query?
thanks for the hack.. this is something Ive been looking for, for quite some time. _________________ --
* Support the Site. Support the Boi. Visit XYboi.S-S.Org * |
|
Back to top |
|
 |
Candle
Joined: 23 Dec 2002 Posts: 547
|
Posted: Tue Mar 25, 2003 6:00 am Post subject: no error |
|
|
No error just no update showing anything to edit or add stuff in to .
Page stays the same and your error on your page was in the main page at your site . i took that error you see off of your page. _________________ My Game Forum
 |
|
Back to top |
|
 |
cukkoo
Joined: 25 Feb 2003 Posts: 17
|
Posted: Tue Mar 25, 2003 10:56 am Post subject: |
|
|
Yes I think that I have inserted that code properly - here is a copy of the b2template.functions.php
Code: |
<?php
/* new and improved ! now with more querystring stuff ! */
if (!isset($querystring_start)) {
$querystring_start = '?';
$querystring_equal = '=';
$querystring_separator = '&';
}
/* template functions... */
// @@@ These are template tags, you can edit them if you know what you're doing...
/***** About-the-blog tags *****/
/* Note: these tags go anywhere in the template */
function bloginfo($show='') {
$info = get_bloginfo($show);
$info = convert_bbcode($info);
$info = convert_gmcode($info);
$info = convert_smilies($info);
$info = apply_filters('bloginfo', $info);
echo convert_chars($info, 'html');
}
function bloginfo_rss($show='') {
$info = strip_tags(get_bloginfo($show));
echo convert_chars($info, 'unicode');
}
function bloginfo_unicode($show='') {
$info = get_bloginfo($show);
echo convert_chars($info, 'unicode');
}
function get_bloginfo($show='') {
global $siteurl, $blogfilename, $blogname, $blogdescription, $pathserver, $admin_email;
switch($show) {
case "url":
$output = $siteurl."/".$blogfilename;
break;
case "description":
$output = $blogdescription;
break;
case "rdf_url":
$output = $siteurl.'/b2rdf.php';
break;
case "rss_url":
$output = $siteurl.'/b2rss.php';
break;
case "rss2_url":
$output = $siteurl.'/b2rss2.php';
break;
case "pingback_url":
$output = $pathserver.'/xmlrpc.php';
break;
case "admin_email":
$output = $admin_email;
break;
case "name":
default:
$output = $blogname;
break;
}
return($output);
}
function single_post_title($prefix = '', $display = 1) {
global $p;
if (intval($p)) {
$post_data = get_postdata($p);
$title = $post_data['Title'];
$title = apply_filters('single_post_title', $title);
if ($display) {
echo $prefix.strip_tags(stripslashes($title));
} else {
return strip_tags(stripslashes($title));
}
}
}
function single_cat_title($prefix = '', $display = 1 ) {
global $cat;
if(!empty($cat) && !(strtoupper($cat) == 'ALL')) {
$my_cat_name = get_the_category_by_ID($cat);
if(!empty($my_cat_name)) {
if ($display)
echo $prefix.strip_tags(stripslashes($my_cat_name));
else
return strip_tags(stripslashes($my_cat_name));
}
}
}
function single_month_title($prefix = '', $display = 1 ) {
global $m, $month;
if(!empty($m)) {
$my_year = substr($m,0,4);
$my_month = $month[substr($m,4,2)];
if ($display)
echo $prefix.$my_month.$prefix.$my_year;
else
return $m;
}
}
/***** // About-the-blog tags *****/
/***** Date/Time tags *****/
function the_date($d='', $before='', $after='', $echo = 1) {
global $id, $postdata, $day, $previousday,$dateformat,$newday;
$the_date = '';
if ($day != $previousday) {
$the_date .= $before;
if ($d=='') {
$the_date .= mysql2date($dateformat, $postdata['Date']);
} else {
$the_date .= mysql2date($d, $postdata['Date']);
}
$the_date .= $after;
$previousday = $day;
}
$the_date = apply_filters('the_date', $the_date);
if ($echo) {
echo $the_date;
} else {
return $the_date;
}
}
function the_time($d='', $echo = 1) {
global $id,$postdata,$timeformat;
if ($d=='') {
$the_time = mysql2date($timeformat, $postdata['Date']);
} else {
$the_time = mysql2date($d, $postdata['Date']);
}
$the_time = apply_filters('the_time', $the_time);
if ($echo) {
echo $the_time;
} else {
return $the_time;
}
}
function the_weekday() {
global $weekday,$id,$postdata;
$the_weekday = $weekday[mysql2date('w', $postdata['Date'])];
$the_weekday = apply_filters('the_weekday', $the_weekday);
echo $the_weekday;
}
function the_weekday_date($before='',$after='') {
global $weekday,$id,$postdata,$day,$previousweekday;
$the_weekday_date = '';
if ($day != $previousweekday) {
$the_weekday_date .= $before;
$the_weekday_date .= $weekday[mysql2date('w', $postdata['Date'])];
$the_weekday_date .= $after;
$previousweekday = $day;
}
$the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date);
echo $the_weekday_date;
}
/***** // Date/Time tags *****/
/***** Author tags *****/
function the_author() {
global $id,$authordata;
$i = $authordata['user_idmode'];
if ($i == 'nickname') echo $authordata['user_nickname'];
if ($i == 'login') echo $authordata['user_login'];
if ($i == 'firstname') echo $authordata['user_firstname'];
if ($i == 'lastname') echo $authordata['user_lastname'];
if ($i == 'namefl') echo $authordata['user_firstname'].' '.$authordata['user_lastname'];
if ($i == 'namelf') echo $authordata['user_lastname'].' '.$authordata['user_firstname'];
if (!$i) echo $authordata['user_nickname'];
}
function the_author_login() {
global $id,$authordata; echo $authordata['user_login'];
}
function the_author_firstname() {
global $id,$authordata; echo $authordata['user_firstname'];
}
function the_author_lastname() {
global $id,$authordata; echo $authordata['user_lastname'];
}
function the_author_nickname() {
global $id,$authordata; echo $authordata['user_nickname'];
}
function the_author_ID() {
global $id,$authordata; echo $authordata['ID'];
}
function the_author_email() {
global $id,$authordata; echo antispambot($authordata['user_email']);
}
function the_author_url() {
global $id,$authordata; echo $authordata['user_url'];
}
function the_author_icq() {
global $id,$authordata; echo $authordata['user_icq'];
}
function the_author_aim() {
global $id,$authordata; echo str_replace(' ', '+', $authordata['user_aim']);
}
function the_author_yim() {
global $id,$authordata; echo $authordata['user_yim'];
}
function the_author_msn() {
global $id,$authordata; echo $authordata['user_msn'];
}
function the_author_posts() {
global $id,$postdata; $posts=get_usernumposts($postdata['Author_ID']); echo $posts;
}
/***** // Author tags *****/
/***** Post tags *****/
function the_ID() {
global $id;
echo $id;
}
function the_title($before='',$after='') {
$title = get_the_title();
$title = convert_bbcode($title);
$title = convert_gmcode($title);
$title = convert_smilies($title);
$title = apply_filters('the_title', $title);
if ($title) {
echo convert_chars($before.$title.$after, 'html');
}
}
function the_title_rss() {
$title = get_the_title();
$title = convert_bbcode($title);
$title = convert_gmcode($title);
$title = strip_tags($title);
if (trim($title)) {
echo convert_chars($title, 'unicode');
}
}
function the_title_unicode($before='',$after='') {
$title = get_the_title();
$title = convert_bbcode($title);
$title = convert_gmcode($title);
$title = apply_filters('the_title_unicode', $title);
if (trim($title)) {
echo convert_chars($before.$title.$after, 'unicode');
}
}
function get_the_title() {
global $id,$postdata;
$output = stripslashes($postdata['Title']);
$output = apply_filters('the_title', $output);
return($output);
}
function the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') {
$content = get_the_content($more_link_text,$stripteaser,$more_file);
$content = convert_bbcode($content);
$content = convert_gmcode($content);
$content = convert_smilies($content);
$content = convert_chars($content, 'html');
$content = apply_filters('the_content', $content);
echo $content;
}
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
$content = get_the_content($more_link_text,$stripteaser,$more_file);
$content = convert_bbcode($content);
$content = convert_gmcode($content);
$content = convert_chars($content, 'unicode');
if ($cut && !$encode_html) {
$encode_html = 2;
}
if ($encode_html == 1) {
$content = htmlspecialchars($content);
$cut = 0;
} elseif ($encode_html == 0) {
$content = make_url_footnote($content);
} elseif ($encode_html == 2) {
$content = strip_tags($content);
}
if ($cut) {
$blah = explode(' ', $content);
if (count($blah) > $cut) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
echo $content;
}
function the_content_unicode($more_link_text='(more...)', $stripteaser=0, $more_file='') {
$content = get_the_content($more_link_text,$stripteaser,$more_file);
$content = convert_bbcode($content);
$content = convert_gmcode($content);
$content = convert_smilies($content);
$content = convert_chars($content, 'unicode');
$content = apply_filters('the_content_unicode', $content);
echo $content;
}
function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') {
global $id,$postdata,$more,$c,$withcomments,$page,$pages,$multipage,$numpages;
global $HTTP_SERVER_VARS, $preview;
global $querystring_start, $querystring_equal, $querystring_separator;
$output = '';
if ($more_file != '') {
$file=$more_file;
} else {
$file=$HTTP_SERVER_VARS['PHP_SELF'];
}
$content=$pages[$page-1];
$content=explode('<!--more-->', $content);
if ((preg_match('/<!--noteaser-->/', $postdata['Content']) && ((!$multipage) || ($page==1))))
$stripteaser=1;
$teaser=$content[0];
if (($more) && ($stripteaser))
$teaser='';
$output .= $teaser;
if (count($content)>1) {
if ($more) {
$output .= '<a name="more'.$id.'"></a>'.$content[1];
} else {
$output .= ' <a href="'.$file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'more'.$querystring_equal.'1#more'.$id.'">'.$more_link_text.'</a>';
}
}
if ($preview) { // preview fix for javascript bug with foreign languages
$output = preg_replace('/\%u([0-9A-F]{4,4})/e', "''.base_convert('\\1',16,10).';'", $output);
}
return($output);
}
function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') {
global $id,$page,$numpages,$multipage,$more;
global $blogfilename;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($more_file != '') {
$file = $more_file;
} else {
$file = $blogfilename;
}
if (($multipage)) { // && ($more)) {
echo $before;
if ($next_or_number=='number') {
for ($i = 1; $i < ($numpages+1); $i = $i + 1) {
$j=str_replace('%',"$i",$pagelink);
echo " ";
if (($i != $page) || ((!$more) && ($page==1)))
echo '<a href="'.$file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'page'.$querystring_equal.$i.'">';
echo $j;
if (($i != $page) || ((!$more) && ($page==1)))
echo '</a>';
}
} else {
$i=$page-1;
if ($i)
echo ' <a href="'.$file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'page'.$querystring_equal.$i.'">'.$previouspagelink.'</a>';
$i=$page+1;
if ($i<=$numpages)
echo ' <a href="'.$file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'page'.$querystring_equal.$i.'">'.$nextpagelink.'</a>';
}
echo $after;
}
}
function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
global $tableposts, $id, $postdata, $siteurl, $blogfilename, $querycount;
global $p, $posts, $posts_per_page, $s;
global $querystring_start, $querystring_equal, $querystring_separator;
if(($p) || ($posts_per_page==1)) {
$current_post_date = $postdata['Date'];
$current_category = $postdata['Category'];
$sqlcat = '';
if ($in_same_cat != 'no') {
$sqlcat = " AND post_category='$current_category' ";
}
$sql_exclude_cats = '';
if (!empty($excluded_categories)) {
$blah = explode('and', $excluded_categories);
foreach($blah as $category) {
$category = intval($category);
$sql_exclude_cats .= " AND post_category != $category";
}
}
$limitprev--;
$sql = "SELECT ID,post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_category > 0 $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev,1";
$query = @mysql_query($sql);
$querycount++;
if (($query) && (mysql_num_rows($query))) {
$p_info = mysql_fetch_object($query);
$p_title = $p_info->post_title;
$p_id = $p_info->ID;
$string = '<a href="'.$blogfilename.$querystring_start.'p'.$querystring_equal.$p_id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'c'.$querystring_equal.'1">'.$previous;
if (!($title!='yes')) {
$string .= stripslashes($p_title);
}
$string .= '</a>';
$format = str_replace('%',$string,$format);
echo $format;
}
}
}
function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
global $tableposts, $p, $posts, $id, $postdata, $siteurl, $blogfilename, $querycount;
global $time_difference;
global $querystring_start, $querystring_equal, $querystring_separator;
if(($p) || ($posts==1)) {
$current_post_date = $postdata['Date'];
$current_category = $postdata['Category'];
$sqlcat = '';
if ($in_same_cat != 'no') {
$sqlcat = " AND post_category='$current_category' ";
}
$sql_exclude_cats = '';
if (!empty($excluded_categories)) {
$blah = explode('and', $excluded_categories);
foreach($blah as $category) {
$category = intval($category);
$sql_exclude_cats .= " AND post_category != $category";
}
}
$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
$limitnext--;
$sql = "SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_category > 0 $sqlcat $sql_exclude_cats ORDER BY post_date ASC LIMIT $limitnext,1";
$query = @mysql_query($sql);
$querycount++;
if (($query) && (mysql_num_rows($query))) {
$p_info = mysql_fetch_object($query);
$p_title = $p_info->post_title;
$p_id = $p_info->ID;
$string = '<a href="'.$blogfilename.$querystring_start.'p'.$querystring_equal.$p_id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'c'.$querystring_equal.'1">'.$next;
if ($title=='yes') {
$string .= stripslashes($p_title);
}
$string .= '</a>';
$format = str_replace('%',$string,$format);
echo $format;
}
}
}
function next_posts($max_page = 0) { // original by cfactor at cooltux.org
global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show;
global $querystring_start, $querystring_equal, $querystring_separator;
if (empty($p) && ($what_to_show == 'paged')) {
$qstr = $HTTP_SERVER_VARS['QUERY_STRING'];
if (!empty($qstr)) {
$qstr = preg_replace("/&paged=\d{0,}/","",$qstr);
$qstr = preg_replace("/paged=\d{0,}/","",$qstr);
} elseif ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '',
$HTTP_SERVER_VARS['REQUEST_URI']) ) {
$qstr = preg_replace("/^\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}/", "", $qstr);
$qstr = preg_replace("/\/$/", "", $qstr);
}
if (!$paged) $paged = 1;
$nextpage = intval($paged) + 1;
if (!$max_page || $max_page >= $nextpage) {
echo $siteurl.'/'.$blogfilename.$querystring_start.
($qstr == '' ? '' : $qstr.$querystring_separator) .
'paged'.$querystring_equal.$nextpage;
}
}
}
function next_posts_link($label='Next Page >>', $max_page=0) {
global $p, $paged, $result, $request, $posts_per_page, $what_to_show;
if ($what_to_show == 'paged') {
if (!$max_page) {
$nxt_request = $request;
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
$nxt_request = substr($request, 0, $pos);
}
$nxt_result = mysql_query($nxt_request);
$numposts = mysql_num_rows($nxt_result);
$max_page = intval($numposts / $posts_per_page) +1;
}
if (!$paged) $paged = 1;
$nextpage = intval($paged) + 1;
if (empty($p) && (empty($paged) || $nextpage <= $max_page)) {
echo '<a href="';
echo next_posts($max_page);
echo '">'. htmlspecialchars($label) .'</a>';
}
}
}
function previous_posts() { // original by cfactor at cooltux.org
global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show;
global $querystring_start, $querystring_equal, $querystring_separator;
if (empty($p) && ($what_to_show == 'paged')) {
$qstr = $HTTP_SERVER_VARS['QUERY_STRING'];
if (!empty($qstr)) {
$qstr = preg_replace("/&paged=\d{0,}/","",$qstr);
$qstr = preg_replace("/paged=\d{0,}/","",$qstr);
} elseif ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '',
$HTTP_SERVER_VARS['REQUEST_URI']) ) {
$qstr = preg_replace("/^\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}/", "", $qstr);
$qstr = preg_replace("/\/$/", "", $qstr);
}
$nextpage = intval($paged) - 1;
if ($nextpage < 1) $nextpage = 1;
echo $siteurl.'/'.$blogfilename.$querystring_start.
($qstr == '' ? '' : $qstr.$querystring_separator) .
'paged'.$querystring_equal.$nextpage;
}
}
function previous_posts_link($label='<< Previous Page') {
global $p, $paged, $what_to_show;
if (empty($p) && ($paged > 1) && ($what_to_show == 'paged')) {
echo '<a href="';
echo previous_posts();
echo '">'. htmlspecialchars($label) .'</a>';
}
}
function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Next Page >>') {
global $p, $what_to_show, $request, $posts_per_page;
if (empty($p) && ($what_to_show == 'paged')) {
$nxt_request = $request;
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
$nxt_request = substr($request, 0, $pos);
}
$nxt_result = mysql_query($nxt_request);
$numposts = mysql_num_rows($nxt_result);
$max_page = intval($numposts / $posts_per_page) +1;
if ($max_page > 1) {
previous_posts_link($prelabel);
echo htmlspecialchars($sep);
next_posts_link($nxtlabel, $max_page);
}
}
}
/***** // Post tags *****/
/***** Category tags *****/
function the_category() {
$category = get_the_category();
$category = apply_filters('the_category', $category);
echo convert_chars($category, 'html');
}
function the_category_rss() {
echo convert_chars(strip_tags(get_the_category()), 'xml');
}
function the_category_unicode() {
$category = get_the_category();
$category = apply_filters('the_category_unicode', $category);
echo convert_chars($category, 'unicode');
}
function get_the_category() {
global $id,$postdata,$tablecategories,$querycount,$cache_categories,$use_cache;
$cat_ID = $postdata['Category'];
if ((empty($cache_categories[$cat_ID])) OR (!$use_cache)) {
$query="SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'";
$result=mysql_query($query);
$querycount++;
$myrow = mysql_fetch_array($result);
$cat_name = $myrow[0];
$cache_categories[$cat_ID] = $cat_name;
} else {
$cat_name = $cache_categories[$cat_ID];
}
return(stripslashes($cat_name));
}
function get_the_category_by_ID($cat_ID) {
global $id,$tablecategories,$querycount,$cache_categories,$use_cache;
if ((!$cache_categories[$cat_ID]) OR (!$use_cache)) {
$query="SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'";
$result=mysql_query($query);
$querycount++;
$myrow = mysql_fetch_array($result);
$cat_name = $myrow[0];
$cache_categories[$cat_ID] = $cat_name;
} else {
$cat_name = $cache_categories[$cat_ID];
}
return(stripslashes($cat_name));
}
function the_category_ID() {
global $id,$postdata; echo $postdata['Category'];
}
function the_category_head($before='',$after='') {
global $id, $postdata, $currentcat, $previouscat,$dateformat,$newday;
$currentcat = $postdata['Category'];
if ($currentcat != $previouscat) {
echo $before;
echo get_the_category_by_ID($currentcat);
echo $after;
$previouscat = $currentcat;
}
}
// out of the b2 loop
function dropdown_cats($optionall = 1, $all = 'All') {
global $cat, $tablecategories, $querycount;
$query="SELECT * FROM $tablecategories";
$result=mysql_query($query);
$querycount++;
echo "<select name=\"cat\" class=\"postform\">\n";
if (intval($optionall) == 1) {
echo "\t<option value=\"all\">$all</option>\n";
}
while($row = mysql_fetch_object($result)) {
echo "\t<option value=\"".$row->cat_ID."\"";
if ($row->cat_ID == $cat)
echo ' selected="selected"';
echo '>'.stripslashes($row->cat_name)."</option>\n";
}
echo "</select>\n";
}
// out of the b2 loop
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = 'blah') {
global $tablecategories,$querycount;
global $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
$file = ($file == 'blah') ? $pagenow : $file;
$sort_column = 'cat_'.$sort_column;
$query="SELECT * FROM $tablecategories WHERE cat_ID > 0 ORDER BY $sort_column $sort_order";
$result=mysql_query($query);
$querycount++;
if (intval($optionall) == 1) {
$all = apply_filters('list_cats', $all);
echo "\t<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a><br />\n";
}
while($row = mysql_fetch_object($result)) {
$cat_name = $row->cat_name;
$cat_name = apply_filters('list_cats', $cat_name);
echo "\t<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.$row->cat_ID.'">';
echo stripslashes($cat_name)."</a><br />\n";
}
}
/***** // Category tags *****/
/***** <Link> tags *****/
/***** // <Link> tags *****/
/***** Comment tags *****/
// generic comments/trackbacks/pingbacks numbering
function generic_ctp_number($post_id, $mode = 'comments') {
global $postdata, $tablecomments, $querycount, $cache_ctp_number, $use_cache;
if (!isset($cache_ctp_number[$post_id]) || (!$use_cache)) {
$post_id = intval($post_id);
$query = "SELECT * FROM $tablecomments WHERE comment_post_ID = $post_id";
$result = mysql_query($query) or die('SQL query: '.$query.'<br />MySQL Error: '.mysql_error());
$querycount++;
$ctp_number = array();
while($row = mysql_fetch_object($result)) {
if (substr($row->comment_content, 0, 13) == '<trackback />') {
$ctp_number['trackbacks']++;
} elseif (substr($row->comment_content, 0, 12) == '<pingback />') {
$ctp_number['pingbacks']++;
} else {
$ctp_number['comments']++;
}
$ctp_number['ctp']++;
}
$cache_ctp_number[$post_id] = $ctp_number;
} else {
$ctp_number = $cache_ctp_number[$post_id];
}
if (($mode != 'comments') && ($mode != 'trackbacks') && ($mode != 'pingbacks') && ($mode != 'ctp')) {
$mode = 'ctp';
}
return $ctp_number[$mode];
}
function comments_number($zero='no comment', $one='1 comment', $more='% comments') {
// original hack by [email protected]
global $id,$postdata,$tablecomments,$c,$querycount,$cache_commentsnumber,$use_cache;
$number = generic_ctp_number($id, 'comments');
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {
$blah = $one;
} elseif ($number > 1) {
$n = $number;
$more=str_replace('%', $n, $more);
$blah = $more;
}
echo $blah;
}
function comments_link($file='') {
global $id,$pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file == '') $file = $pagenow;
if ($file == '/') $file = '';
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'c'.$querystring_equal.'1#comments';
}
function comments_popup_script($width=400, $height=400, $file='b2commentspopup.php', $trackbackfile='b2trackbackpopup.php', $pingbackfile='b2pingbackspopup.php') {
global $b2commentspopupfile, $b2trackbackpopupfile, $b2pingbackpopupfile, $b2commentsjavascript;
$b2commentspopupfile = $file;
$b2trackbackpopupfile = $trackbackfile;
$b2pingbackpopupfile = $pingbackfile;
$b2commentsjavascript = 1;
$javascript = "<script language=\"javascript\" type=\"text/javascript\">\n<!--\nfunction b2open (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n//-->\n</script>\n";
echo $javascript;
}
function comments_popup_link($zero='no comment', $one='1 comment', $more='% comments', $CSSclass='') {
global $id, $b2commentspopupfile, $b2commentsjavascript;
global $querystring_start, $querystring_equal, $querystring_separator;
echo '<a href="';
if ($b2commentsjavascript) {
echo $b2commentspopupfile.'?p='.$id.'&c=1';
echo '" onclick="b2open(this.href); return false"';
} else {
// if comments_popup_script() is not in the template, display simple comment link
comments_link();
echo '"';
}
if (!empty($CSSclass)) {
echo ' class="'.$CSSclass.'"';
}
echo '>';
comments_number($zero, $one, $more);
echo '</a>';
}
function comment_ID() {
global $commentdata; echo $commentdata['comment_ID'];
}
function comment_author() {
global $commentdata; echo stripslashes($commentdata['comment_author']);
}
function comment_author_email() {
global $commentdata; echo antispambot(stripslashes($commentdata['comment_author_email']));
}
function comment_author_url() {
global $commentdata;
$url = trim(stripslashes($commentdata['comment_author_url']));
$url = (!stristr($url, '://')) ? 'http://'.$url : $url;
// convert & into &
$url = preg_replace('#&([^amp\;])#is', '&$1', $url);
if ($url != 'http://url') {
echo $url;
}
}
function comment_author_email_link($linktext='', $before='', $after='') {
global $commentdata;
$email=$commentdata['comment_author_email'];
if ((!empty($email)) && ($email != '@')) {
$display = ($linktext != '') ? $linktext : antispambot(stripslashes($email));
echo $before;
echo '<a href="mailto:'.antispambot(stripslashes($email)).'">'.$display.'</a>';
echo $after;
}
}
function comment_author_url_link($linktext='', $before='', $after='') {
global $commentdata;
$url = trim(stripslashes($commentdata['comment_author_url']));
$url = preg_replace('#&([^amp\;])#is', '&$1', $url);
$url = (!stristr($url, '://')) ? 'http://'.$url : $url;
if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) {
$display = ($linktext != '') ? $linktext : stripslashes($url);
echo $before;
echo '<a href="'.stripslashes($url).'" target="_blank">'.$display.'</a>';
echo $after;
}
}
function comment_author_IP() {
global $commentdata; echo stripslashes($commentdata['comment_author_IP']);
}
function comment_text() {
global $commentdata;
$comment = stripslashes($commentdata['comment_content']);
$comment = str_replace('<trackback />', '', $comment);
$comment = str_replace('<pingback />', '', $comment);
$comment = convert_chars($comment);
$comment = convert_bbcode($comment);
$comment = convert_gmcode($comment);
$comment = convert_smilies($comment);
$comment = make_clickable($comment);
$comment = balanceTags($comment);
$comment = apply_filters('comment_text', $comment);
echo $comment;
}
function comment_date($d='') {
global $commentdata,$dateformat;
if ($d == '') {
echo mysql2date($dateformat, $commentdata['comment_date']);
} else {
echo mysql2date($d, $commentdata['comment_date']);
}
}
function comment_time($d='') {
global $commentdata,$timeformat;
if ($d == '') {
echo mysql2date($timeformat, $commentdata['comment_date']);
} else {
echo mysql2date($d, $commentdata['comment_date']);
}
}
/***** // Comment tags *****/
/***** TrackBack tags *****/
function trackback_url($display = 1) {
global $pathserver, $id;
$tb_url = $pathserver.'/b2trackback.php/'.$id;
if ($display) {
echo $tb_url;
} else {
return $tb_url;
}
}
function trackback_number($zero='no trackback', $one='1 trackback', $more='% trackbacks') {
global $id, $tablecomments, $tb, $querycount, $cache_trackbacknumber, $use_cache;
$number = generic_ctp_number($id, 'trackbacks');
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {
$blah = $one;
} elseif ($number > 1) {
$n = $number;
$more=str_replace('%', $n, $more);
$blah = $more;
}
echo $blah;
}
function trackback_link($file='') {
global $id,$pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file == '') $file = $pagenow;
if ($file == '/') $file = '';
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'tb'.$querystring_equal.'1#trackback';
}
function trackback_popup_link($zero='no trackback', $one='1 trackback', $more='% trackbacks', $CSSclass='') {
global $id, $b2trackbackpopupfile, $b2commentsjavascript;
global $querystring_start, $querystring_equal, $querystring_separator;
echo '<a href="';
if ($b2commentsjavascript) {
echo $b2trackbackpopupfile.'?p='.$id.'&tb=1';
echo '" onclick="b2open(this.href); return false"';
} else {
// if comments_popup_script() is not in the template, display simple comment link
trackback_link();
echo '"';
}
if (!empty($CSSclass)) {
echo ' class="'.$CSSclass.'"';
}
echo '>';
trackback_number($zero, $one, $more);
echo '</a>';
}
function trackback_rdf($timezone=0) {
global $pathserver, $id, $HTTP_SERVER_VARS;
if (!stristr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'W3C_Validator')) {
echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" '."\n";
echo ' xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n";
echo ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">'."\n";
echo '<rdf:Description'."\n";
echo ' rdf:about="';
permalink_single();
echo '"'."\n";
echo ' dc:identifier="';
permalink_single();
echo '"'."\n";
echo ' dc:title="'.addslashes(get_the_title()).'"'."\n";
echo ' trackback:ping="'.trackback_url(0).'"'."\n";
echo '</rdf:RDF>';
}
}
/***** // TrackBack tags *****/
/***** PingBack tags *****/
function pingback_number($zero='no pingback', $one='1 pingback', $more='% pingbacks') {
global $id, $tablecomments, $tb, $querycount, $cache_pingbacknumber, $use_cache;
$number = generic_ctp_number($id, 'pingbacks');
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {
$blah = $one;
} elseif ($number > 1) {
$n = $number;
$more=str_replace('%', $n, $more);
$blah = $more;
}
echo $blah;
}
function pingback_link($file='') {
global $id,$pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file == '') $file = $pagenow;
if ($file == '/') $file = '';
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'pb'.$querystring_equal.'1#pingbacks';
}
function pingback_popup_link($zero='no pingback', $one='1 pingback', $more='% pingbacks', $CSSclass='') {
global $id, $b2pingbackpopupfile, $b2commentsjavascript;
global $querystring_start, $querystring_equal, $querystring_separator;
echo '<a href="';
if ($b2commentsjavascript) {
echo $b2pingbackpopupfile.'?p='.$id.'&pb=1';
echo '" onclick="b2open(this.href); return false"';
} else {
// if comments_popup_script() is not in the template, display simple comment link
pingback_link();
echo '"';
}
if (!empty($CSSclass)) {
echo ' class="'.$CSSclass.'"';
}
echo '>';
pingback_number($zero, $one, $more);
echo '</a>';
}
/***** // PingBack tags *****/
/***** Permalink tags *****/
function permalink_anchor($mode = 'id') {
global $id, $postdata;
switch(strtolower($mode)) {
case 'title':
$title = preg_replace('/[^a-zA-Z0-9_\.-]/', '_', $postdata['Title']);
echo '<a name="'.$title.'"></a>';
break;
case 'id':
default:
echo '<a name="'.$id.'"></a>';
break;
}
}
function permalink_link($file='', $mode = 'id') {
global $id, $postdata, $pagenow, $cacheweekly;
global $querystring_start, $querystring_equal, $querystring_separator;
$file = ($file=='') ? $pagenow : $file;
switch(strtolower($mode)) {
case 'title':
$title = preg_replace('/[^a-zA-Z0-9_\.-]/', '_', $postdata['Title']);
$anchor = $title;
break;
case 'id':
default:
$anchor = $id;
break;
}
$archive_mode = get_settings('archive_mode');
switch($archive_mode) {
case 'daily':
echo $file.$querystring_start.'m'.$querystring_equal.substr($postdata['Date'],0,4).substr($postdata['Date'],5,2).substr($postdata['Date'],8,2).'#'.$anchor;
break;
case 'monthly':
echo $file.$querystring_start.'m'.$querystring_equal.substr($postdata['Date'],0,4).substr($postdata['Date'],5,2).'#'.$anchor;
break;
case 'weekly':
if((!isset($cacheweekly)) || (empty($cacheweekly[$postdata['Date']]))) {
$sql = "SELECT WEEK('".$postdata['Date']."')";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
$cacheweekly[$postdata['Date']] = $row[0];
}
echo $file.$querystring_start.'m'.$querystring_equal.substr($postdata['Date'],0,4).$querystring_separator.'w'.$querystring_equal.$cacheweekly[$postdata['Date']].'#'.$anchor;
break;
case 'postbypost':
echo $file.$querystring_start.'p'.$querystring_equal.$id;
break;
}
}
function permalink_single($file='') {
global $id,$postdata,$pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file=='')
$file=$pagenow;
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'c'.$querystring_equal.'1';
}
function permalink_single_rss($file='b2rss.xml') {
global $id,$postdata,$pagenow,$siteurl,$blogfilename;
global $querystring_start, $querystring_equal, $querystring_separator;
echo $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'c'.$querystring_equal.'1';
}
/***** // Permalink tags *****/
// @@@ These aren't template tags, do not edit them
function start_b2() {
global $row, $id, $postdata, $authordata, $day, $preview, $page, $pages, $multipage, $more, $numpages;
global $preview_userid,$preview_date,$preview_content,$preview_title,$preview_category,$preview_notify,$preview_make_clickable,$preview_autobr;
global $pagenow;
global $HTTP_GET_VARS;
if (!$preview) {
$id = $row->ID;
$postdata=get_postdata2($id);
} else {
$id = 0;
$postdata = array (
'ID' => 0,
'Author_ID' => $HTTP_GET_VARS['preview_userid'],
'Date' => $HTTP_GET_VARS['preview_date'],
'Content' => $HTTP_GET_VARS['preview_content'],
'Title' => $HTTP_GET_VARS['preview_title'],
'Category' => $HTTP_GET_VARS['preview_category'],
'Notify' => 1,
'Clickable' => 1,
'Karma' => 0 // this isn't used yet
);
if (!empty($HTTP_GET_VARS['preview_autobr'])) {
$postdata['Content'] = autobrize($postdata['Content']);
}
}
$authordata = get_userdata($postdata['Author_ID']);
$day = mysql2date('d.m.y',$postdata['Date']);
$currentmonth = mysql2date('m',$postdata['Date']);
$numpages=1;
if (!$page)
$page=1;
if (isset($p))
$more=1;
$content = $postdata['Content'];
if (preg_match('/<!--nextpage-->/', $postdata['Content'])) {
if ($page > 1)
$more=1;
$multipage=1;
$content=stripslashes($postdata['Content']);
$content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
$content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
$content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
$pages=explode('<!--nextpage-->', $content);
$numpages=count($pages);
} else {
$pages[0]=stripslashes($postdata['Content']);
$multipage=0;
}
return true;
}
function is_new_day() {
global $day, $previousday;
if ($day != $previousday) {
return(1);
} else {
return(0);
}
}
function apply_filters($tag, $string) {
global $b2_filter;
if (isset($b2_filter['all'])) {
$b2_filter['all'] = (is_string($b2_filter['all'])) ? array($b2_filter['all']) : $b2_filter['all'];
$b2_filter[$tag] = array_merge($b2_filter['all'], $b2_filter[$tag]);
$b2_filter[$tag] = array_unique($b2_filter[$tag]);
}
if (isset($b2_filter[$tag])) {
$b2_filter[$tags] = (is_string($b2_filter[$tag])) ? array($b2_filter[$tag]) : $b2_filter[$tag];
$functions = $b2_filter[$tag];
foreach($functions as $function) {
$string = $function($string);
}
}
return $string;
}
function add_filter($tag, $function_to_add) {
global $b2_filter;
if (isset($b2_filter[$tag])) {
$functions = $b2_filter[$tag];
if (is_array($functions)) {
foreach($functions as $function) {
$new_functions[] = $function;
}
} elseif (is_string($functions)) {
$new_functions[] = $functions;
}
function getcustomfield($name){
global $tableposts,$id;
$sql = "SELECT ".$name." from ".$tableposts." where id = ".$id." LIMIT 1";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)){
$output = $row[$name];
}
$output = convert_bbcode(convert_smilies(stripslashes($output)));
echo $output;
}
/* this is commented out because it just makes PHP die silently
for no apparent reason
if (is_array($function_to_add)) {
foreach($function_to_add as $function) {
if (!in_array($function, $b2_filter[$tag])) {
$new_functions[] = $function;
}
}
} else */if (is_string($function_to_add)) {
if (!@in_array($function_to_add, $b2_filter[$tag])) {
$new_functions[] = $function_to_add;
}
}
$b2_filter[$tag] = $new_functions;
} else {
$b2_filter[$tag] = array($function_to_add);
}
return true;
}
include("latestcomments.php");
?>
|
And I am getting the error when I insert the function onto my index page. I have tried calling it outside and inside the b2 loop just in case that was a factor - but it happens whereever I put it. The error changes the line number accordingly
Any more ideas? |
|
Back to top |
|
 |
Eyevan
Joined: 16 Aug 2002 Posts: 18
|
Posted: Wed Mar 26, 2003 1:21 am Post subject: |
|
|
Wow!! What a GREAT and USEFUL hack! I'm going to download it in a few, and test it out in a few days (since I'm busy). Thank you for it, hope all goes well with it!  |
|
Back to top |
|
 |
Mystis
Joined: 02 Mar 2003 Posts: 74
|
Posted: Wed Mar 26, 2003 2:10 am Post subject: |
|
|
Cukkoo, I know your problem. Replace this:
Code: | function add_filter($tag, $function_to_add) {
global $b2_filter;
if (isset($b2_filter[$tag])) {
$functions = $b2_filter[$tag];
if (is_array($functions)) {
foreach($functions as $function) {
$new_functions[] = $function;
}
} elseif (is_string($functions)) {
$new_functions[] = $functions;
}
|
with this:
Code: | function add_filter($tag, $function_to_add) {
global $b2_filter;
if (isset($b2_filter[$tag])) {
$functions = $b2_filter[$tag];
if (is_array($functions)) {
foreach($functions as $function) {
$new_functions[] = $function;
}
} elseif (is_string($functions)) {
$new_functions[] = $functions;
}
}
}
|
When inserting my function, you apparently forgot to close two of the brackets. Should work now
Candle, I have no idea what your problem could be, please try my debugging steps that I gave you, I would like to see what queries PHP is trying to make. _________________ - Mystis
[url=tidakada.com/board/viewtopic.php?t=3375]b2customfields v2[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2sql[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2quotes[/url] |
|
Back to top |
|
 |
BluntedbyNature
Joined: 26 Mar 2003 Posts: 5 Location: New York
|
Posted: Wed Mar 26, 2003 8:10 am Post subject: |
|
|
ok i followed all the directions but i still got errors.
this is the error i get when i go to the b2edit.php.
Quote: |
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/bluntedb/bluntedbynature.com/b2-include/b2edit.form.php on line 125
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/bluntedb/bluntedbynature.com/b2-include/b2edit.form.php on line 125
|
this is like 125 of b2edit.form.php:
Code: |
while ($new_row = mysql_fetch_array($new_result)){
|
and this is all of my b2edit.form.php:
Code: |
<?php
echo $tabletop;
switch($action) {
case "post":
$submitbutton_text = "Blog this !";
$toprow_title = "New Post";
$form_action = "post";
$form_extra = "";
if ($use_pingback) {
$form_pingback = '<input type="checkbox" class="checkbox" name="post_pingback" value="1" checked="checked" tabindex="7" id="pingback" /><label for="pingback"> PingBack the URLs in this post</label><br />';
} else {
$form_pingback = '';
}
if ($use_trackback) {
$form_trackback = '<br /><br /><label for="trackback"><b>TrackBack</b> an URL:</label><br /><input type="text" name="trackback_url" style="width: 415px" id="trackback" />';
} else {
$form_trackback = '';
}
$colspan = 3;
break;
case "edit":
$submitbutton_text ="Edit this !";
$toprow_title = "Editing Post #".$postdata["ID"];
$form_action = "editpost";
$form_extra = "\" />\n<input type=\"hidden\" name=\"post_ID\" value=\"$post";
$colspan = 2;
$form_pingback = '<input type="hidden" name="post_pingback" value="0" />';
$form_trackback = '';
break;
case "editcomment":
$submitbutton_text ="Edit this !";
$toprow_title = "Editing Comment #".$commentdata["comment_ID"];
$form_action = "editedcomment";
$form_extra = "\" />\n<input type=\"hidden\" name=\"comment_ID\" value=\"$comment\" />\n<input type=\"hidden\" name=\"comment_post_ID\" value=\"".$commentdata["comment_post_ID"];
$colspan = 3;
$form_pingback = '<input type="hidden" name="post_pingback" value="0" />';
$form_trackback = '';
break;
}
?>
<form name="post" action="b2edit.php" method="POST">
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
<input type="hidden" name="action" value="<?php echo $form_action.$form_extra ?>" />
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td<?php
if ($action != "editcomment") {
// this is for everything but comment editing
?>>
<table height="60" align="left" cellpadding="0" cellspacing="0">
<td height="60" width="190">
<label for="title"><b>Title :</b></label><br />
<input type="text" name="post_title" size="20" tabindex="1" style="width: 170px;" value="<?php echo $edited_post_title; ?>" id="title" />
</td>
<td>
<label for="category"><b>Category :</b></label><br /><?php dropdown_categories(); ?>
</td>
</table>
<?php
} else {
// this is for comment editing
?> colspan="2"> </td>
</tr>
<tr>
<td>
<label for="name"><b>Name :</b></label><br />
<input type="text" name="newcomment_author" size="20" value="<?php echo format_to_edit($commentdata["comment_author"]) ?>" tabindex="1" id="name" /></td>
<td>
<label for="email"><b>E-mail :</b></label><br />
<input type="text" name="newcomment_author_email" size="20" value="<?php echo format_to_edit($commentdata["comment_author_email"]) ?>" tabindex="2" id="email" /></td>
<td>
<label for="URL"><b>URL :</b></label><br />
<input type="text" name="newcomment_author_url" size="20" value="<?php echo format_to_edit($commentdata["comment_author_url"]) ?>" tabindex="3" id="URL" />
<?php
}
?>
</td>
</tr>
<tr>
<td colspan="<?php echo $colspan; ?>">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<td valign="bottom">
<?php
if ($action != 'editcomment') {
echo '<label for="content"><b>Post :</b></label>';
} else {
echo '<br /><label for="content"><b>Comment :</b></label>';
}
?>
</td>
<td valign="bottom" align="right">
<?php if ($use_quicktags) include($b2inc.'/b2quicktags.php'); ?>
</td>
</table>
<textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual" id="content"><?php echo $content ?></textarea><br />
<input type="checkbox" class="checkbox" name="post_autobr" value="1" <?php
if ($autobr)
echo " checked" ?> tabindex="7" id="autobr" /><label for="autobr"> Auto-BR (converts line-breaks into <br /> tags)</label><br />
<?php
echo $form_pingback;
///////////////
$sql = "SELECT * from b2customfields";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$new_sql = "SELECT ".$row['field_name']." from $tableposts";
if($_GET['action'] == 'edit'){
$new_sql .= " where ID = ".$postdata["ID"];
}
$new_sql .= " LIMIT 1";
$new_result = mysql_query($new_sql);
while ($new_row = mysql_fetch_array($new_result)){
if($_GET['action'] == 'edit'){
echo "<b>".$row["field_name"]." :</b><br /><input name=\"".$row["field_name"]."\" value=\"".$new_row[0]."\"><br />";
}else{
echo "<b>".$row["field_name"]." :</b><br /><input name=\"".$row["field_name"]."\"><br />";
}
}
}
///////////////
?>
<?php if ($use_preview) { ?>
<input type="button" value="preview" onclick="preview(this.form);" class="search" tabindex="8" />
<?php } ?>
<input type="submit" name="submit" value="<?php echo $submitbutton_text ?>" class="search" style="font-weight: bold;" tabindex="5" />
<?php if ($use_spellchecker) { ?>
<!--<input type = "button" value = "Spell Check" onclick="var f=document.forms[0]; doSpell( 'en', f.post_content, '<?php echo $spellchecker_url ?>/sproxy.cgi', true);" class="search" tabindex="5" />-->
<input type="button" value="Spellcheck" onclick="DoSpell
('post','content','');" class="search" tabindex="9"/>
<?php } ?>
<?php if ( ($use_fileupload) && ($user_level >= $fileupload_minlevel) && ((ereg(" ".$user_login." ", $fileupload_allowedusers)) || (trim($fileupload_allowedusers)=="")) ) { ?>
<input type="button" value="upload a file/image" onclick="launchupload();" class="search" tabindex="10" />
<?php }
echo $form_trackback;
// if the level is 5+, allow user to edit the timestamp - not on 'new post' screen though
#if (($user_level > 4) && ($action != "post"))
if ($user_level > 4) {
touch_time(($action=="edit"));
}
?>
<script language="JavaScript">
<!--
// document.blog.post_content.focus();
//-->
</script>
</td>
</tr>
</table>
<?php echo $tablebottom ?>
</form>
|
can someone please help me, its driving me crazy. |
|
Back to top |
|
 |
Mystis
Joined: 02 Mar 2003 Posts: 74
|
Posted: Wed Mar 26, 2003 2:04 pm Post subject: |
|
|
Try replacing
Code: | while ($new_row = mysql_fetch_array($new_result)){ |
with
Code: | echo $new_sql."<br><br>";
while ($new_row = mysql_fetch_array($new_result)){ |
Something's wrong with your PHP query, also. _________________ - Mystis
[url=tidakada.com/board/viewtopic.php?t=3375]b2customfields v2[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2sql[/url] | [url=tidakada.com/board/viewtopic.php?t=3375]b2quotes[/url] |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2 © 2001, 2002 phpBB Group
|