Jump to content

verycleanteeth

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

verycleanteeth's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've got the following code which is intended to create a thumbnail of an uploaded image. I'm getting an image of the the appropriate size, and it's saving it properly, but the images are nothing but black. if ($extension == 'gif') $src_img = imagecreatefromgif("$image_path/$image_name"); else $src_img = imagecreatefromjpeg("$image_path/$image_name"); if ($img_width > $thumb_width) $new_w = $thumb_width; else $new_w = $img_width; $image_name = str_replace('.gif', '.jpeg', $image_name); $diff=$img_width/$new_w; $new_h=$new_w; if ($extension == 'gif') $dst_img = imagecreate($new_w,$new_h); else $dst_img = imagecreatetruecolor($new_w,$new_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); if ($extension == 'gif') imagegif($dst_img, "$thumb_path/$image_name"); else imagejpeg($dst_img, "$thumb_path/$image_name"); This is my first time playing with the PHP image creation functions, so I'm sure I could be missing something very basic. Any help is appreciated! Thanks!
  2. Thanks for the suggestions. According to this http://us3.php.net/mysql_fetch_object I should be able to specify a class name as the second parameter to mysql_fetch_object and have the functions automagically added to my database fetched objects, but I could not get it to work properly. I've ended up using the last suggestion and using mysql_fetch_assoc to get an array and then using a constructor method to iterate through each each array item and add it to the object. <?PHP class char { function char($char) { foreach ($char as $key => $value) $this->$key = $value; } } $query = "SELECT * FROM $table WHERE ID IN ($get_char_list)"; $result = mysql_query($query); while ($char = new char(mysql_fetch_assoc($result))) { //do stuff } ?> This seems like a rather dirty workaround. I'd much rather use the mysql_fetch_object function, but this at least works.
  3. Hello! I'm a bit new to OOP and am trying to find a way to add functions to already existing objects. I'm pulling tables from a mysql "character" database with mysql_fetch_object, and these objects are organized just how I need them, except they lack the functions normally defined in the "character" class. Thanks!
  4. Wouldn't you have to retrieve all the rows to do that though?
  5. Okay, I wasn't sure whether this should go under the MySQL forum or here, because I'm not sure where the solution lies. Basically I've got a MySQL database with a Users table, and this table has a 'Points' column. I want to find the quickest, most efficient way to determine where this user ranks in relation to other users. Something like 'There are 250 users with more points than you'.
  6. Thank you. The sleep function is precisely the sort of thing I was looking for
  7. The problem with those solutions is I need this script to run even if no one is actively watching it. If people want they can watch the race "live", or they can wait until it's over and read a transcript of what transpired. If I rely on a javascript refresh or a header refresh, and no one is watching the race happen, nothing will fire. I hope that makes sense.
  8. I'm creating a racing simulation in PHP that I want to run in semi-real time. I'll explain. A bunch of people sign up for a race. They sit and stare at a page that updates about every 10 seconds with the new positions of all the racers and some details about the race. Now the rub. How on Earth do I set up a script that will run every 10 seconds and do what I need it to do? I've read that cron should only be used for things spaced a bit further apart. My service provider specifically requests we don't have any scripts that run within 5 minutes of themselves.
  9. Good to know I'm on the right track. I'll actually be doing quite a bit of listing the entire inventory. People like seeing their entire heaping collection in one, well, giant heap. And inventory limits are no fun! It's gonna be fun restructuring my code to take advantage of the new table structure! Thanks for the reply.
  10. This is a database structure question. I've got a game where you have a character. This character has an inventory. Right now there are only about 100 items this character can acquire, but this number will only increase. I currently have an inventory table with a unique Character_ID column, and then 100 columns, one for each item. It looks something like this: Character_ID | i1 | i2 | i3 | i4 | i5 | i6 |..........etc. 94 |0 |5 |2 |99 |1 | 0 |...........etc. here character 94 has 99 of item i3 and 0 of item i1. Okay. I know this isn't the proper way to set up an inventory. If I one day have 1000 unique items, I don't want a table with 1000 columns. What is the best way to set this up? I could have another table that looks something like this: Character_ID | item | quantity 94 | 2 | 5 94 | 3 | 2 94 | 4 | 99 94 | 5 | 1 but that seems like it would also get unwieldly quickly. Without an index I'll be doing queries like "SELECT * FROM inventory_table WHERE Character_ID = '94'". If I have 10,000 users with 1000 items each that's 10,000,000 cells of data. These queries are going to be slow. So, yeah, any suggestions?
  11. I'm designing a web based game. Each player has 3 characters, and each of those characters can have a myriad of skills. I'm currently storing the skill data as a serialized array in the character table, but i'm wondering if this is inefficient. I know I could have a seperate table with character IDs and skill IDs and just use joins, but I would end up with a huge number of rows eventually.
  12. That's exactly what I was looking for! Thanks Ken.
  13. I know this should be easy to do, but I'm just not sure how. I've got a string storing some HTML like so: [code] $mess = ' <table id="sometable">     <tr>     <td>         <table id="thatguyfromwham">             <tr>             <td>                       stuff to read             </td>             </tr>         </table>     </td>     </tr> </table> ';[/code] Is there a function I can call to strip all the line breaks out? My table is showing up right now with all sorts of extra whitespace because of all the extra lines, and I want to keep the HTML readable.
×
×
  • 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.