Jump to content

Porl123

Members
  • Posts

    239
  • Joined

  • Last visited

Everything posted by Porl123

  1. I made this function to verify images posted on profiles for this website I'm making and it seemed okay but I've just realised it's pretty slow if it's verifying more than 1-2 pictures on a single page and was just wondering if there are any ways of modifying my already made function or whether there's a better way all together. I'd prefer not to verify it with substr() or regex or anything of that nature because that just recognises the link extension and excludes things like php generated images which I'd rather not shut off if I can help it Anyway here's the function: function images($link) { list( , , $type) = @getimagesize($link); $a = 0; if($type == 1) { $a = 1; } elseif($type == 2) { $a = 1; } elseif($type == 3) { $a = 1; } elseif($type == 6) { $a = 1; } else { $a = 0; } if($a == 1) { $ret = $link; } else { $ret = ''; } return $ret; } if you can help out at all with this I really would appreciate it. anyway thanks! (:
  2. I've got a query that I'm trying to order by doing a sum with one of its fields and one array: $sql = mysql_query("SELECT `type` FROM `items` WHERE `username` = '".$username."' ORDER BY (($items[id]['price'] / 50) * (50 - `damage`)) DESC"); The problem is with the: $items[id]['price'] The $items is an array although the id for the [id] is the id of the item it's currently selecting with the query, but thinking about it it's obviously just going to see that [id] as its own field, rather than the field in the database Sorry if I'm not explaining this very well but I'm crappy with the terminology if anyone knows how I can get the query to to recognise it as the id field in the database could you help me? thanks in advance!
  3. I've got a database with 10 items in at the moment with IDs 1-10 and I was wondering if there's a way to distribute the chance of getting a certain item "SELECT type FROM items ORDER BY RAND() LIMIT 1" Is what I'm using at the moment but there's no distribution there. I need it to pick out one random item although I need it weighted to the lower end, so it's more probable to pick out items with lower IDs than higher. I'm making this in php/mysql if that helps. Can anyone think of any ways I can do this? I was thinking of adding a 'chance' field in the table with the values '1,10' and the next '11,30' and so on in descending ID order like this ID | TYPE | CHANCE 10 | type10| 1,10 9 | type9 | 11,30 8 | type8 | 31,60 Then I could get the highest value and the lowest value, explode them and get the appropriate numbers, then get a random number with mt_rand() and do a while loop throughout all the items, exploding the chance field and seeing where the random number lies. This does work but when new items are added, all the other chances have to be changed and it's just all around a lot of work. So I was wondering whether anybody could think of either a php or mysql way of getting around this. Thanks in advance for any help!
  4. Porl123

    Fonts

    I wasn't really sure whether this was php or html but I was wondering how about fonts. When you use a font with font-family: or font face="" it only lets the user see the font if they have the specific font in their fonts folder. I was just wondering if there was a way of uploading a font to your web space and linking it to a file so others can see it. If I'm way off please tell me thanks
  5. Yeah I thought of a few ways around preg_match but thinking about it preg_match can handle matching more than one at a time and identifies the line breaks
  6. Array ( [0] => /name message test test\r\n\r\nfollowing message [1] => name [2] => message test test\r\n\r\nfollowing message ) Almost had it again it's got the name but the following message is linked to the "message test test"
  7. Array ( [0] => /name m [1] => name [2] => m ) Not too sure about that one ^^
  8. Array ( [0] => /name message [1] => name [2] => message ) So close the message was "message test test" and it's cut off the test test
  9. Array ( [0] => /name message\r\n\r\nfollowingmessage [1] => name [2] => message\r\n\r\nfollowingmessage ) That's pretty much doing it but it's reading the followingmessage two lines down as the message to the name. any clue how I'd get that to not include after the line break?
  10. I was kind of hoping that someone could help me with this regex pattern I've been trying to write and failing it's for directing a comment at someone on the forums and would by typed out as: /username messageblablabla and would come out: <span style="color:cyan">TO: <b>username</b>: messageblablabla</span> I managed it by exploding the string and piecing it all together but it had the problem that I couldn't determine where the line break was, so it wouldn't carry on after it goes on to a new sentence. I thought my first way was a little impractical too so I was wondering if I could do this using preg_match If anyone can help me you're doing me a real favour because it's been racking my brain for hours. thanks in advance!
  11. I've just started using case switch instead of if else and already I'm having problems I was wondering if there's something wrong with this: I've got this function that returns the value 'Poor' when the $money variable is 0 and it should be 'Very Poor'. Anybody know why? any help will be appreciated! Thanks
  12. Ah, never knew that. I'll start converting them from now on :] thanks guys
  13. Is it necessary to convert, for example a '&' into a '&' if you were just coding it into the page yourself and it couldn't be interfered with by the user. I've read in a couple of places that it's vital but I just wanted to make sure, is it really necessary? I do filter all the user entered data with htmlspecialchars but if I've entered it myself I don't really see a point. Anyway, any help is appreciated. thanks!
  14. I've got this chat box which I'm currently using meta refresh to reload the chat in the iframe every 10 seconds, but it's using up too much unnecessary traffic so I was wondering if there's a way to do it in ajax by reloading the page when a message appears Anyone know any links which can help me with this? Thanks in advance
  15. I need to rotate the text in an image for a captcha. anyone know how to do that? thanks
  16. Both methods work great! thanks for all the help guys
  17. <? if($_GET['logout'] == 'yes') { session_start(); session_destroy(); header("Location: index.php"); } ?> Like that?
  18. sorry not pixels, bytes*
  19. Yeah I thought that too but it only gives the height and width rather than the pixels, so if a user adds an animated gif it still pretty much bones the page with lag
  20. is there a function that can do this for a URL rather than a path as it's an external image link i'm trying to validate to check that exceedingly large files aren't being set as users avatar images. thanks!
  21. <? mysql_query("UPDATE user SET V_Name='$_POST[v_name]', N_Name='$_POST[n_name]', Passwort='$_POST[passwort]', Email='$_POST', Admin='$_POST[admin]' WHERE U_ID='$_GET[iD]'"); printf(mysql_affected_rows()) ?>
  22. When it doesn't work in IE, what does it return if it returns anything?
  23. <?php $a = rand(1,9); $b = rand(1,9); while($b <= $a) { $b = rand(1,9); } ?> Might be long winded but that's how I'd do it
  24. i've got a forum where the user sets their little 80x80 avatar image, which is tagged at the side of every post from them. but i've got this problem with lag though. it just seems to take a while when someone has a picture that's over 100-200 pixels w/h so I was wondering if there are any techniques that I could use to make it so the page doesn't lag so much i don't really want to restrict the user from posting an image that's over 80x80 pixels as it just adds work for them, so if you know of any methods i'd really appreciate the help. thanks !
  25. Ah that's the problem, it's an external link
×
×
  • 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.