The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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); 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 |
#2
|
|||
|
|||
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).
|
#3
|
|||
|
|||
changed in:
Code:
code removed edit, ok now it give me the error: Quote:
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 |
#4
|
|||
|
|||
up
please, the problem isn't solved |
#5
|
|||
|
|||
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. |
#6
|
|||
|
|||
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 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|