contrabandheart Posted September 10, 2006 Share Posted September 10, 2006 So. Here's my problem. The first section of my code(Ex. 1) works properly. It displays how it should (it echos all of the correct information, it displays properly, etc.)[b]Ex. 1:[/b][code] if(!isset($entry_year) and !isset($entry_month)){ echo "<p>Select the year and entry that you posted the entry you want to edit from below...</p>\n"; $sql = "SELECT DISTINCT entry_year,entry_month FROM `entries` ORDER BY `entry_year` AND `entry_month` ASC;"; $result = mysql_query($sql) or die(mysql_error()); while($qd = mysql_fetch_row($result)){ echo "<p><a href='" . $REQUEST_URI . "&entry_year=$qd[0]&entry_month=$qd[1]'>$qd[0] | " . $month[$qd[1]] . "</a></p>\n"; }[/code]It's the second section of code(Ex. 2), which should find and display the relevent information from the database, based on the "entry_year" and "entry_month" columns. [b]Ex. 2:[/b][code] $sql = "SELECT entry_id,entry_year,entry_month,entry_day,entry_title FROM `entries` WHERE `entry_year` = '$entry_year' AND `entry_month` = '$entry_month' ORDER BY `entry_id` ASC;"; $result = mysql_query($sql) or die(mysql_error()); while($qd = mysql_fetch_row($result)){ "<p><a href='" . $REQUEST_URI . "?entry_id=$qd[0]'><strong>$qd[3] " . $month[$qd[2]] . ", $qd[1]</strong> | "$qd[4]"</a></p>\n";[/code]I know it's not a MySQL connection problem, because the first section works correctly. The only thing I can figure is that my operators (my "||"s and "and"s) are configured incorrectly. Any help is appreciated.[b]Complete Code:[/b][code] elseif($action == "editentry"){ connect2db("cass_blog"); echo "<h2>Edit Blog Entry</h2>\n"; if(!isset($entry_id) || empty($entry_id)){ if(!isset($entry_year) and !isset($entry_month)){ echo "<p>Select the year and entry that you posted the entry you want to edit from below...</p>\n"; $sql = "SELECT DISTINCT entry_year,entry_month FROM `entries` ORDER BY `entry_year` AND `entry_month` ASC;"; $result = mysql_query($sql) or die(mysql_error()); while($qd = mysql_fetch_row($result)){ echo "<p><a href='" . $REQUEST_URI . "&entry_year=$qd[0]&entry_month=$qd[1]'>$qd[0] | " . $month[$qd[1]] . "</a></p>\n"; } } else { $sql = "SELECT entry_id,entry_year,entry_month,entry_day,entry_title FROM `entries` WHERE `entry_year` = '$entry_year' AND `entry_month` = '$entry_month' ORDER BY `entry_id` ASC;"; $result = mysql_query($sql) or die(mysql_error()); while($qd = mysql_fetch_row($result)){ "<p><a href='" . $REQUEST_URI . "?entry_id=$qd[0]'><strong>$qd[3] " . $month[$qd[2]] . ", $qd[1]</strong> | "$qd[4]"</a></p>\n"; } } }[/code] Quote Link to comment Share on other sites More sharing options...
.josh Posted September 10, 2006 Share Posted September 10, 2006 2 things:1) make sure all the variables that you are doing conditioning on are holding what you expect them to (or not to be) holding, by echoing them out before your conditions. Your conditions may be failing because the variables are not holding what they are supposed to be holding. If this is the case, then the bug is not in your conditions, but somewhere else, like not setting the variables correctly or something.2) in order for us to even begin to guess whether your conditions are correct, you are going to have to explain what all the variables are supposed to be for, and what exactly you're trying to accomplish with these conditions. Quote Link to comment Share on other sites More sharing options...
contrabandheart Posted September 11, 2006 Author Share Posted September 11, 2006 Eh. I just took a good, long look at my code and realized what the problem was. I accidentally closed out a block before I should have, and set the wrong trigger.And Crayon Violent, I'm sorry for making those mistakes in my post (those are actually my pet peeves as well).Thanks for taking the effort to at least read the post. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.