Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Don't forget ternary operators return values. So you could assign a variable a ternary operator, eg instead of doing this ($_SESSION['logged_in'] == 1) ? $this->output = 1 : $this->output = 0; You can do just this: $this->output = ($_SESSION['logged_in'] == 1) ? 1 : 0;
  2. When you use header you redirect the user to sheets.php. All POST/GET data from the page you was redirected from will be lost. You'll probably want to use include instead. Also you may aswell use a basic if statement if you want the user to go to sheets.php if $_POST['login'] or $_POST['go'] exists: if(isset($_POST['login']) || isset($_POST['go'])) { include 'sheets.php'; } else { // code here to be executed if $_POST['login'] and $_POST['go'] doesn't exist }
  3. The ternary operator is just an if else statement, without the words if/else, instead they are symbols instead. If you understand an if/else statement you'll be able to use a ternary operator. The syntax of a ternary operator is this: (condition) ? true : false The above is the same as: if(condition) { true } else { false } Ternary operators are inline, they cannot execute blocks of code.
  4. What is gdbm? I can't seem to find any info about this on php.net.
  5. Where did I say store them in the root folder? I said outside of the root folder.
  6. As long the sessions are stored outside of your websites root folder (the folder where you upload your files too) then your sessions will be "safe". There is no "standard" place to store your sessions files.
  7. In order to do that you have to recompile PHP. On Windows you don't/should not need to recompile PHP. PHP is already compiled. In order to enable extra libraries you just need to enable either an extension/or an setting within the php.ini.
  8. You could of just changed the first foreach loop to this: foreach($dt_data as $k => $dt_val) { $output .= '<dt>'.$dt_val."</dt>\n<dd>" . $dd_data[$k] . "</dd>\n"; } And remove the secound foreach. Rather than rewriting the whole thing.
  9. That is to do with mysql. Make sure you have setup the correct user permissions for the lbobmanuel user in mysql.
  10. Well your configuration works fine here. I'm not sure what the problem might be. Try restoring the httpd.conf to its default settings when Apache was installed, there should be a backup copy of the httpd.conf stored in the conf folder. Look for a file called something like http-default.conf. Rename that backup file to httpd.conf (delete/rename the existing httpd.conf). Restart apache and test a simple html file. If the html file works fine then start by adding in the PHP config lines one by one. Making sure to save the httpd.conf and restart Apache each time.
  11. This should not prevent you from accessing localhost (which is an alias to 127.0.0.1). 127.0.0.1 is an internal ip address (or loopback address). My ISP does not condone hosting websites from my computer however I can still use Apache locally. From the problem you are having I'd assume its a configuration issue can you attach your httpd.conf file here.
  12. Upgrade PHP5.1.6 to PHP5.2.x. Apache2.2.x is not compatible with PHP5.1.6*. Note: When you upgrade make sure you use the php5apache2_2.dll module (for Windows). Or php5apache2_2.so (for non windows OS). * PHP5.1.6 can be compatible if you download the third party apache2.2.x php module from apachelounge.com Apache2.2.x has changed the way it handles modules. Apache2.0.x modules are no longer compatible with Apache2.2.x
  13. That should work. You have modified the correct line. Make sure you have edited the correct httpd.conf file.
  14. What version of Apache do you have installed? if its Apache2.2.x then the loadModule line should be: LoadModule php5_module c:/php5/php5apache2_2.dll Make sure you have PHP5.2.x installed in order to get this module. Apache2.2.x changed the way how it handles modules. Apache2.0.x modules are not compatible with Apache2.2.x. php5apache2.dll is for use with Apache 2.0.x
  15. Try: <?php $theFile=fopen("hybrid_spring.txt", "r"); $firstLine=fread($theFile,19); //error check to ensure we can open the text file and get results back, if not, display a //warning. if(!$theFile) { echo "Couldn't open the data file. Try again later."; } else { echo "<table cellspacing=\"2\" cellpadding=\"5\" border=\"1\">\n"; //read the contents of the text file while(!feof($theFile)) { //split the tab delimited file up $data = array_map("trim", explode("\t", fgets($theFile))); if (count($data) == 14) { if($data[5] <= 0 && $data[6] != "LAB" && $data[12] != "Y") { print " <tr class=\"closed\">\n"; } elseif ($data[13] == "Y") { print " <tr class=\"lab\">\n"; } else { print " <tr>\n"; } for ($i=0; $i<13; $i++) { print " <td>$data[$i]</td>\n"; } print " </tr>\n"; } elseif(!empty($data[0])) { echo " <tr>\n <td colspan=\"14\">" . trim($data[0]) . "</td>\n </tr>\n"; } } //done with the file, call the fclose function, passing variable fclose($theFile); echo '</table>'; } ?>
  16. Well how did you install PHP? Surely you must know what you have added to the httpd.conf when you installed PHP?
  17. Did you restart Apache when made the changes to the httpd.conf? Also how have you configured Apache to handle PHP (Module or CGI)?
  18. databases will return back the stored value. Databases wont convert text. This most probably your browser. If you want to see the text & in the browser you need to use &amp;. Your browser will parse and & and display &.
  19. Your code wont work as you always have to set the min number. Try: function getmin($nums) { // set min number to first number in the array $min = $nums[0]; // loop through the array foreach($nums as $num) { // check that the number is less than curret min number if($num <= $min) { // set min to current number $min = $num; } } // return minimum number return $min; } $arr = array(25, 60, 8, 1, 22); echo getmin($arr);
  20. The server has be configured to parse PHP scripts with the PHP interpreter. You cannot "force" an non-configured server to parse PHP code.
  21. If you want to get the smallest value within an array use min. You can also use max to get the biggest number in the array.
  22. Abit like this: <?php $seed = "http://www.site.com/page.html"; $data = file_get_contents($seed); $checked_links = array(); if (preg_match_all("/http:[^\"\s']+/", $data, $links)) { foreach($links[0] as $key => $link) { // check that the link has not been parsed already if(!in_array($link, $checked_links)) { // link has not been parsed we'll add it to the checked links array $checked_links[] = $link; $data_b = file_get_contents('http://www.site.com/sub/'. $link); if (preg_match_all("/http:[^\"\s']+/", $data_b, $links_b)) { @header("Content-type: text/plain"); foreach($links_b[0] as $skey => $sub_link) { // check that the sublink has not been parsed already if(!in_array($sub_link, $checked_links)) { // sublink has not been parsed we'll add it to the checked links array $checked_links[] = $sub_link; echo $sub_link . "\n"; } } } } } } ?> Notice: I changed your for loops to foreach loops. foreach loops are much easier to loop through arrays.
  23. Add each link you check into an array, call this array $checked_urls. Then every time you go to parse a url check whether that url has been parsed already using is_array. If its in the array skip to next url, else parse url.
  24. Could use ENUM
×
×
  • 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.