Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. It creates a really ugly form, but this would work for building the form (I haven't tested, so I can't guarantee there's no syntax errors): $result = mysql_query("SELECT * FROM sections ORDER BY Display_ID DESC"); echo '<form method="post">'; while ($data = mysql_fetch_array($result)) { echo '<br /> Name: <input name="row[' . $data['id'] . '][Name]" value="' . $data['Name'] . '"><br /> Description: <textarea name="row[' . $data['id'] . '][Description]">' . $data['Description'] . '</textarea><br />'; echo str_repeat("-", 20); } Then on the processing side: foreach ($_POST['row'] as $DisplayID => $data) { $query = "UPDATE tablename SET Name = '" . $data['Name'] . "', Description = '" . $data['Description'] . "' WHERE DisplayID = " . $DisplayID; mysql_query($query); } This isn't a good solution because you will be updating each and every row each time the page is submitted. So, if there are 1000 rows, and only 1 gets updated...that means 999 unnecessary updates.
  2. Use a join to get the data into a single query... SELECT players.*, awards.name FROM players, awards WHERE players.id = awards.player_id ORDER BY name, dkp, class
  3. Get the text of your article, then use substr to get just a few characters and add a link at the end to the full article.
  4. Check out array_multisort http://www.php.net/array_multisort Also, if you are querying this data from a database, why not use SQL to sort?
  5. use the file_exists function http://www.php.net/file_exists
  6. I don't see anything particularly wrong with the code...mostly just html. You can turn on php error reporting by placing the following at the very top of your page: <?php ini_set("display_errors", 1); ini_set("display_startup_errors", 1); error_reporting(E_ALL); ?>
  7. I'm guessing since you're using alpha software (MySQL 6.0.2), that could be a major cause of your problems. Have you checked their bug reports? I haven't played with MySQL 6 yet, but I would imagine that it's much the same as MySQL 5 in that if the InnoDB table spaces do not exist, then it will attempt to create them upon first run. Check your my.cnf / my.inf and make sure that the location for your data files is defined, delete any current table space files (for innodb) and restart the daemon / service.
  8. You fix the parse errors by not writing incorrect code. If you want better help, tell us what the errors are. If you want even better help, include your source code.
  9. Actually, you did ask that question. Anyway, look in the manual: http://www.php.net/file-upload If you aren't handling uploads, then look into the file functions...fopen, fwrite, fclose.......
  10. You are assigning $mail to be equal to an array, then you are appending a string onto the end of that. When php converts an array into a string(which is happening when you are appending a string to the end of $mail, which to start with is an array), it is converted to simply "Array". You can get rid of the "Array" at the beginning by simply not using $mail as the variable to store the $_POST['mail'] array. In fact, why reassign that array to another variable anyway? Use the recommendation by xyn:
  11. This is called heredoc syntax: http://us.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc What else would you consider "advanced"? Type casting is one of the basics in any statically typed language (php is dynamic). Heredoc is used extensively by perl programmers.
  12. SELECT DISTINCT(IP) FROM tablename WHERE url = 'www.phpfreaks.com'
  13. I think if you have no output buffering, and you echo the html to the browser first, then execute whatever code takes 20 seconds, the browser will receive the initial html, then wait for more while the remaining code executes. I haven't tested it, but it works in my head.
  14. Use the seek functions... http://www.php.net/mysql_data_seek
  15. If you want to preserve the spacing at the beginning of a line, you'll have to wrap the string in pre tags, or replace the spaces with ... $string = "this is a string with random spacing"; echo "This is the unadulterated string: <br />" . $string . "<br /><br />"; echo "This is the string with pre tags:<pre>" . $string . "</pre><br /><br />""; echo "This is the string without pre tags, but with formatting: " . nl2br(str_replace(" ", " ", $string)); Remember that unless you use a monospace font (e.g. Courier New) the characters won't line up.
  16. I would try using exceptions to catch the error / "exit" when the curl operation fails. http://www.php.net/exceptions You could also separate the code that checks the feed and inserts / deletes from the db into a file that can be executed independently...then have a controller script that forks off additional, background, processes to do the work...it would probably be faster, and it wouldn't kill the overall script. Cacti does this with it's snmp polling functionality.
  17. $Commentdate = date("M j, Y, g:i a T", mktime() - (3600 * 6));
  18. Have you read the php manual about Image Magick and the Imagick functions... http://us2.php.net/manual/en/ref.imagick.php http://us2.php.net/manual/en/imagick.install.php It does require php >= 5.2.1
  19. http://pear.php.net/manual/en/introduction.php
  20. Those are the mime types... http://en.wikipedia.org/wiki/MIME http://www.php.net/mime-magic
  21. Is the .so file readable / reachable by the apache user? Do an su to the apache user, cd to the directory and see if you can access the directory. Not sure which OS you're using, but I usually check to make sure it can load correctly using 'ldd' in solaris.
  22. Use the dir functionality to read the file names into an array: <?php $d = dir("."); while (false !== ($file= $d->read())) { if (substr($file, -4, 4) == ".htm" || substr($file, -4, 4) == ".php") { $links[] = $file; } } $d->close(); ?>
  23. You can put checkboxes in a sub array of $_POST and you can define values for them. However, the way you have your code setup, they won't necessarily be in the same order each time...from your snipped, if I check all three boxes, then they will be available at array index positions 0, 1, and 2. However, if I chose only the last 2, then they will still be in 0 and 1, but not 2...you need to force them to be in the place you want... Brunch <input type="checkbox" name="activity[0]" value="brunch" /> <br />Dance <input type="checkbox" name="activity[1]" value="dance" /> <br />Game <input type="checkbox" name="activity[2]" value="game" /> Remember that with checkboxes, if they box isn't checked, it's not included with the POST at all.
  24. How often is the data updated? If it's frequently updated then your users have the potential to get out of date data, which is probably bad. Additionally, what do you mean by "a large amount of pages"? Every single time you click the mouse at this website, i.e. phpfreaks, it hits the database several times to generate the page, so unless you have an underpowered database, it shouldn't be that big of a deal to generate the page each time.
×
×
  • 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.