Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2002, 06:35 AM
werwer werwer is offline
 
Join Date: Apr 2002
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default troubles including a file

hi all,

I installed vb 2.5 and wanted to include the file last.php in the header of my vb page.
The last.php file connects to a different database on my site and retrievs the last 7 records on it. The last.php file looks like:

PHP Code:
<?   

$dbservertypee="mysql";  

$servernamee="localhost";  
$dbusernamee="name";  
$dbpasswordd="pass"; 

$dbnamee="db"; 

$urll="http://www.mysite.com";  
   
$topicss = "7";
   

     $db=mysql_connect($servername,$dbusername,$dbpassword);   
    mysql_select_db($dbname);   

  $query = "select * from table1 where catname='general'";   
  $queryresult = mysql_query($query);   
  $count = mysql_numrows($queryresult);  
      



  $query2 = "select * from table1 where catname='general' order by idnum desc limit 0,$topics";   
  $queryresult2 = mysql_query($query2);   
  $count2=mysql_numrows($queryresult2);   

if ($count2 == "0") {   
    echo "No records";  
}   

else {   

    while($row = mysql_fetch_object($queryresult2)) {  
          
        
    echo "<tr>
        <td width=\"20\" bgcolor=\"#F0F0F0\" align=\"center\">
        <img border=\"0\" src=\"http://www.mysite.com/photos/new.gif\" width=\"12\" height=\"10\"></td>
        
<td bgcolor=\"#F0F0F0\" align=\"right\"       onMouseOver=\"this.style.backgroundColor='#fffeff';this.style.cursor='hand';\" 
onMouseOut=\"this.style.backgroundColor='#F0F0F0';\" 
onClick=\"window.location.href='http://www.mysite.com/index.php?ct=general&md=details&id=$row->idnum'\">
<a href=\"$url/index.php?ct=general&md=details&id=$row->idnum\">$row->title</a></font></td>
        <td bgcolor=\"#F0F0F0\" width=\"80\">
        <p align=\"center\"><b><font size=\"2\">$row->field01</font></span></b></td>
      </tr>
";  


    }   

}   

mysql_close();   
?>
then I modyfy the phpinlude template as follows:

ob_start();
require("/path/last.php");
$last = ob_get_contents();
ob_end_clean();


this causes a seriuos problem in my forum and error msgs show up even before I put the &last variable in the header!!!

I have been trying to figure out what is going on, but failed to fix it.

Can anyone plz help me with this?! Any help is apreciated


thanx a lot
Reply With Quote
  #2  
Old 06-12-2002, 06:44 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try changing:
Code:
mysql_close();
To:
Code:
mysql_close($db);
Reply With Quote
  #3  
Old 06-12-2002, 08:08 AM
werwer werwer is offline
 
Join Date: Apr 2002
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I changed the code but still have the error msgs:

There seems to have been a slight problem with the forum database.
Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.

Database error in vBulletin 2.2.5:

Invalid SQL: SELECT * FROM usergroup WHERE usergroupid=6
mysql error:

mysql error number:

Date: Wednesday 12th of June 2002 04:27:44 AM
Script: http://www.mysite.com/vb

Referer:

Invalid SQL: UPDATE session SET lastactivity=1023870464,location='/vb/' WHERE sessionhash='050c4ae41a96bb961812d4f6fa57a7bd'
mysql error:

mysql error number:

Date: Wednesday 12th of June 2002 04:27:44 AM
Script: http://www.mysite.com/vb
Referer:

important to mention that I have included some other files and everything wen just fine, I think the problem with the above code.

any sugestions?
Reply With Quote
  #4  
Old 06-15-2002, 09:51 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why dont you run your query in global.php and instead of echoing the result right after the query, compile them with HTML code and assign all to a variable? Then you can insert the variable into header template.

I dont know why your code does not work but this method will work..
Reply With Quote
  #5  
Old 06-16-2002, 05:34 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Logician: Because he's using a different database, not vBulletin's.
Reply With Quote
  #6  
Old 06-16-2002, 06:51 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by FireFly
Logician: Because he's using a different database, not vBulletin's.
Does it matter? He has "mysql_connect" command in his code so he is supposed to connect any db he likes.

His problem may be forgetting to switch back to vb db inside his own code. If his code runs before all other vb code (in the very begining of global.php), I guess it will work..
Reply With Quote
  #7  
Old 06-16-2002, 07:19 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

He doesn't need to switch databases because vBulletin uses the $DB_site class, which specifies a connection ID for each query it issues. He can have 10 other connections open, it doesn't affect vB.
Reply With Quote
  #8  
Old 06-16-2002, 11:47 AM
werwer werwer is offline
 
Join Date: Apr 2002
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi all,

thanx Logician and Firefly,

So guys what is wrong? I'm sure it's a correct php code! do you have any idea why it's not working?

and how can I try the global.php solution proposed here?

thanx
Reply With Quote
  #9  
Old 06-16-2002, 05:07 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am not sure what your problem is but I know my solution will work (PROVIDED THAT your code is correct).

So what you have to is copy your code in the begining of file yourboard/global.php right AFTER line:
PHP Code:
<?php
Then you have to edit your code so that it will NOT echo anything or send any information to the user. So delete all your echo commands. Instead of echoing while the code is parsed, put the information inside a variable like:

$my_variable.=" <td width=\"20\" bgcolor=\"#F0F0F0\" align=\"center\">";


$my_variable.="<a href=\"$url/index.php?ct=general&md=details&id=$row->idnum\">$row->title</a></font></td>";

etc.

then put $my_variable inside any template you like (header for you)

If you get "headers already sent error" after modification it means that while editing your code you miss a part which echos a text or sends a piece of information to user, so make sure to remove that part and this will do the trick.
Reply With Quote
  #10  
Old 02-23-2003, 01:16 AM
Kenji Wing's Avatar
Kenji Wing Kenji Wing is offline
 
Join Date: Jul 2002
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

im trying to add my advertisement onto my forums

the code is only 2 lines

<?php

require "ad.php";

echo show_ad();

?>

at first i couldnt figure it out, and i just included the file in the main pages and it would give the header already recieved error

i tried adding it to the parsed php, but it has an echo in it, so that doesnt work

and when i tried what logician suggested above it gave me an db error.

is there any way to do this?
thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:12 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04405 seconds
  • Memory Usage 2,268KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete