Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Not that i'm aware of. While mysql does have support for regular expressions and wildcards, they can, as far as i know, only be used in the context of the WHERE clause. I would also be questioning your database structure if you have 6 fields named q1-q6. Perhaps its necessary, but it sounds like you need to take a look at database normalization.
  2. Bad idea. If you were considering doing something like that, i suggest that you read up on database normalization. You could see this thread for starters: http://www.phpfreaks.com/forums/index.php/topic,126097.0.html And there would actually be over 5000 columns in your table.
  3. If you're just matching strings, substr_count() might be more appropriate. It would remove the need for the regular expressions.
  4. I'm aware of that, and i wasn't criticising your response.
  5. Im afriad your code isn't really anything like the examples given. Some of the things missing: 1.) You need to specify an ENCTYPE of "multipart/form-data" in the form tag 2.) You need a form field called MAX_FILE_SIZE 3.) The information regarding files is contained in the $_FILES superglobal, not $_POST See: http://uk2.php.net/manual/en/features.file-upload.php for an example form and example php.
  6. Err..why bother? There's nothing dynamic going on, so just access the png directly: <html> <body> <img src="http://www.example.com/test.png"> </body> </html>
  7. Two things occur to me. Firstly, does the string '#RES' ever occur outside of the part of the text file you are interested in? If not, i suggest you read the file as a string, and find out where the first and last occurances of this are, swe we're not dealing with lots of redundant data. Second. You say your function may get called around 200 times. Why is that? Is that because you are are working out totals for 200 different categories? If so, then your code is very inefficient The first part of the function is being repeated unnecessarily. The part that generates the array of values only needs to happen once, it is just the totalling which needs to be repeated.
  8. Eugh, system recovery. My mum's partner is forever using this tool, for no apparent reason. Im sure its the reason why he has so many problems with his computer, which I then have to fix. Anyway, I havn't used system recovery in a while, but don't you get the option to roll back to various dates? Perhaps its worth trying to roll back to a date futher in the past. If that's not helping, any chance of getting to the boot menu? The 'last known good configuration' does occassionally work.
  9. Having said that, if you're just going to be using smilies, and no bb tags, str_ireplace would be more appropriate: <?php $patterns[] = ''; $patterns[] = ''; $patterns[] = ''; $replacements[] = '<img src="path_to_happy_face />"'; $replacements[] = '<img src="path_to_sad_face />"'; $replacements[] = '<img src="path_to_very_happy_face />"'; $string = str_ireplace($patterns,$replacements,$string); ?>
  10. Almost. You need preg_replace. You can also use an array of different patterns and replacements: <?php $patterns[0] = '|:\)|'; $patterns[1] = '|:\(|'; $patterns[2] = '||i';//case insensitive $replacements[0] = '<img src="path_to_happy_face />"'; $replacements[1] = '<img src="path_to_sad_face />"'; $replacements[2] = '<img src="path_to_very_happy_face />"'; $string = preg_replace($patterns,$replacements,$string); ?> If you add to that, make sure the key of the pattern matches with the key of the replacement.
  11. Ok, i see. The substr() function is your friend: <?php $str = ':Hello'; $str = substr($str,1); echo $str;//Hello ?>
  12. Alternatively, replace this line: list($_cat, $_bool, $_id, $num) = explode("\t", $line_value); With: list($_cat, $_bool, $_id, $num) = preg_split("/(\t| )/",$line_value); That way the function wont require an extra parameter, and wont care if the file is space or tab delimited.
  13. Im afraid not. The 4th (and optional) parameter of the str_replace() function is the name of variable that you wish to store the number of replacements made.
  14. I'm a little confused. If the user does not type the first colon, where does it come from? Perhaps showing us some of your code (using tags) will help
  15. Hmm, i was under the impression that, since none of us are god, asking a question is in fact the same as asking an opinion.
  16. You may also wish to multiply by a weighting factor. For example, you may consider that views are less important than the other factors. The query would be something like: SELECT (downloads+installs+views*0.5+comments) as total FROM table ORDER BY total DESC
  17. Well, you'll need a script that actually has an error in: <?php $foo = 'foo' $bar = 'bar'; ?> Parse error: parse error, unexpected T_VARIABLE in wherever on line 3
  18. Perhaps i misunderstood. I thought you were trying to generate an error by using an undefined function.
  19. That is normal behaviour. Having no closing tag doesn't cause an error in PHP (as long as there is nothing after it)
  20. Try: <?php $db2con = "main"; include "../../scripts/c2d.php"; $queryMAIN = mysql_query("SELECT * FROM stores") or die(mysql_error()); $numstores=mysql_num_rows($queryMAIN); $locname = array(); if($numstores > 0){ while($row = mysql_fetch_assoc($queryMAIN)){ $storeid = $row['id']; $storename = $row['location']; $locname[$storeid] = $storename; } } echo '<pre>'.print_r($locname,1).'</pre>'; ?>
  21. I would suggest four tables, in addition to your users table, for this: captured_fighters id - primary key, auto increment userid - links to users.id fighterid links to fighters.id fighters id - primary key, auto increment fightername any attributes of the fighter - speed, strength etc attacks_taught id - primary key, auto increment attackid - links to attacks.id capturedfighterid - links to captured_fighters.id attacks id - primary key, auto increment attackname attributes of the attack - damage, type etc Without knowing the details of the game, i've had to be a bit vague. But i would imagine it would be similar to the above.
  22. Stunning attitute there. Last time i checked this was a forum, which, as far as im aware, involves the sharing of opinions. Since you didn't bother to state in the topic that you understood that the general opinion would be that it was a bad idea, how can you possibly expect people to know that? Correcting the minor gramatical mistake just adds to the rudeness of the reply.
  23. Isn't that slightly naive? Just because you don't find a use for it, does not mean it is not useful.
  24. 1.) Aside from the fact you may well be breaking copyright, you can use one of the imagecreatefrom functions (www.php.net/imagecreatefromgif, www.php.net/imagecreatefromjpeg etc) and save the image 2.) There are numerous restrictions on file upload, which you can modify. For example, a file upload form should have a hidden field containing the maximum file size, and the php settings max_execution_time, memory_limit and upload_max_filesize may all need to be edited.
×
×
  • 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.