vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   mysql query sometime return nothing in widgets (https://vborg.vbsupport.ru/showthread.php?t=279292)

dimiandre 02-28-2012 05:16 PM

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

kh99 02-28-2012 05:38 PM

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

dimiandre 02-28-2012 06:05 PM

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

dimiandre 03-01-2012 07:45 AM

up

please, the problem isn't solved

kh99 03-01-2012 11:31 AM

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.

dimiandre 03-05-2012 01:11 PM

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


All times are GMT. The time now is 06:06 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.02140 seconds
  • Memory Usage 1,723KB
  • 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
  • (3)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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