Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. What exactly do you want? Do you want it to display in the file the way it does in a browser?
  2. That "echo 1" and "echo 0" should be "return 1" and "return 0". Then the $ok assignment makes sense. PJ, you'll need to give us some more information about how the script doesn't work for use to help. Printing out your sql queries before running them would be a good start, as you can manually verify them.
  3. Try this code: <?php if (is_numeric($_GET["i"])) { $file = file("stats.txt"); $init = chop($file[$_GET["i"]]); list($name, $num) = explode(",", $init); $num++; $file[$_GET["i"]] = implode(",", array($name, $num)) . "\n"; # $file is now updated - write it back $fp = fopen("stats.txt", "w"); foreach ($file as $line) { fwrite($fp, $line); } fclose($fp); } else { print "'i' was not set"; } ?> The chop() is related to the newline character, which separates lines in a file. It strips it off. Then on the implode() line I add it back in.
  4. Aha. $c{$c + 1} actually takes the $c+1'th character of the string $c, which doesn't make much sense at all, and that's why php gives you a warning. You can do this: $cname = "c" . ($c + 1); $$cname = 'blah'; The double $$ does the "evaluated variable name" thing (aka "variable variables"). Also do what sasa suggested .. otherwise you are re-executing the sql every time around the loop, which will have you loop forever.
  5. Which part of the if/else does the text just before the error belong in? Try moving it inside the appropriate one.
  6. Well "shell access" is a term for hosting usually. It means you can use the command line. If it's your own machine then of course you can use the command line
  7. Do you have shell access on this machine? If so you can use the "chmod" command to change permissions. Can you give a bit more detail about the setup? Is it hosted or on your own machine? Another option could be to use another writeable folder to create your lock file instead. /tmp is a good bet. That's not very secure though (if other people could also be writing to /tmp)
  8. That lad should be up between the head tags, but it should work anywhere. What code are you using to call the form validation from the submit button?
  9. Are you trying to read from and write to these files from php and getting permission denied? Are they files you created through some kind of admin interface or uploaded through ftp? If so the files may be owned by a different user to the one that your script runs as. That's my best guess given limited information. Don't worry about the .htaccess if this is the issue - .htaccess doesn't control these things. If you can show your code (or the relevant parts) that might help.
  10. It won't be slower in php than in any other language .. if it's a slow task then it's a slow task Yes, command line programs can be called from php (this may not be true if you use a hosting provider with restrictive security policies). system() and exec() are some of the interfaces.
  11. Wait wait wait! No moving on just yet Have you got an index on the username column on your users table? You shouldn't need to break the table up like that to get adequate performance. You may also need indexes on other values if you do frequent lookups by those values.
  12. Try removing the "&" symbols from your two inner loops: for ($g = &$startint; ... These ones ^^^
  13. Try file_get_contents() instead of readfile(), if you want the contents of the file as a return value.
  14. I tried the code on my server and it didn't exceed execution time. Theres 2 avenues I would investigate 1. Is the function itself being called infinitely many times in a loop from somewhere else? 2. Can you log to a file all the variables being unset (just before you unset them) and see if there's a specific one that causes it to loop?
  15. Edit: Oops, you marked it I see Will reply in a moment..
  16. This is the postgresql forum (and your topic will be moved over to the mysql forum shortly), but the answer is the same. SELECT * FROM t1 LEFT JOIN t2 USING (serial) This query will combine rows from t1 and t2, matching them up by the serial value. If there's no match, then t1.serial will be set but t2.serial will be null. So if you want all serials from t1 that aren't in t2 you just need to do this: SELECT * FROM t1 LEFT JOIN t2 USING (serial) WHERE t2.serial IS NULL Or "SELECT t1.serial" if you just need the serials.
  17. It sounds like you can use "group by" for this. Eg SELECT a1, a2, a3, a4, count(*) FROM tab GROUP BY a1, a2, a3, a4 HAVING count(*) > 1 That will give you a list of all sets of answers which appeared more than once in the table, and a count of each. Is that what you want?
  18. btherl

    Question

    Can you post your code? It's most likely a problem in your code.
  19. rand(1,10) will give you a random number between 1 and 10.
  20. Try this: foreach ($rssfeeds as $a) { include ("http://www.indianasheep.com/scripts/rss/rss2html.php?TEMPLATE=output.php&XMLFILE=".$a."&MAXITEMS=10")."<br><br>"; } That is, remove the "echo"
  21. There's 2 problems I can see there. First, in your form processing script you need to fetch the input data like this: $suffix=mysql_real_escape_string(stripslashes($_REQUEST['suffix'])); The extra functions there ensure that you can't have your database modified by sql injection attacks. And secondly, you have several forms on your page. There should be just one big form. There's a php freelancing forum here if you want professional help (not everyone who responds may be a professional of course!)
  22. I'm not sure if this is just the words, but it's not multi-column indexes I'm suggesting, it's multiple single-column indexes. A multi-column index is like CREATE INDEX tab_id_name_idx ON tab (id, name) Multiple single column indexes CREATE INDEX tab_id_idx ON tab (id) CREATE INDEX tab_name_idx ON tab (name) The multi-column index is usually only useful for queries involving id, but the two seperate indexes can also be used for queries on name, as well as queries on both name and id.
  23. You can put one index on each column (eg, if you have 10 columns then you have 10 indexes). This means that an insert or update must update all 10 indexes though, so insert and update will be much slower. If you are using a recent version of postgres then multi-column searches can also take advantage of multiple indexes.
  24. btherl

    Query Time

    If you are using psql, you can use the \timing command. If you're using an interface from php, it's probably good enough to just time how long the query takes in php. The microtime() function is good for that.
×
×
  • 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.