Jump to content

Deathwillow

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Deathwillow's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you.
  2. // Build Query array. if ($name == '' && $level == '' && $race == '' && $gender == '' && $type == '' && $rank == '') { $query = "SELECT * FROM wow_character"; $counter = 0; } else { $counter = 0; if ($name != '') { $dataName[$counter] = "name"; $dataQuery[$counter] = $name; $counter++; } if ($level != '') { $dataName[$counter] = "level"; $dataQuery[$counter] = $level; $counter++; } if ($race != '') { $dataName[$counter] = "raceid"; $dataQuery[$counter] = $race; $counter++; } if ($gender != '') { $gender = $gender - 1; $dataName[$counter] = 'genderid'; $dataQuery[$counter] = $gender; $counter++; } if ($type != '') { $dataName[$counter] = 'classid'; $dataQuery[$counter] = $type; $counter++; } if ($rank != '') { $rank = $rank - 1; $dataName[$counter] = 'rank'; $dataQuery[$counter] = $rank; $counter++; } $x = 0; while ($x < $counter) { if ($x == 0) { $query = "SELECT * FROM wow_character WHERE $dataName[$x] = $dataQuery[$x]"; $x++; } else { $query .= " AND $dataName[$x] = $dataQuery[$x]"; $x++; } } } This is how I did it, is there a more efficient way of doing it?
  3. Alright, I may not have done it efficiently but I created a loop that builds an array and then at the end combines it into a query and it all seems to be working. Thanks for your help!
  4. Ok this is weird.... something so simple has become a fairly large and annoying issue. So I started getting the error: Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /hermes/web03/b36/pow/IM/roster2/test.php on line 6 I made a simple test page to see if it was anything in the scripts but nothing. the page I load is: <?php $connection = mysql_connect("","","") or die(mysql_error()); $connection = mysql_select_db("") or die(mysql_error()); echo $connection; mysql_close($connection); ?> The first echo returns 1 while the next line is the one above... how is something so easy and simple going so wrong?
  5. May have babbled a little bit but I couldn't put into words what I was trying to do Just trying to give you guys a precise picture of the issue.
  6. I'm going to have trouble explaining the problem here but bare with me! So I'm trying to build a search query that search the database for information the user has entered. Basically the setup is: Editbox Editbox Dropdown Dropdown Dropdown Dropdown So the first thing I did was check to see if all those were blank to set the string as : $query = "SELECT * FROM wow_character"; if even one of those form elements aren't blank, set $query as: $query = "SELECT * FROM wow_character WHERE "; Now the problem I'm having and can't figure out is how I would code it to where if say the first editbox is empty but the second isn't it'll return the right information. The only way I can think of is using a TON of if else statements and that just doesn't seem efficient and I think there's a better cleaner and shorter way of doing it. Here's what I've done so far: // Build Query if ($name == '' && $level == '' && $race == '' && $gender == '' && $type == '' && $rank == '') { $query = "SELECT * FROM wow_character"; } else { $query = "SELECT * FROM wow_character WHERE "; } if ($name != '') { $query .= " name = '$name'"; } if ($level != '') { $query .= " AND level = '$level'"; } Now that's just testing the first 2 edit boxes, but the errors arise when: 1) if name isn't empty but level is, works like a charm 2) if name isn't empty and level isn't empty, works like a charm 3) if name is empty and level is empty, works like a charm 4) if name is empty and level isn't empty, ERROR Is there a shorter, better, more efficient way of coding this without doing: // Build Query if ($name == '' && $level == '' && $race == '' && $gender == '' && $type == '' && $rank == '') { $query = "SELECT * FROM wow_character"; } else { $query = "SELECT * FROM wow_character WHERE "; } if ($name != '') { $query .= " name = '$name'"; } if ($level != '') { if ($name == '') { $query .= " level = '$level'"; } else { $query .= " AND name = '$name'"; } } You can see where it's lengthy with just 2 with 6 it'll be a ton of if else statements... a ton... What's a better way of coding this?
  7. Actually I just went ahead and tried the above and it all seems to work like a charm now, for reference here's the final code. <?php include('news.php'); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" /> <title>Insinuo Matris</title> <link href="main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jQuery/jquery.1.4.3.js"></script> <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script> </head> <body> <div id="page"> <div id="topImage"> </p> </P> </div> <div id="navBar"> <div class="navBar"> <ul> <li class="active"><a href="#">Home</a></li> <li><a href="/forums">Forums</a></li> <li><a href="/roster">Roster</a></li> <li><a href="/media">Videos</a></li> <li><a href="/loot">Loot</a></li> <li><a href="/downloads">Downloads</a></li> </ul> </div> </div> <div id="content"> <div id="contentArea"> <div id="breadCrumb"></div> <div id="contentLeft"> <?php foreach($news as $n) { echo "<div class=\"newsPost\"> <h1><span class=\"topic\"><a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$n['topic_id']}\">{$n['topic_title']}</a></span></h1> <p>{$n['post_text']}</p> <div class=\"newsPost_footer\"> <span class=\"newsPost_comments\">Comments: <a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$n['topic_id']}\">{$n['topic_replies']}</a></span><span class=\"newsPost_author\">Posted by <i><font color=\"#CCCCCC\">{$n['username']} </font>on " . $user->format_date($n['topic_time']) . "</i></span> </div> </div>"; } ?> </div> <div id="contentRight"> <div class="contentRightSetup"> <h1><span class="topic">Currently Recruiting:</span></h1> <ul class="recruitmentList"> <?php include('recruitment.php'); ?> </ul> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Loot:</span></h1> <p>Loot to be added later.</p> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Blue Posts:</span></h1> <ul> <span class="blueFeed"> <?php include('bluePosts.php'); ?> </span> </ul> </div> </div> </div> </div> </div> </body> </html> thanks to everyone who replied and help me with this issue, it's been plaguing me for a while.
  8. So should I place: <?php include('news.php'); ?> at the VERY beginning of index.php and use the array function where I need to display the information. Example of what I mean would be: <?php include('news.php'); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" /> <title>Insinuo Matris</title> <link href="main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jQuery/jquery.1.4.3.js"></script> <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script> </head> <body> <div id="page"> <div id="topImage"> </p> </P> </div> <div id="navBar"> <div class="navBar"> <ul> <li class="active"><a href="#">Home</a></li> <li><a href="/forums">Forums</a></li> <li><a href="/roster">Roster</a></li> <li><a href="/media">Videos</a></li> <li><a href="/loot">Loot</a></li> <li><a href="/downloads">Downloads</a></li> </ul> </div> </div> <div id="content"> <div id="contentArea"> <div id="breadCrumb"></div> <div id="contentLeft"> ** PHP LOOP HERE RECALLING THE ARRAY FROM NEWS.PHP ** </div> <div id="contentRight"> <div class="contentRightSetup"> <h1><span class="topic">Currently Recruiting:</span></h1> <ul class="recruitmentList"> <?php include('recruitment.php'); ?> </ul> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Loot:</span></h1> <p>Loot to be added later.</p> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Blue Posts:</span></h1> <ul> <span class="blueFeed"> <?php include('bluePosts.php'); ?> </span> </ul> </div> </div> </div> </div> </div> </body> </html> If i'm understanding you guys right, that should correct it right?
  9. I'm not exactly sure where in the index file this could be happening, here's what it is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" /> <title>Insinuo Matris</title> <link href="main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jQuery/jquery.1.4.3.js"></script> <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script> </head> <body> <div id="page"> <div id="topImage"> </p> </P> </div> <div id="navBar"> <div class="navBar"> <ul> <li class="active"><a href="#">Home</a></li> <li><a href="/forums">Forums</a></li> <li><a href="/roster">Roster</a></li> <li><a href="/media">Videos</a></li> <li><a href="/loot">Loot</a></li> <li><a href="/downloads">Downloads</a></li> </ul> </div> </div> <div id="content"> <div id="contentArea"> <div id="breadCrumb"></div> <div id="contentLeft"> <?php include('news.php'); ?> </div> <div id="contentRight"> <div class="contentRightSetup"> <h1><span class="topic">Currently Recruiting:</span></h1> <ul class="recruitmentList"> <?php include('recruitment.php'); ?> </ul> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Loot:</span></h1> <p>Loot to be added later.</p> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Blue Posts:</span></h1> <ul> <span class="blueFeed"> <?php include('bluePosts.php'); ?> </span> </ul> </div> </div> </div> </div> </div> </body> </html>
  10. So I've got a simple news script that pulls the last 5 posts in a specific phpbb3 forum but I'm getting errors on the front page whenever they don't at least open the forums before. There errors: To narrow it down a little more for everyone, When they visit the home page( http://im.deathwillow.com ) before visiting the forums they receive the following errors. Once they have at least visited, not requiring a log in, the forums ( http://im.deathwillow.com/forums ) the errors disappear. Any ideas? [phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /hermes/web03/b36/pow.deathwillow21/IM/index.php: [phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /hermes/web03/b36/pow.deathwillow21/IM/index.php: [phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /hermes/web03/b36/pow.deathwillow21/IM/index.php: The script: <?php define('FORUM_ID', 6); // Forum ID to get data from define('POST_LIMIT', 5); // How many to get define('PHPBB_ROOT_PATH', './forums/'); // Path to phpBB (including trailing /) define('PRINT_TO_SCREEN', true); // If set to true, it will print the posts out // If set to false it will create an array $news[] with all the following info // // 'topic_id' eg. 119 // // 'topic_time' eg. 06 June, 07 (uses board default) // 'topic_replies' eg. 26 // // 'username' eg. chAos // 'topic_title' eg. "News Post" // // 'post_text' eg. just the text (formatted w/ smilies, bbcode, etc) define('IN_PHPBB', true); $phpbb_root_path = PHPBB_ROOT_PATH; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/bbcode.' . $phpEx); // Start session management $user->session_begin(false); $auth->acl($user->data); // Grab user preferences $user->setup(); $query = "SELECT u.user_id, u.username, t.topic_title, t.topic_poster, t.forum_id, t.topic_id, t.topic_time, t.topic_replies, t.topic_first_post_id, p.poster_id, p.topic_id, p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid FROM ".USERS_TABLE." u, ".TOPICS_TABLE." t, ".POSTS_TABLE." p WHERE u.user_id = t.topic_poster AND u.user_id = p.poster_id AND t.topic_id = p.topic_id AND p.post_id = t.topic_first_post_id AND t.forum_id = ".FORUM_ID." ORDER BY t.topic_time DESC"; $result = $db->sql_query_limit($query, POST_LIMIT); $posts = array(); $news = array(); $bbcode_bitfield = ''; $message = ''; $poster_id = 0; while ($r = $db->sql_fetchrow($result)) { $posts[] = array( 'topic_id' => $r['topic_id'], 'topic_time' => $r['topic_time'], 'username' => $r['username'], 'topic_title' => $r['topic_title'], 'post_text' => $r['post_text'], 'bbcode_uid' => $r['bbcode_uid'], 'bbcode_bitfield' => $r['bbcode_bitfield'], 'topic_replies' => $r['topic_replies'], ); $bbcode_bitfield = $bbcode_bitfield | base64_decode($r['bbcode_bitfield']); } // Instantiate BBCode if ($bbcode_bitfield !== '') { $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } // Output the posts foreach($posts as $m) { $poster_id = $m['user_id']; $message = $m['post_text']; if($m['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $m['bbcode_uid'], $m['bbcode_bitfield']); } $message = str_replace("\n", '<br />', $message); $message = smiley_text($message); $comment = ($m['topic_replies']==1) ? 'comment' : 'comments'; if( PRINT_TO_SCREEN ) { /* Output is in the following format * * <h3>Thread Title</h3> ^ <h4 class="postinfo">date // 5 comments // poster</h4> * <p>First post test</p> * */ echo "<div class=\"newsPost\"> <h1><span class=\"topic\"><a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\">{$m['topic_title']}</a></span></h1> <p>{$message}</p> <div class=\"newsPost_footer\"> <span class=\"newsPost_comments\">Comments: <a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\">{$m['topic_replies']}</a></span><span class=\"newsPost_author\">Posted by <i><font color=\"#CCCCCC\">{$m['username']} </font>on " . $user->format_date($m['topic_time']) . "</i></span> </div> </div>"; } else { $news[] = array( 'topic_id' => $m['topic_id'], // eg: 119 'topic_time' => $user->format_date($m['topic_time']), // eg: 06 June, 07 (uses board default) 'topic_replies' => $m['topic_replies'], // eg: 26 'username' => $m['username'], // eg: chAos 'topic_title' => $m['topic_title'], // eg: "News Post" 'post_text' => $message, // just the text ); } unset($message,$poster_id); } ?>
×
×
  • 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.