Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-28-2012, 06:16 PM
dimiandre dimiandre is offline
 
Join Date: Aug 2011
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default mysql query sometime return nothing in widgets

hi all,
i have added a new widget in my vbulletin cms. It's a "direct execution widget"

in it i have an Mysql query that return counts of some rows in my database..

but sometimes it returns nothing :S

i have tryed to run the query manually from "phpmyadmin" and the query itself works

this is the code of my widget:
Code:
require_once("mysql_vars.php");
$conn_widget = mysql_connect($host, $user, $pass); 
mysql_select_db($characters, $conn_widget); 
$result_wid = mysql_query("SELECT Count(Online) FROM `characters` WHERE `online` = 1", $conn_widget); 
$row_wid = mysql_fetch_array($result_wid); 
$online_wid = $row_wid["Count(Online)"]; 

if (!$sock = @fsockopen("127.0.01", 8085, $errno, $errstr, 30))
	$output = '<div class="status">Server Status: <FONT COLOR="#ff1f1f">OFF</FONT></div>'; 
else 
{
	$output = '<div class="status">Server Status: <FONT COLOR="#3acc3a">ON</FONT></div>';
 fclose($sock);
}

$output .= '<div class="status"> PG Online: <font color="#c9c9c9">';
$output .= $online_wid;
$output .= '</font></div>';

mysql_close($conn_widget);
sometimes "$online_wid" return nothing, some help ?

maybe cache problem ? :S

i have the same problem with similar widgets that should return data from an database..
thanks, i'm using vbulletin 4.1.10
Reply With Quote
  #2  
Old 02-28-2012, 06:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could try checking the return values of your mysql calls and in the case of an error, call mysql_error() to get the details. For instance, the example code on this page: http://us2.php.net/manual/en/function.mysql-connect.php shows how it could be done for mysql_connect (although you probably don't want to call die() in your widget).
Reply With Quote
  #3  
Old 02-28-2012, 07:05 PM
dimiandre dimiandre is offline
 
Join Date: Aug 2011
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

changed in:

Code:
code removed
and when problems happend it don't give me any error

edit, ok now it give me the error:
Quote:
Errore!: Access denied for user 'www'@'localhost' (using password: NO)
but obviously www it's not the same username of $user, it's the linux account where apache is running :S

edit2: if i try to put directly mysql account informations in mysql_connect($host, $user, $pass);
with "mysql_connect(127.0.0.1, "XXX", "XXX");"
sometimes it works, and sometimes the widget closes on himself like this screen:
http://img62.imageshack.us/img62/4190/immaginepmx.png
http://img828.imageshack.us/img828/2008/immagine2zw.png
Reply With Quote
  #4  
Old 03-01-2012, 08:45 AM
dimiandre dimiandre is offline
 
Join Date: Aug 2011
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

up

please, the problem isn't solved
Reply With Quote
  #5  
Old 03-01-2012, 12:31 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't see anything wrong (although I could be missing something of course), but if it's blank sometimes that seems to mean that something is causing an error, but only sometimes. I don't know why the query would sometimes return nothing.

Maybe try putting in a line like:

Code:
$output .= "1";  return;

start with it right under the reuqire once. If it always works (just shows "1"), then move it down a line and try again. When (if) you get to a point where the problem starts happening, you'll know it's caused by the line above.
Reply With Quote
  #6  
Old 03-05-2012, 02:11 PM
dimiandre dimiandre is offline
 
Join Date: Aug 2011
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hum i have solved using file() to grab data from an external php file instead of queryng the server

in this way all works perfect :P

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 07:39 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.04380 seconds
  • Memory Usage 2,205KB
  • 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
  • (3)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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