Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Your setYearSelect method or dateAllow method probably expects the min value to be less than the max value.
  2. Since $dateAllowedSelect = date('Y') +5; produces the expected value of 2015, you apparently have some problem in your code that is using that value.
  3. highlight_file or highlight_string
  4. You cannot set post_max_size or upload_max_filesize in a script (they must be set before the script is executed) and you forgot to tell use which error message you are getting.
  5. The cleanest way (for an arbitrary number of 'having all x' present) is to use IN() the way you are currently, but GROUP BY s.solarSystemID and then get a count of how many are in each group, and add a HAVING count = 3. Untested but should work - SELECT s.solarSystemID, count(*) as cnt FROM mapRegionIceTypes i LEFT JOIN invTypes t ON i.typeID = t.typeID LEFT JOIN mapSolarSystems s ON s.regionID = i.regionID WHERE i.maxSecurity >= s.security AND i.minSecurity <= s.security AND i.typeID IN (16264,16262,16267) GROUP BY s.solarSystemID HAVING cnt = 3 The HAVING cnt = x would need to match the number of different choices being used in the IN() term.
  6. And the problem is the same that someone already stated - It's also possible that your code is closing the database connection at some point between where it is being opened and where the queries are trying to us it.
  7. When they were talking about putting in register_globals (yes they intentionally did this), red lights should have been flashing, flags should have been waving, bells should have been going off. Once the security problems with it were known, it should have been irrevocably turned off. With RG on, any post/get/cookie/files/some-server variables create a program variable by the same name and any session variable with the same name as a program variable is back-populated with the value that the program variable was just set to. And it is really too bad that we are still seeing code and new programmers being shown code that relies on register_globals at this point in the year 2010. It should have all disappeared/been updated long ago. People should not be wasting time on - "my code does not work because my program variables are not being set!"
  8. Security is the first priority when writing any kind of code and it should be the first priority when teaching someone how to code. You are being told to follow the coding found in a specific book and that book is 8 years out of date and is teaching you to use something that will allow hackers to take over a web site. Register_globals were turned off by default in php4.2 in April of the year 2002 (yes over 8 years a go) because it allows hackers to set your program and session variables by simply putting get parameters on the end of the URL when they visit your page. A lot of web sites have been taken over. Register_globals being on finally throws a depreciated error message in php5.3 and register_globals will be completely removed in the next major release of php. Any person developing php code or using php for teaching purposes should know this. As has already been stated in this thread, the code you are being shown to follow won't work on a majority of servers today (it does not work on your development system) and in the near future it won't work at all.
  9. Why don't you just use trim() on the values when they are entered, instead of using trim() in several different places in the code, but not in the place where you are getting the unexpected results.
  10. It looks like you are adding 65 to $matchno, did you try doing that?
  11. Blank php pages are usually the result of a fatal php parse error on the page. Have you tested displaypage.php by browsing directly to it and do you have error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that all php detected errors will be reported and displayed?
  12. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=318011.0
  13. Your $subDomain and $shortProjectName variables apparently have new-lines as part of them. What is the code that is setting those variables?
  14. If you search for that error message you will find that it most commonly means that your query failed due to an error. If you echo mysql_error(); on the next line after the line with the mysql_query() statement, it will tell you why the query failed.
  15. Using DISTINCT in the query would probably solve it. It removes duplicate rows from the result set. You would need to select only those columns you need, rather than *
  16. Are the $showendo['date'] vales the same when 'endonum' has the same value or what do you want to use for $showendo['date'] when you have several 'endonum' with the same value?
  17. Best guess is your queries are failing due to an error. If you echo mysql_error(); on the next line after the line with the mysql_query() statements, it will tell you why the query is failing.
  18. If you actually look at the line where the error is being reported, you will see it is the following code, where you have a $ in front of the die() statement - $die("Your avatar is uploaded. <a href = 'character.php'> home </a>"); It always helps to post actual errors, like someone had to ask you to do.
  19. Either - 1) Your source file is corrupted or contains some encoded characters as part of that line (perhaps you are using a non-English keyboard or you copy/pasted code that had some of the characters encoded), or 2) Your web host has disabled that function (the phpinfo() output would list it under disable_functions.) For #1, delete and retype the line and/or copy and paste the code into a completely new file. For #2, check the phpinfo() output and/or check with your web host. Given the that php version that your web host is using is about 4 years out of date, I'll guess this is a free/cheep host and they have probably disabled several functions.
  20. Your database connection code is not working and since you don't have a valid database connection when the mysql_query() is being executed, it is attempting to create a connection using default values. You would need to troubleshoot why your connection code is either not being executed or is failing to create a connection. You would need to post your code if you want help with what it is or is not doing.
  21. The code does not have any white-space between the <?php tag and the session_start() statement and apparently short-open tags are enabled on your server. The php language parser saw a short opening php tag <? followed by phpsession_start(); instead of <?php session_start();
  22. The other links correctly have the SID in them. As to the error message, just read what it is telling you and someone already posted about it -
  23. { $links .= "\n<A HREF=\"$self?".SID."&letters=$alpha[$c]$letters&n=$n\">$alpha[$c]</A> "; }
  24. The following code demonstrates how you might accomplish the basic edit logic - <?php // locate <div class="editable"></div> on a page and allow it to be edited and then saved back to the page // echo or return a string that may contain html function echo_html($string,$return=false){ if(!$return){ echo htmlentities($string,ENT_QUOTES); } else { return htmlentities($string,ENT_QUOTES); } } // ref: http://forums.devnetwork.net/viewtopic.php?f=38&t=102670 for the following // regex to extract contents from <div class="editable">contents</div> $pattern_long = '{ # recursive regex to capture contents of specific DIV (<div\s+[^>]*?class=["|\']editable["|\'][^>]*>) # match the DIV opening tag ( # capture DIV contents into $1 (?: # non-cap group for nesting * quantifier (?: (?!<div[^>]*>|</div>). )++ # possessively match all non-DIV tag chars | # or <div[^>]*>(?1)</div> # recursively match nested <div>xyz</div> )* # loop however deep as necessary ) # end group 1 capture (</div>) # match the DIV closing tag }six'; // single-line (dot matches all), ignore case and free spacing modes ON session_start(); $_SESSION['admin'] = true; // ********* fake for testing ********* // check if visitor is logged in as an admin... Replace with your actual log in checking logic if(!isset($_SESSION['admin'])){ header('login.php'); // send them somewhere else... exit; } // the current visitor can access this page // get/make a list of files that can be edited - either via array, glob, database, or by indexing the site $files = array('index.html','news.html'); // dummy list of files for testing purposes // set default value(s) as needed $_SESSION['current_file'] = isset($_SESSION['current_file']) ? $_SESSION['current_file'] : ''; // 'select file' form processing code if(isset($_POST['select_file'])){ $_SESSION['current_file'] = $_POST['file']; } // 'div edit' form processing code if(isset($_POST['div_edit'])){ // check if there is a filename (if the form was used to submit to here there will be) if(!empty($_POST['filename'])){ // check if file actually/still exists if(!file_exists($_POST['filename'])){ echo "The file: {$_POST['filename']} does not exist!"; } else { // file exists, get the current content $content = file_get_contents($_POST['filename']); // check that the <div> exists $matchcount = preg_match_all($pattern_long, $content, $matches); if ($matchcount > 0) { // an editable <div> exists, replace the content in the <div> $content = preg_replace($pattern_long, "$1{$_POST['textarea']}$3", $content, 1); if($content !== NULL){ // write changes to file if(file_put_contents($_POST['filename'],$content) === false){ echo "Could not save changes to the file!"; } else { echo "The file: {$_POST['filename']}, was successfully updated!"; } } else { echo "preg_replace failed due to an error!<br />"; } } else { echo_html('No editable <div> found!'); } } } } // end div_edit form processing // make a select list of files $select = "<select name='file' onchange='this.form.submit();'>\n<option value=''>Select a file to edit!</option>\n"; foreach($files as $file){ $selected = ($_SESSION['current_file'] == $file) ? " selected = 'selected'" : ''; $select .= "<option value='$file'$selected>$file</option>\n"; } $select .= "</select>\n"; // output the select file form ?> <form action='' method='post'> Current File: <input type='hidden' name='select_file'> <?php echo $select; ?><br /> </form> <?php // get and display the editable div from the currently selected file if(!empty($_SESSION['current_file'])){ if(!file_exists($_SESSION['current_file'])){ echo "The file: {$_SESSION['current_file']} does not exist!"; } else { $content = file_get_contents($_SESSION['current_file']); $matchcount = preg_match_all($pattern_long, $content, $matches); if ($matchcount > 0) { echo echo_html("The following editable <div> was found:",true) . "<br />\n"; echo "<form action='' method='post'>"; echo "<input type='hidden' name='div_edit'>"; echo "<input type='hidden' name=filename value='{$_SESSION['current_file']}'"; echo "<textarea name='textarea' rows='10' cols='80'>". echo_html($matches[2][0],true) . "</textarea><br />\n"; echo "<input type='submit' name='submit' value='Save Changes'"; echo "<form>"; } else { echo_html('No editable <div> found!'); } } } ?>
  25. Another point about using a cookie to 'remember' someone. That's all the existence of the cookie should do, identify the visitor. It should not determine if the visitor is logged in, if he is an admin, or what his privileges are, .... You should 'remember' if the visitor is logged in ONLY using a value stored on the server.
×
×
  • 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.