Jump to content

Jeremysr

Members
  • Posts

    199
  • Joined

  • Last visited

    Never

Everything posted by Jeremysr

  1. The code you posted looks right. Just make sure you put something like this at the top of every page, changing the third line with the page title and page URL (seperated by the pipe symbol: " | "). session_start(); if (!isset($_SESSION['page_history'])) { $_SESSION['page_history'] = array(); } // Make the array if it hasn't been made array_push($_SESSION['page_history'], 'Index | http://site.com/index.php'); // Push the current page's title and URL to the array if (count($_SESSION['page_history'] > 5)) { array_shift($_SESSION['page_history']); } // If the array is getting too long, shorten it
  2. I didn't think you could have spaces in column names ("Employee ID"). If your column is really named that, then try putting it in backquotes: $strSQL = "SELECT * FROM details WHERE `Employee ID`='$id' AND Password='$pass'";
  3. You type the name of it, put the arguments inside parentheses, and put a semicolon. If there are no arguments you put a left and right parentheses without anything in them. Then the code inside the function will be executed. So wherever you put this: display_breadcrumbs(); The list of links will be displayed.
  4. Did you call the function to print the breadcrumbs? display_breadcrumbs();
  5. Here's how to use regex to validate it (I got it from regular-expressions.info): $email_is_valid = preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $email);
  6. I think you should store their member id and their encrypted password. Then on every single page you should check to make sure the user id matches the encrypted password. This is because it is easy for users to edit their cookies and view their cookies. It's better to use sessions though. To the coder they work almost exactly the same, but a user can't edit session variables. So once you've checked their password you don't have to check it again.
  7. Maybe you could store each page in a session variable, an array of pages. So you'd put this on each page: session_start(); if (!isset($_SESSION['page_history'])) { $_SESSION['page_history'] = array(); } // Make the array if it hasn't been made array_push($_SESSION['page_history'], 'Index | http://site.com/index.php'); // Push the current page's title and URL to the array if (count($_SESSION['page_history'] > 5)) { array_shift($_SESSION['page_history']); } // If the array is getting too long, shorten it And to display the breadcrumbs: function display_breadcrumbs() { foreach ($_SESSION['page_history'] as $page) { $page_parts = explode(' | ', $page); echo '<a href="'.$page_parts[1].'">'.$page_parts[0].'</a> > '; } }
  8. I just do something like this on each page: include 'header-php.php'; // Get job title from database here $page_title = "Job Details for $jobtitle"; include 'header-html.php'; header-php.php would have all the php code like functions and connecting to mysql and sessions. header-html.php would be mostly HTML and would put the title like this: <title><?php echo $page_title; ?></title>
  9. It's probably on the line just before 10. Like if you missed a semicolon on line 9 it probably isn't expecting a variable assignment on line 10.
  10. Maybe make the query like this: if (empty($_POST['year'])) { $where_year = "true"; } else { $where_year = "year = '".$_POST['year']."'"; } if (empty($_POST['type'])) { $where_type = "true"; } else { $where_type = "type = '".$_POST['type']."'"; } if (empty($_POST['title'])) { $where_title = "true"; } else { $where_title = "title LIKE '".$_POST['title']."'"; } $sql = "SELECT * FROM `listings` WHERE $where_year AND $where_type AND $where_title"; Now all three parts of the WHERE part have to be true, and if a form field is left blank it'll make that part true. Example: SELECT * FROM `listings` WHERE true AND true AND title LIKE 'asdf'
  11. Still not sure if I understand you, is this what you want? <?php $subject = array_rand(explode(',', $_POST['subject'])); $body = array_rand(explode(',', $_POST['body'])); ?> <form name="" method="post" action="" id=""> <input name="ctl00$Main$BulletinEdit$tbxSubject" id="ctl00_Main_BulletinEdit_tbxSubject" type="text" value="<?php echo $subject; ?>"> <textarea name="ctl00$Main$BulletinEdit$tbxBody" rows="10" cols="20" id="ctl00_Main_BulletinEdit_tbxBody"> <?php echo $body; ?> </textarea> </form>
  12. Can you explain that more? I don't know what you mean... These forums work fine, also I have to leave right away so other people might have to help you.
  13. Inside PHP tags, anywhere above your form. It can replace all your other PHP code.
  14. It loops through the $array_cnt array. Each iteration it assigns the next element of the array to the variable $line. The if statement checks to see if their ip address is at the beginning of the current line it's checking. strpos() returns the position that the ip address is found. If it isn't found, it returns false. Since 0 and false mean the same thing, I used ===. So if it found the IP address on the current line, it sets $ipck to true and sets $banid to the current line.
  15. So you just want to pick a random subject and a random body? $subject = array_rand(explode(',', $_POST['subject'])); $body = array_rand(explode(',', $_POST['body']));
  16. If you're using that foreach loop I gave you, you could just store the line into a variable when you find it: $ipchk = false; foreach ($array_cnt as $line) { if (strpos($line, $user_ip) === 0) { $ipchk = true; $banid = $line; } } Then you don't have to worry about the array number.
  17. I think there's something wrong with your quotes at the very end of the query... it's OK to use single quotes in the query, you know. Then you don't have to make it look confusing with all the escaped quotes.
  18. This should help you debug. Replace the $result = mysql_query() line with this: echo "SELECT * FROM `listings` WHERE number= \"".$_POST['number']."\" or state =\"".$_POST['state']."\" and title LIKE \"". $_POST['title'] ."\""; $result = mysql_query("SELECT * FROM `listings` WHERE number= \"".$_POST['number']."\" or state =\"".$_POST['state']."\" and title LIKE \"". $_POST['title'] ."\"") or die(mysql_error()); The first line will echo the query that you're trying to do, the second line will echo the mysql error if there's something wrong with the query.
  19. I would get the different parts of the date using a bunch of substr()'s... $endtime = "2008-10-31T00:48:06.000Z"; $year = substr($endtime, 0, 4); $month = substr($endtime, 5, 2); $day = substr($endtime, 8, 2); // etc... ...make a UNIX timestamp out of all those variables, subtracting it from the current time... $endtime_timestamp = mktime($hour, $minute, $second, $month, $day, $year); $seconds_left = time() - $endtime_timestamp; ...and use getdate() to find out how many days, hours, etc. are left. $time_left = getdate($seconds_left); $time_left_string = $time_left['yday'].'D '.$time_left['hours'].'H '.$time_left['minutes'].'M '.$time_left['seconds'].'S';
  20. I think you do it like this: class DBConnection { function connect() { Logger::WriteLog(); } }
  21. Don't you need quotes when using LIKE? $result = mysql_query ("SELECT * FROM `listings` WHERE number= ".$_POST['number']." or state =".$_POST['state']." and title LIKE '". $_POST['title'] ."'");
  22. This line $ipchk = in_array($user_ip, $array_cnt); always returns false, because it checks if the user's IP is in the array of lines. The lines have the IP but also the other two things. Here's some code that would work: $ipchk = false; foreach ($array_cnt as $line) { if (strpos($line, $user_ip) === 0) { $ipchk = true; } } It loops through the lines in the file and checks if the user's ip is on the current line (starting at position 0).
  23. Looks like you meant the $cnt and $contents on lines 9 and 10 to be the same variables.
  24. 1. Use this query: "SELECT * FROM bugs ORDER BY ID DESC" 2. Set $ida to 0 above the loop, then put "$ida++;" at the very end of the loop (just before it loops back.) 3. Use "if (!empty($row['screen1'])) {"
×
×
  • 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.