Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Everything posted by Wolphie

  1. add echo $_FILES['yourfile']['error']; somewhere in your code, to see what the error is.
  2. You can use $_SERVER['DOCUMENT_ROOT'] to get the path of the webservers root directory. include(dirname($_SERVER['DOCUMENT_ROOT']) . DIRECTORY_SEPARATOR . 'includefile.php');
  3. http://php.net/manual/en/control-structures.goto.php
  4. First of all, are you sure that mysql_num_rows($rsCartSQL) is returning a positive integer higher than the loop starting point? Secondly, why are you starting the loop at 1?
  5. You could use sessions. When the user makes the page request you can start the looping process and use a sessions variable to store which iteration the loop is at. If there Internet connection drops, the session variable would stay the same until the user comes back. This is a very very basic way of doing it: <?php session_start(); $start = isset($_SESSION['iteration']) ? $_SESSION['iteration'] : 0; for ($i = $start; $i <= 200000; $i++) { echo $i; $_SESSION['iteration'] = $i; } ?>
  6. Log in as root and change the usergroup and username (if necessary to correspond to the apache files) using chmod and then trying moving it to the httpdocs folder. If you can't move it, login as the apache user (su - username) and then try moving it again.
  7. I agree, although in the context it's being used, it's unlikely a character will be named 0.
  8. Instead of using strlen() you should use empty(). Returns FALSE if var has a non-empty and non-zero value. The following things are considered to be empty: "" (an empty string) 0 (0 as an integer) "0" (0 as a string) NULL FALSE array() (an empty array) var $var; (a variable declared, but without a value in a class)
  9. I'm unsure as to what you mean? Surely if you have data inside a MySQL database you would use PHP MySQL function to update and manipulate the data within the MySQL database.
  10. The only way to do that would be to make an array which stores the variable names. <?php $var_name = array('totalcorrect', 'totalitems', 'pctcorrect', 'appcount'); foreach ($var_name as $name) { ${$name} = 0; } ?> So this still involves a bit of manual work.
  11. I guess the easiest way would be to use: <?php $num_of_vars = 10; $prefix = 'var'; for ($i = 0; $i <= $num_of_vars; $i++) { ${$prefix . $i} = 0; } ?>
  12. From what I can make out from your description, this should work. <?php $filename = "x.txt"; if (file_exists($filename)) { $contents = file_get_contents($filename); if (!empty($contents)) { echo '<a href="'. linklokurl(htmlspecialchars($contents), 0, 1, 0)) .'">Download Here</a>'; } else { trigger_error('The file <strong>'. $filename .'</strong> is empty.', E_USER_WARNING); } } else { trigger_error('The file <strong>'. $filename .'</strong> does not exist.', E_USER_ERROR); } ?>
  13. file_get_contents() gets the contents of the file in question. It won't make it available for download. I'm mystified about what you're exactly trying to achieve here.
  14. If she were a decent wife, you'd always be talking over her head, as she'd be down on her knees giving you a ... +1
  15. Not a problem please mark the topic as solved! Thanks.
  16. Have you set the file to write permissions (777)? You must be able to write to the file. I did actually modify the code in my previous post because it wasn't working at first, so you may have copied over the old code. It does definitely work now though, I've tested it. A revised version: <?php $filename = 'path/to/file'; // Check file exists if (file_exists($filename)) { if (isset($_POST['memberbanner'])) { // You may want to add additional sanitizing to this for security $banner = trim($_POST['memberbanner']); // Get the contents and use preg_replace() to replace the text between the <banner> tags $contents = file_get_contents($filename); $contents = preg_replace('/<banner>(.*?)<\/banner>/', '<banner>' . $banner . '</banner>', $contents); file_put_contents($filename, $contents); } } else { trigger_error('The file <strong>'. $filename .'</strong> does not exist.', E_USER_ERROR); } ?> That works perfectly fine for me.
  17. Have you tried using a full path instead of a URL? When using the function file_exists() you must use a local path rather than a URL. I.e. /usr/www/htdocs/site.com/xmlfile.xml
  18. Well to change a files owner and group the command is: chown username:usergroup somefile.php Is that what you're after?
  19. This works for me if I'm understanding you correctly: <?php $filename = 'file.xml'; // Check file exists if (file_exists($filename)) { if (isset($_POST['memberbanner'])) { // You may want to add additional sanitizing to this for security $banner = trim($_POST['memberbanner']); // Get the contents and use preg_replace() to replace the text between the <banner> tags $contents = file_get_contents($filename); $contents = preg_replace('/<banner>(.*?)<\/banner>/', '<banner'> . $banner . '</banner>', $contents); // $filename MUST be writeable for this to work file_put_contents($filename, $contents); } else { echo 'Please enter banner text...'; } } else { trigger_error('The file <strong>'. $filename .'</strong> does not exist.', E_USER_ERROR); } ?>
  20. I'm not really sure why you're using the file() function within the implode() function to pull the contents of a file and put it into a string. The function file_get_contents() does this already. <?php $filename = '/path/to/hi.txt'; // Check to make sure the file exists // If it does, then continue, otherwise produce an error if (file_exists($filename)) { // Get the entire contents of the file as a string $contents = file_get_contents($filename); // Populate the text area with the contents of the file echo '<textarea>' . htmlspecialchars($contents) . '</textarea>'; // Is htmlspecialchars() strictly necessary?! } else { echo 'The file <strong>' . $filename . '</strong> does not exist.'; } ?>
  21. I managed to get it working using this code: <?php $filename = '/path/to/battlegroups.xml'; if (file_exists($filename)) { $xml = simplexml_load_file($filename); // Print battlegroups foreach ($xml->battlegroups->battlegroup as $battlegroup) { echo '<h1>' . $battlegroup['display'] . '</h1>'; // Print realms for each battlegroup echo '<ul>'; foreach ($battlegroup->realms->realm as $realm) { echo '<li>' . $realm['name'] . '</li>'; } echo '</ul>'; } } ?>
  22. I think an XML file would be more ideal since you can easily use PHP's XML parser to parse different parts of the document.
  23. Granted, I can agree if that is the case. However, from my understanding and the OP's description it seemed more like a twitter post. I.e. only a single post appears at a time, thus making it easy to update and remove. For this a database is just over-complicating matters. That is just an assumption, though.
  24. Personally, for such a small thing I would just use a text file to store the data. Check out: http://uk3.php.net/manual/en/function.file-get-contents.php http://uk3.php.net/manual/en/function.file-put-contents.php
  25. The easiest way would be to create a web-based form for them to use where they can enter some text and it gets inserted into a database or a text file. Then you could pull the text from either the database or text file and display it on your web page.
×
×
  • 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.