cohan1279 Posted October 2, 2006 Share Posted October 2, 2006 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("<","<",$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> </td></tr>\n"; print "<tr><td colspan=3>$messagetext</td></tr>\n"; print "<tr><td colspan=3> </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 https://forums.phpfreaks.com/topic/22713-query-was-empty-help/ Share on other sites More sharing options...
shivabharat Posted October 2, 2006 Share Posted October 2, 2006 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 Link to comment https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-102145 Share on other sites More sharing options...
cohan1279 Posted October 2, 2006 Author Share Posted October 2, 2006 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 https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-102147 Share on other sites More sharing options...
cohan1279 Posted October 2, 2006 Author Share Posted October 2, 2006 [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 https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-102148 Share on other sites More sharing options...
fenway Posted October 3, 2006 Share Posted October 3, 2006 And $forumnamedb is what? Link to comment https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-102766 Share on other sites More sharing options...
cohan1279 Posted October 3, 2006 Author Share Posted October 3, 2006 [code]CREATE TABLE forumname ( forumid bigint(20) default NULL, name blob, adminonly int(11) default NULL, clanonly int(11) default NULL) TYPE=MyISAM;[/code] Link to comment https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-103059 Share on other sites More sharing options...
fenway Posted October 3, 2006 Share Posted October 3, 2006 No, in your query... Link to comment https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-103093 Share on other sites More sharing options...
cohan1279 Posted October 4, 2006 Author Share Posted October 4, 2006 its the table in my database called forumname ...[code]$forumnamedb = 'forumname'; // forumname table name[/code] Link to comment https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-103522 Share on other sites More sharing options...
shoz Posted October 4, 2006 Share Posted October 4, 2006 [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 https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-103578 Share on other sites More sharing options...
cohan1279 Posted October 5, 2006 Author Share Posted October 5, 2006 ;D thanks alot shoz! i think i should have my eyes checked after that one! All's well now ;D Link to comment https://forums.phpfreaks.com/topic/22713-query-was-empty-help/#findComment-104122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.