vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Help with a PHP file (https://vborg.vbsupport.ru/showthread.php?t=218209)

reotto 07-09-2009 04:57 AM

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)
       
?>


Dismounted 07-09-2009 06:03 AM

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).

reotto 07-10-2009 05:29 AM

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);
   
?>


Lynne 07-10-2009 03:24 PM

Where is the title coming from in this where statement:
PHP Code:

WHERE fbschedule.teamname '$style[title]' 

Nowhere have you defined it.

reotto 07-10-2009 05:28 PM

Quote:

Originally Posted by Lynne (Post 1846408)
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?

Lynne 07-10-2009 07:56 PM

Quote:

Originally Posted by reotto (Post 1846470)
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.

reotto 07-10-2009 09:02 PM

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?

Marco van Herwaarden 07-14-2009 11:08 AM

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


All times are GMT. The time now is 08:18 PM.

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.01179 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete