Jump to content


Photo

Query was empty help!!


  • Please log in to reply
9 replies to this topic

#1 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 02 October 2006 - 04:37 AM

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

###
### 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;


thats the tables and here is the php script..

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";
}


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?

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 02 October 2006 - 06:03 AM

Hi Cohan,

Thanks for the posting. Whenever you feel you need help please make sure you can narrow down the issue to an extend. I dont think we can go thorugh the long code which you have posted. Let uu know exactly were you think the issue is.

Thanks
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 02 October 2006 - 06:13 AM

sorry for the long code but i really have no idea where the problem is.... maybe here...
<?
	$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); }
?>


#4 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 02 October 2006 - 06:18 AM

$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 = "";

that should be geting this
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);

and printing
it ...it is not , just says query was empty,

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 October 2006 - 12:01 AM

And $forumnamedb is what?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#6 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 03 October 2006 - 01:51 PM

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


#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 October 2006 - 03:03 PM

No, in your query...
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#8 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 04 October 2006 - 02:58 AM

its the table in my database called forumname ...
$forumnamedb = 'forumname';		// forumname table name


#9 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 04 October 2006 - 06:49 AM

$forumlst = mysql_query("select * from $forumnamedb;");
$result = mysql_query($query) or die(mysql_error());


should the first line read
$query = "select * from $forumnamedb";
?

The variable $query is not set in the code you posted. That would be the cause of the "empty query" error.

#10 cohan1279

cohan1279
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 05 October 2006 - 03:51 AM

;D thanks alot shoz! i think i should have my eyes checked after that one! All's well now  ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users