Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. Stupid question, but, is "/logfiles" a directory named "logfiles" in the root partition of your server, or is it a folder in the docroot of Apache? What is the exact error given?
  2. By putting a space in your variable, the same as you would any other time: $cmd = '/usr/local/bin/lame -b 112 /home/site/public_html/temp/' . $mp3file . ' /home/site/public_html/temp/112_' . $mp3file;
  3. I think we should all recommend nl2br again. Also, br2nl isn't a (predefined/builtin) function
  4. File system is usually better. If the db is on a different server, it must cross the network twice, additionally, db storage is almost always more expensive than web storage. If you use a blob field in you db, you must also be more careful with your SQL...doing SELECT * FROM users ORDER BY username WHERE create_date = TODAY() or any other SELECT that includes the blob field with an ORDER BY will force mysql to do a file sort which is much much slower.
  5. This will be faster with a larger number of items in the $outcomes array: for ($i = 0; $i < count($outcomes); $i++) { if (!$streaks[$outcomes[$i]]) { $streaks[$outcomes[$i]] = 1; $current_streak = 1; } if ($outcomes[$i] == $outcomes[$i + 1]) { $current_streak++; if ($current_streak > $streaks[$outcomes[$i]]) { $streaks[$outcomes[$i]]++; } } else if ($outcomes[$i] != $outcomes[$i + 1]) { $current_streak = 1; } } With 10 entries, they are about the same, with 100 entries the above is about 2.5 times faster. <?php $possible = array('win', 'tie', 'loss'); while (count($outcomes) <= 100) { $outcomes[] = $possible[array_rand($possible)]; } $start = microtime(); for ($i = 0; $i < count($outcomes); $i++) { if (!$streaks[$outcomes[$i]]) { $streaks[$outcomes[$i]] = 1; $current_streak = 1; } if ($outcomes[$i] == $outcomes[$i + 1]) { $current_streak++; if ($current_streak > $streaks[$outcomes[$i]]) { $streaks[$outcomes[$i]]++; } } else if ($outcomes[$i] != $outcomes[$i + 1]) { $current_streak = 1; } } echo 'completion time for method: ' . (microtime() - $start) . ' seconds<br />Result:'; echo '<pre>' . print_r($streaks, true) . '</pre>'; $start = microtime(); $outcome_types = array ('win', 'loss', 'tie'); foreach ($outcomes as $outcome) { foreach ($outcome_types as $type) { $tmp[$type] = ($outcome==$type)? $tmp[$type]+1 : 0 ; $streaks[$type] = ($tmp[$type]>$streaks[$type])? $tmp[$type] : $streaks[$type] ; } } echo 'completion time for method: ' . (microtime() - $start) . ' seconds<br />Result:<br />'; foreach ($outcome_types as $type) { echo "The $type streak is: $streaks[$type]<br>"; } //echo '<pre>' . print_r($outcomes, true); ?> increasing the number of entries keeps the ratio about the same. EDIT: I did test with a larger number of possibilities...6 to be exact: win, loss, tie, one, two, three. This makes the time difference even larger: almost 5 times faster. Although I don't know why you would have six possible results.....
  6. so long as the host name is in DNS correctly, it doesn't matter
  7. Do you download them from the same server? The connection from "www.filesite.com" may be slow to your server.
  8. Try pathinfo or realpath. http://www.php.net/pathinfo http://www.php.net/realpath
  9. Technically, if the folder is owned by the web user, then you can set the permissions to 600 and be able to read and write files to it.
  10. Make sure display errors is on: error_reporting(E_ALL); ini_set('display_startup_errors','1'); ini_set("display_errors", 1); Also, I think you need to instantiate a class with parenthesis: $mail = new MyMailer();
  11. set error reporting to all: error_reporting(E_ALL); ensure display errors is on: ini_set("display_errors", 1); I think that you can also use __LINE__ to display the line in the php file. http://us2.php.net/manual/en/language.constants.predefined.php
  12. Make sure that the action of your form tag is the name of your script...or leave it out...or set it equal to $_SERVER['PHP_SELF']. Also, I'm not sure, but I think you may need to remove the spaces between the attribute="value" in your html tags. <form action = "Ass2.php" method = "post"> maybe should be: <form action="Ass2.php" method="post">
  13. Use mysql's "SELECT ... INTO outfile" command to create a CSV http://dev.mysql.com/doc/refman/4.1/en/select.html#id3180150
  14. should be something like: echo substr($string, 0, 5) . "1" . substr($string, 6, strlen($string) - 6);
  15. If you are using htaccess for authentication control, you can't have php tell apache that a user is authenticated...Apache will see, and utilize, the htaccess file before it even opens the .php file to read it and see what's in it. You may be able to play with the authentication headers, if you redirect the user from a php file to your protected file, and see if that will work...this may help: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.8
  16. I'm not sure, but it may be your array merge line: $category = implode("|", array_merge($_POST["category"], $_POST["category2"])); Try changing it to: $category = $_POST["category"] . "|" . $_POST["category2"]; Unless both of those are arrays and not just array elements.
  17. 3MB is a lot of queries to execute over the network...my house has 6mb down / 512 kb up, with those numbers it takes the server 60 seconds just to get the SQL file from me, then if it is executing the commands on another remote host, that adds additional execution time, plus the time that the DB server takes to execute the commands. Executing the commands can take a long period of time depending on a lot of things...number of indexes vs. number of inserts, etc. There isn't a max size for a single variable, but there is a max size that the script can occupy in memory.
  18. The headers must end with "\r\n". $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: contact@test.com' . "\r\n"; //<-----------
  19. Nearly all of the injection prevention is handled by php, not the database, so it shouldn't matter if you are using MySQL or Access. Many times authors will recommend mysql_real_escape_string...you can use addslashes almost as effectively with ODBC since there is no equivalent, assuming magic_quotes_gpc isn't turned on. http://www.php.net/addslashes
  20. You need to specify html headers: // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; http://www.php.net/function.mail#id3102134 You could also use phpMailer, or a similar class. http://phpmailer.sourceforge.net/
  21. Check the value of $_FILES['field_name']['error']. If the file size exceeds the value set for max_upload_size in php.ini it will be equal to 1. If it is bigger than max_file_size it will equal 2. http://us.php.net/manual/en/features.file-upload.errors.php
  22. Try forcing it to throw an exception on error: try { $dbPDO = new PDO('mssql:host='.$db_myHost.';dbname='.$db_myDatabase, $db_myUser, $db_myPassword); $dbPDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo "Error!: " . $e->getMessage() . " "; die(); }
  23. If you want someone to write something for you post in the freelancer's forum. http://www.phpfreaks.com/forums/index.php/board,8.0.html
×
×
  • 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.