Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 07-09-2009, 04:57 AM
reotto reotto is offline
 
Join Date: Oct 2007
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with a PHP file

I have created the following PHP file, and I cannot get the results to return corrrectly. The echo command is returning a value of 1. I have run the query manually from the PHP console, and it returns the correct value. I figure I made a dumb mistake or I am not connecting the DB correctly becuase if I manually add the value at the end of the http line it shows correctly. Here is my code for the query:

PHP Code:
<?php

function fetch_team_schedule_id($schedule_id)

{
    
error_reporting(E_ALL & ~E_NOTICE);
        
    global 
$db$vba_options$vbulletin$vbphrase;

    
$scheduleid $db->query("
        SELECT teamid
           FROM " 
TABLE_PREFIX "fbschedule
           INNER JOIN " 
TABLE_PREFIX "style
           WHERE fbschedule.teamname=style.title AND fbschedule.teamname='Iowa Style'
        "
);
}  

    
$remote_schedule_file file_get_contents("http://www.website.com/schedule.php?id={$scheduleid['teamid']}"); 
    
$xml = new SimpleXMLElement($remote_schedule_file);
   
echo (print 
$remote_schedule_file)
       
?>
Reply With Quote
  #2  
Old 07-09-2009, 06:03 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you just run this file by itself? If so, it's not going to work, as no vBulletin functions will be available there (as global.php is not included).
Reply With Quote
  #3  
Old 07-10-2009, 05:29 AM
reotto reotto is offline
 
Join Date: Oct 2007
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK I basically started over did all of the code from scratch, but now I have a new problem. I created the file and tested it by directly accessing the file via http://mysite/file.php. It ran perfect. Now I have pulled it in as a module, and after updating the directory to global.php to make it work I figured I would be fine. Now, however, it appears that my query is no longer pulling the value needed.

FYI...I am using CMPS as my index page which is where I am trying to create the module. The code is below.
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''adv_index');

// ######################### REQUIRE BACK-END ############################
require_once(DIR '/global.php');

$vbulletin->input->clean_array_gpc('r', array(
    
'teamname'    => TYPE_STR,
    
'logolink'    => TYPE_STR,
    
'teamid'       => TYPE_STR,
    
'title'        => TYPE_STR,
));
    
    
$scheduleid $db->query_first_slave("
        SELECT *
        FROM " 
TABLE_PREFIX "fbschedule AS fbschedule
        INNER JOIN " 
TABLE_PREFIX "style
        WHERE fbschedule.teamname = '
$style[title]'
        "
);

echo 
'<link type="text/css" rel="stylesheet" href="fbschedule_style.css"/>';

$remote_schedule_file file_get_contents("http://www.site-with-PHP-xml.php?id={$scheduleid[teamid]}"); 
$xml = new SimpleXMLElement($remote_schedule_file);
   
?>
Reply With Quote
  #4  
Old 07-10-2009, 03:24 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where is the title coming from in this where statement:
PHP Code:
WHERE fbschedule.teamname '$style[title]' 
Nowhere have you defined it.
Reply With Quote
  #5  
Old 07-10-2009, 05:28 PM
reotto reotto is offline
 
Join Date: Oct 2007
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Where is the title coming from in this where statement:
PHP Code:
WHERE fbschedule.teamname '$style[title]' 
Nowhere have you defined it.
This would be the title of a style from the basic installation of vBulletin. If you look in the style table in vB, the title would be like "Default Style."

What do you mean defined?
Reply With Quote
  #6  
Old 07-10-2009, 07:56 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by reotto View Post
What do you mean defined?
Can you actually spit out that variable? If not, it isn't defined. By defined I mean that the code, somewhere, needs to say "style[title] = whatever' before you go and try to use it somewhere. If no code defines it prior to you trying to use it, then it isn't available for your use.
Reply With Quote
  #7  
Old 07-10-2009, 09:02 PM
reotto reotto is offline
 
Join Date: Oct 2007
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne,

I get what you are asking, and when I originally coded this page I forgot to add the value for "Default Style" into the table fbschedule so it wasn't returning anything. When I plugged in a dummy value it started working so I know that it a valid value in vB.

I can even run the native PHP when I access it here:
http://www.sportssoundoff.com/forums...s/schedule.php

When I try to insert it as a module to display it on my front page it dies.

FYI...when I originally thought about implementing this I wanted to use the AJAX GUI hack, and I know when I make a call to that page it displayed OK as well.

Any other ideas?
Reply With Quote
  #8  
Old 07-14-2009, 11:08 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PS A title can contain special charachters like ', and should be escaped before used in a query.
Reply With Quote
Reply

Thread Tools
Display Modes

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 02:25 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06444 seconds
  • Memory Usage 2,244KB
  • 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
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete