Jump to content

contrabandheart

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

contrabandheart's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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.
  2. 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> | &quot;$qd[4]&quot;</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> | &quot;$qd[4]&quot;</a></p>\n";       }     }     } [/code]
  3. Okay... We'll do this the easy way. Or the hard way, however you want to see it. What are the names of the rows within your table? Give them to me in order, and I'll write a new query that [i]should[/i] word. (Emphasis on [b]SHOULD[/b]).
  4. Hey Mutley. If I understand your problem at all, it should be able to be fixed by selecting only [i]DISTINCT[/i] entries. i.e., the query below would give you all the rows. [code]mysql_query("SELECT * FROM `table`");[/code] With values named "1", "2", and "3", if each was in the table three times, it would get [code] 1 1 1 2 2 2 3 3 3 [/code] THIS query would only select entries in which the selected row was unique: [code]mysql_query("SELECT DISTINCT entry FROM table");[/code] This would give you: [code] 1 2 3 [/code]
  5. Do you store your user information in MySQL? If you want help, you should include more information about what it is you actually want to do, how the information you wish to access is stored, etc. Vague requests like "please tell me how to show a user's information" doesn't give anyone who wishes to help you any sort of starting point at all. -Cass
  6. Ahem. Bump. I'll be happy to provide any clarification if it's needed.
  7. Okay. So first, I'll give you a quick rundown of what it is I'm trying to do. I have a username and password field on a login page for a CMS script I'm currently writing. I already have all of the code for checking for empty fields, and now I'm on to securing it from people trying to brute force their way in (Not that anyone would care enough to do so, but I just want to be impressed with myself.) The snippet of code that I'm trying to get to work should function thusly: If you enter a username that doesn't exist, a cookie called "ccms_failed_login_attempts" is set with a default value of "1 (for one failed login)". After that, a piece of code checks to see if "ccms_failed_login_attempts" is set with a value of "1" (or set at all, for that matter). If it exists, it should load the cookie's value. After that, if the attacker tries to use another bogus username, the code should load and then reset "ccms_failed_login_attempts" to the current value plus 1 (i.e., if you have tried twice, it should load the cookie and reset it as three). *hopes any of this is making sense*. I'll insert the code below, hoping someone will help me. Thanks in advance. [code]     connect2db("********");     $sql = "SELECT user_id FROM `users` WHERE `user_name` = '$user_name' LIMIT 1;";     $result = mysql_query($sql) or die(mysql_error());     if(mysql_num_rows($result) == "0"){     header("Location: " . $PHP_SELF);     setcookie("ccms_status","loginBadUsername",time()+1);     if(!isset($_COOKIE['ccms_failed_login_attempts']) or $_COOKIE['cms_failed_login_attempts'] == 0){       setcookie("ccms_failed_login_attempts","1",time()+3600);     }     elseif(isset($_COOKIE['ccms_failed_login_attempts']) and $_COOKIE['ccms_failed_login_attempts'] >= 1){       $attempts = $_COOKIE['ccms_failed_login_attempts'];       setcookie("ccms_status","loginBanned",time()+1);       setcookie("ccms_failed_login_attempts",$attempts + 1,time()+3600);       //... And insert a value into a table in MySQL marking someone as banned.     } [/code]
×
×
  • 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.