Jump to content

Query was empty help!!


cohan1279
 Share

Recommended Posts

hello im trying to get a query but it comes back as empty when it is not?? can someone please help?

[code]###
### Table structure for table 'forumname'
###

CREATE TABLE forumname (
  forumid bigint(20) default NULL,
  name blob,
  adminonly int(11) default NULL,
  clanonly int(11) default NULL
) TYPE=MyISAM;

###
### Dumping data for table 'forumname'
###


INSERT INTO forumname VALUES (1,'Announcements',1,0);
INSERT INTO forumname VALUES (2,'Clan Messages',0,1);
INSERT INTO forumname VALUES (3,'General Chatter',0,0);
INSERT INTO forumname VALUES (4,'Bugs/Suggestions',0,0);

###
### Table structure for table 'forum'
###

CREATE TABLE forum (
  msgid bigint(20) NOT NULL auto_increment,
  posternum bigint(20) default NULL,
  message blob,
  parentid bigint(20) default NULL,
  forumid bigint(20) default NULL,
  subject blob,
  timestamp bigint(20) default NULL,
  postername blob,
  clantag blob,
  adminflag int(11) default NULL,
  lastpost bigint(20) default NULL,
  PRIMARY KEY  (msgid)
) TYPE=MyISAM;[/code]


thats the tables and here is the php script..

[code]if ($users[clan] != "") { $clan = loadClan($users[clan]); }

?>

Welcome to the <?=$config[servname]?> internal forum, <?=$users[empire]?>!<br>

<table border=1 align=center width=100% class="scores">
<tr><th>Forum Name (Click name to go to forum)</th></tr>
<?
$forumlst = mysql_query("select * from $forumnamedb;");
$result = mysql_query($query) or die(mysql_error());
        $data = mysql_fetch_array($result);
        while ($forumlist = mysql_fetch_array($forumlst)) {
$adminonly = ""; $clanonly = "";
if ($forumlist[adminonly] == 1) { $adminonly = " - Read only access"; $postok = array($forumlist[forumid] => 0); }
if ($forumlist[clanonly] == 1) { $clanonly = " - Clan read/write access"; $postok = array($forumlist[forumid] => 1); }
if (($users[clan] == 0) && ($forumlist[clanonly] == 1)) { $clanonly = " - NO access (create or join a clan)"; $postok = array($forumlist[forumid] => 0); }
if ((($users[num] == $clan[founder]) || ($users[num] == $clan[asst]) || ($users[num] == $clan[fa1]) || ($users[num] == $clan[fa2])) && ($forumlist[clanonly] == 1)) { $adminonly = " - Clan Administrator Access"; $clanonly = ""; $postok = array($forumlist[forumid] => 2); }
if ($users[disabled] == 2) { $adminonly = " - Administrator Access"; $clanonly = ""; $postok = array($forumlist[forumid] => 3); }
print "<tr><th><a href=$config[main]?action=forums&forumid=$forumlist[forumid]>$forumlist[name]</a>$adminonly$clanonly</th></tr>\n";
}
?>
</table>

<? if ($forumid != 0) {
$forumlista = mysql_fetch_array(mysql_query("select * from $forumnamedb where forumid=$forumid;"));
if ($forumlista[adminonly] == 1) { $postok = array($forumlista[forumid] => 0); }
if ($forumlista[clanonly] == 1) { $postok = array($forumlista[forumid] => 1); }
if (($users[clan] == 0) && ($forumlist[clanonly] = 1)) { $postok = array($forumlista[forumid] => 0); }
if ((($users[num] == $clan[founder]) || ($users[num] == $clan[asst]) || ($users[num] == $clan[fa1]) || ($users[num] == $clan[fa2])) && ($forumlist[clanonly] = 1)) { $postok = array($forumlista[forumid] => 2); }
if (($forumlista[adminonly] != 1) && ($forumlista[clanonly] != 1)) { $postok = array($forumlista[forumid] => 1); }
if ($users[disabled] == 2) { $postok = array($forumlista[forumid] => 3); }
?>
<hr width=50% size=3 color=#360000>
<?
if ($do_newmessage != "") {
mysql_query("insert into $forumdb (posternum,message,parentid,forumid,subject,timestamp,postername,clantag,adminflag,lastpost) values (\"$users[num]\",\"$message\",\"$parentid\",\"$forumid\",\"$subject\",\"$time\",\"$users[empire]\",\"$users[clan]\",\"$users[disabled]\",\"$time\");");
if ($parentid != "") { mysql_query("update $forumdb set lastpost=$time where msgid=$parentid;"); }
print "<i><b>Message Posted</b></i>";
}
if ($do_delete != "") {
if (($forumlista[clanonly] == 1) && ($postok[$forumid] >= 2)) {
if ($post) { $postid = $post; mysql_query("delete from $forumdb where msgid=$post"); }
if ($thread) { $postid = $thread; mysql_query("delete from $forumdb where parentid=$thread or msgid=$thread"); }
print "Post ID $postid deleted!";
}
if ($postok[$forumid] == 3) {
print "Post ID $postid deleted!";
}
}
?>
<table border=1 width=100% class="scores">
<? $foruminfo = mysql_fetch_array(mysql_query("select name,clanonly from $forumnamedb where forumid=$forumid;")); ?>
<caption align=top>Browsing <?=$foruminfo[name]?>... (Most recent thread displayed first)</caption>
<tr><th width=30%>Subject</th><th width=30%>Poster</th><th width=10%># of posts</th><th width=30%>Last Post (in <?=date("T");?>)<br>Last Poster</th></tr>
<?
if (($foruminfo[clanonly] == 1) && ($users[disabled] != 2)) {
$messagelst = mysql_query("select * from $forumdb where forumid=$forumid and (clantag=$users[clan] or adminflag=2) and parentid is not null and parentid = 0 order by lastpost desc;");
} else {
$messagelst = mysql_query("select * from $forumdb where forumid=$forumid and parentid is not null and parentid = 0 order by lastpost desc;");
}
while ($messagelist = mysql_fetch_array($messagelst)) {
# $lastpost = mysql_fetch_array(mysql_query("select timestamp from $forumdb where (parentid=$messagelist[msgid] or msgid=$messagelist[msgid]) order by timestamp desc limit 1"));
$lastpost = date("D, F j, Y g:i:s a",$messagelist[lastpost]);
$threadnum = mysql_num_rows(mysql_query("select timestamp from $forumdb where (parentid=$messagelist[msgid] or msgid=$messagelist[msgid]) order by timestamp desc"));
$lastpostinfo = mysql_fetch_array(mysql_query("select adminflag,posternum,postername,clantag from $forumdb where (parentid=$messagelist[msgid] or msgid=$messagelist[msgid]) order by timestamp desc"));
$msgstamp = date("D, F j, Y g:i:s a",$lastpost[timestamp]);
$clantag = ""; $clantagb = "";
if ($messagelist[clantag] > 0) { $clantaga = mysql_fetch_array(mysql_query("select tag from $clandb where num=$messagelist[clantag];")); $clantag = " - $clantaga[tag]"; }
if ($messagelist[adminflag] == "2") { $clantag = " - <font class=\"cbad\">Administrator</font>"; }
if ($lastpostinfo[clantag] > 0) { $clantagba = mysql_fetch_array(mysql_query("select tag from $clandb where num=$messagelist[clantag];")); $clantagb = " - $clantagba[tag]"; }
if ($lastpostinfo[adminflag] == "2") { $clantagb = " - <font class=\"cbad\">Administrator</font>"; }
if (($forumlista[clanonly] == 1) && ($postok[$forumid] >= 2)) {
$deleteok = " - <a href=$config[main]?action=forums&forumid=$forumid&do_delete=1&thread=$messagelist[msgid]>Delete</a>";
}
if ($postok[$forumid] == 3) {
$deleteok = " - <a href=$config[main]?action=forums&forumid=$forumid&do_delete=1&thread=$messagelist[msgid]>Delete</a>";
}
print "<tr><td><a href=$config[main]?action=forums&forumid=$forumid&read=$messagelist[msgid]>$messagelist[subject]</a></td><td>$messagelist[postername] (#$messagelist[posternum])$clantag</td><td>$threadnum$deleteok</td><td>$lastpost<br><i>$lastpostinfo[postername] (#$lastpostinfo[posternum])$clantagb</i></td></tr>\n";
}
?>
<?
if ($read != 0) {
$messagedis = mysql_fetch_array(mysql_query("select * from $forumdb where msgid=$read and forumid=$forumid"));
if (($users[clan] != $messagedis[clantag]) && ($foruminfo[clanonly] == 1) && ($users[disabled] != 2)) { print "Message unreadable!"; } else {
?>
</table>
<table border=0 width=100% class="scores">
<?
$threadlst = mysql_query("select * from $forumdb where forumid=$forumid and (parentid=$read OR msgid=$read);");
while ($threadlist = mysql_fetch_array($threadlst)) {
$messagetext = eregi_replace("<","&lt;",$threadlist[message]);
$messagetext = eregi_replace("\n","<br>",$messagetext);
$messagetext = eregi_replace("\cM","<br>",$messagetext);
$msgstamp = date("D, F j, Y g:i:s a",$threadlist[timestamp]);
$clantg = "";
if ($threadlist[clantag] > 0) { $clantga = mysql_fetch_array(mysql_query("select tag from $clandb where num=$threadlist[clantag];")); $clantg = " - $clantga[tag]"; }
if ($threadlist[adminflag] == "2") { $clantg = " - <font class=\"cbad\">Administrator</font>"; }
if (($forumlista[clanonly] == 1) && ($postok[$forumid] >= 2)) {
$deleteok = " - <a href=$config[main]?action=forums&forumid=$forumid&do_delete=1&post=$threadlist[msgid]>Delete</a>";
}
if ($postok[$forumid] == 3) {
$deleteok = " - <a href=$config[main]?action=forums&forumid=$forumid&do_delete=1&post=$threadlist[msgid]>Delete</a>";
}
print "<tr><td width=25%><b><i>$threadlist[subject]</b>$deleteok</i></td><td>$threadlist[postername] (#$threadlist[posternum])$clantg</td><td><b>Posted at:</b> $msgstamp</td></tr>\n";
print "<tr><td bgcolor=#993300 colspan=3>&nbsp;</td></tr>\n";
print "<tr><td colspan=3>$messagetext</td></tr>\n";
print "<tr><td colspan=3>&nbsp;</td></tr>\n";
}
?>
<? } } ?>
</table>
<?
#$forumlista = mysql_fetch_array(mysql_query("select * from $forumnamedb where forumid=$forumid;"));
#if ($forumlista[adminonly] == 1) { $postok = array($forumlista[forumid] => 0); }
#if ($forumlista[clanonly] == 1) { $postok = array($forumlista[forumid] => 1); }
#if (($users[clan] == 0) && ($forumlist[clanonly] = 1)) { $postok = array($forumlista[forumid] => 0); }
#if ((($users[num] == $clan[founder]) || ($users[num] == $clan[asst]) || ($users[num] == $clan[fa1]) || ($users[num] == $clan[fa2])) && ($forumlist[clanonly] = 1)) { $postok = array($forumlista[forumid] => 2); }
#if (($forumlista[adminonly] != 1) && ($forumlista[clanonly] != 1)) { $postok = array($forumlista[forumid] => 1); }
#if ($users[disabled] == 2) { $postok = array($forumlista[forumid] => 3); }
if ($postok[$forumid] != 0) {
if (($users[disabled] != 2) && ($forumlista[adminonly] == 1)) { TheEnd("Only Administrators may post here!"); }
if ($read != 0) { print "Reply to this thread<br>\n";
} else { print "Post new thread<br>\n"; }
print "<form method=post action=Global-Wars.php>\n";
print "<input type=hidden name=action value=forums>\n";
print "<input type=hidden name=forumid value=$forumid>\n";
if ($read != "") { print "<input type=hidden name=parentid value=$read>\n"; }
print "Subject: <input type=text name=subject size=25 maxlength=25><br>\n";
print "<textarea rows=15 cols=60 name=message></textarea><br>\n";
print "<input type=submit name=do_newmessage value=\"Post Message\">\n";
print "</form>\n";
}
[/code]


can anyony see why it just says the query was emtpy???? theres nothing in the forum table but the forumname table there is.... and even if i insert in to the forum table it still comes up emtpy????? please any help?
Link to comment
Share on other sites

sorry for the long code but i really have no idea where the problem is.... maybe here...
[code]<?
$forumlst = mysql_query("select * from $forumnamedb;");
$result = mysql_query($query) or die(mysql_error());
        $data = mysql_fetch_array($result);
        while ($forumlist = mysql_fetch_array($forumlst)) {
$adminonly = ""; $clanonly = "";
if ($forumlist[adminonly] == 1) { $adminonly = " - Read only access"; $postok = array($forumlist[forumid] => 0); }
if ($forumlist[clanonly] == 1) { $clanonly = " - Clan read/write access"; $postok = array($forumlist[forumid] => 1); }
if (($users[clan] == 0) && ($forumlist[clanonly] == 1)) { $clanonly = " - NO access (create or join a clan)"; $postok = array($forumlist[forumid] => 0); }
if ((($users[num] == $clan[founder]) || ($users[num] == $clan[asst]) || ($users[num] == $clan[fa1]) || ($users[num] == $clan[fa2])) && ($forumlist[clanonly] == 1)) { $adminonly = " - Clan Administrator Access"; $clanonly = ""; $postok = array($forumlist[forumid] => 2); }
if ($users[disabled] == 2) { $adminonly = " - Administrator Access"; $clanonly = ""; $postok = array($forumlist[forumid] => 3); }
print "<tr><th><a href=$config[main]?action=forums&forumid=$forumlist[forumid]>$forumlist[name]</a>$adminonly$clanonly</th></tr>\n";
}
?>
</table>

<? if ($forumid != 0) {
$forumlista = mysql_fetch_array(mysql_query("select * from $forumnamedb where forumid=$forumid;"));
if ($forumlista[adminonly] == 1) { $postok = array($forumlista[forumid] => 0); }
if ($forumlista[clanonly] == 1) { $postok = array($forumlista[forumid] => 1); }
if (($users[clan] == 0) && ($forumlist[clanonly] = 1)) { $postok = array($forumlista[forumid] => 0); }
if ((($users[num] == $clan[founder]) || ($users[num] == $clan[asst]) || ($users[num] == $clan[fa1]) || ($users[num] == $clan[fa2])) && ($forumlist[clanonly] = 1)) { $postok = array($forumlista[forumid] => 2); }
if (($forumlista[adminonly] != 1) && ($forumlista[clanonly] != 1)) { $postok = array($forumlista[forumid] => 1); }
if ($users[disabled] == 2) { $postok = array($forumlista[forumid] => 3); }
?>[/code]
Link to comment
Share on other sites

[code]$forumlst = mysql_query("select * from $forumnamedb;");
$result = mysql_query($query) or die(mysql_error());
        $data = mysql_fetch_array($result);
        while ($forumlist = mysql_fetch_array($forumlst)) {
$adminonly = ""; $clanonly = "";[/code]

that should be geting this [code]INSERT INTO forumname VALUES (1,'Announcements',1,0);
INSERT INTO forumname VALUES (2,'Clan Messages',0,1);
INSERT INTO forumname VALUES (3,'General Chatter',0,0);
INSERT INTO forumname VALUES (4,'Bugs/Suggestions',0,0);[/code]

and printing
it ...it is not , just says query was empty,
Link to comment
Share on other sites

[quote]
[code]
$forumlst = mysql_query("select * from $forumnamedb;");
$result = mysql_query($query) or die(mysql_error());
[/code]
[/quote]

should the first line read
[code]
$query = "select * from $forumnamedb";
[/code]
?

The variable $query is not set in the code you posted. That would be the cause of the "empty query" error.
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.