Jump to content

Goose87

Members
  • Posts

    113
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Goose87's Achievements

Member

Member (2/5)

0

Reputation

  1. Is it just me or is the code below wrong? $owner = $_SESSION['id']); Remove the bracket and maybe that would help. Like Magnetica said: Just try a print and see if a value comes out. If it does, then the query might be wrong, if it doesn't, then there's something wrong earlier on..
  2. Could anyone look at my code and help me out with this one? Thanks a lot
  3. Ok... my current code that I'm using from a script is below. I haven't managed to add a resizing feature yet. I also modified it to only accept PNGs because it caused problems when displaying it ( I had a file that was $userID.jpg and $userID.jpg and it didn't know which one to show ) I solved the resize problem by just forcing the image, when being displayed, to be fixed to height 200 and width 150. This obviously causes resizing problems, but I'm assuming the users can deal with that problem, as I don't really know what I am doing... <?php include("includes/header.php"); echo "<p class='h1'>Upload an image</p>"; echo "<span class='content_text'>"; //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","30"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "png")) { //print error message echo "<p class='h2'>Your image must be in PNG format.</p>"; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo "<p class='h2'>You have exceeded the size limit!</p>"; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=$user_id.'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="images/profile_avatar/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo "<p class='h2'>Copy unsuccessfull!</p>"; $errors=1; include("includes/footer.php"); }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { @mysql_query("xxxxx"); // HERE I ADDED A QUERY TO SET A VALUE IN THE DB TO 1 TO LET THE PROFILE PAGE KNOW THERE IS AN IMAGE THERE.. echo "<p class='h1'>File Uploaded Successfully!</p>"; include("includes/footer.php"); } ?> <div align='center'> <table width='400'> <tr class='bg1'> <td> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> </td> </tr> </table> How does that look? Any advice?
  4. Ok, before anyone gets angry because I'm typing a question that has 1 million posts on the web about, I am posting because I am merely confused.. Every single website I look at uses different methods and has strange functions I am not aware of. I will explain what I need and why I am struggling to do it: Users on my website have a profile. On that profile I would like an image (in the future maybe a number of images) and I would like to let me users upload images to be shown there. I need the following: - Image upload (or entering of url for image on somewhere like imageshack.us for example..) - File verification - Image resizing - Saving of file using the user's ID so it can easily be referred to Every single script I have seen either confuses me, or I have no idea how to edit it to get what I want. I am also extremely worried about the security. That's why I'm thinking letting the users enter a URL to an image uploading website might be a good idea. That way, I can just link to the url. I have yet to find a tutorial on this though. Any help is appreciated. I am not asking for you to do it for me, I merely need a good push in the right direction. Many thanks in advance, Goose.
  5. Im not sure if I made my first post clear or not. First off: if you think there is no money in online text-based games you are completely wrong. One of the people I have been "following" is now making over $80000 a month and was in the national papers for hitting £1,000,000 profit.. I also have a NUMBER of other people who are making healthy £100,000+ a year with their online games.. My game is tiny and it's making me a small sum every year already. Second point: I am not a complete newbie. I have already made my own game. It works. However, I need to get some specific areas that people would recommend becoming pro in. 6 months isn't a long time if you're not working hard. I will be working 10+ hours a day on this, so I know I can learn a lot.. a heck of a lot, as I already have a good understanding of PHP. Regarding the business plan: That is already thought out in my head. I know my aims for my BUSINESS side. I have investors and potential investors lined up in my venture, that isn't a problem. My problem is the languages that you would recommend. I am not going to look into flash. I have no skills in graphical stuff, so I'm not going to waste my time doing any of that. What I want to know is: What are the most crucial languages you would recommend learning that will open up my flexibility with web design. As stated before, I can already code html, css, php, mysql. I have some javascript on my site, but I'm not very good. Would you recommend the following and think it's a good idea: Read a number of books to improve syntax knowledge of php to a "pro" level (stupid wording, but basically get a lot better at PHP). Also look into javascript, mysql, database structure, optimising websites and databases.. How does all that sound to you guys? Is there anything you'd recommend like AJAX or anything similar? Anything you learnt and you thought was priceless?
  6. Dear all, I am posting here to receive some feedback from people who are interested in giving me some information and guidance. I started learning how to code back in June 2007. I worked very hard at PHP and MySQL. I had some basic HTML knowledge at the time.. but I studied hard and have got to a pretty good level with PHP. I built my own online-game which I am still working on today (as I am still a student). I am considering taking a gap-year after I finish my degree (in June this year) and I would like the following information from people: If I spent 6 months studying hard and then 6 months of working on websites to create my dream game development business.. what languages would you recommend learning? I do not have huge skills in graphics design and I have had to outsource my css/html layout design to a third party.. so what would you recommend learning? I want to create high quality, text-based role playing browser games. I already have one, but I want a number of them.. so what do you think? At the moment, I am considering improving my php skills to a very high level, then improving my mysql and database structure skills.. I will also look into more CSS and JavaScript. What is the best use of my time and how would you recommend doing it? I was thinking of buying about 15-20 text-books and going through those for 6 months. I'd then spend 6 months putting that knowledge into practice. If you could all respond with a detailed reply and give as much information as possible I would be extremely grateful. Thanks in advance for your help and assistance. Goose.
  7. don't i have to buy flash to do that? I've done no work with flash ever.. i'm just a self-taught php/mysql developer.. so i haven't had the opportunity to branch off in different directions yet.. could you give me some info and push me in the right direction for that please? i'd be extremely greatful.
  8. Dear all, I am writing this message as I have looked on the internet but my searches have been fruitless. A user of my online game has asked me if I can add a sound notification to a timer that ticks down once every 5 mins or so (when they are playing). This means they could use another browser and it would let them know they can do another action. I have absolutely no knowledge on this area, so if someone could give me some reference material or push me in the right direction, I would be very grateful. Thanks in advance, Goose.
  9. There are two problems: 1) What if the person doesn't add an image shack url? What if they add a www.blahblah.com/powned.exe or whatever.. i don't know what they could add, as I haven't studied this area.. 2) I have NO idea about validation.. It's the other area I've failed in and I've had to had help with aspect.. even though I can code a game lol. When it comes to text validation with all the {4-2} stuff and /*)(){} I get confused.. Could someone help me out and comment it possibly for me? I'd be so grateful if you did.. Many thanks, Goose.
  10. Maybe I need url validation for this? I will have a post form to submit the data into the database.. so maybe I just need to validate it.. Anyone have any good code to validate images from say.. www.imageshack.us for example?
  11. Hi all, I have been looking around on the internet and I've only found one script that's any good and it appears to have no security related to it. I am looking for a script that can let the user submit a url to display a picture (in my case, a profile picture). The profile page will then pull up the picture from the url and display it when the page is loaded. My current method works quite simply: The user can enter the url into the DB with a simple form. The db then pulls that url out and displays it in the following way: <img src='$url' height='200' width='150' alt='Avatar'> Basically like that. It works fine... but.. I'm worried about the following few problems: How can I stop various problems like people using links that are not image files. Also, there might be other methods for people to manipulate the url method and cause huge problems. If anyone can make me aware of it (and help with some code) as I am not very good with verification php, especially when it gets complicated! Thanks in advance, Goose.
  12. Maybe it's a feature I should just forget about? That did cross my mind, but as it's just one query.. i didn't think it would be that bad.. meh.. to be honest, i will look into the code to do it, but I won't implement it. It's just not what I need for that feature I think.. Thanks anyways all.
  13. Dear all, I apologise for my serious lack of knowledge in this area.. and i'm pretty sure that you can't use php, but i just need advice + some support if that's possible. I have recently added a chat feature to my website. It currently displays on every page in the title bar. It displays 30 rows of chat and updates every time the page is changed or refreshed. I would like the mysql query that collects the latest messages to update every 5-10 seconds if that's possible.. or ideally... update when there is a new post.. that would be perfect.. Can someone point me in the right direction. Or ideally, help me out with this. Many thanks in advance. Goose.
  14. Thanks for the response. I have a couple more questions on this matter though.. 1) I have a session variable for the id of the user when they are logged into my website and a session for the username. Should I create another session for the forums that they are viewing, then if they log out (or the session ends) I have to reallocate that same forum session back to that user, correct? 2) You said I have to store the ID of the session in the database. I need some clarification on what exactly you mean by this. I wasn't aware that sessions could have IDs and that you could store just an ID and it would keep the values you store in them. 3) My array knowledge is rather poor, so I will have to read up on it.. but I have to store something like $array = array ($post1, $post2, $post3, $post4); correct? Then I have to explode the array to get those values and then add to them when I want to add more posts that they have read? 4) You said "session id cookie". Does that mean I need to store a cookie on their computer, and have a session related to that cookie?? I also don't use cookies, I just use sessions on my website.
  15. for #1 I understand that you can have a "viewed" in the database field, but there might be 1000 users that want to view it, how to I distinguish between the users? That's why I was thinking I would need to create a table for "post id", "user id", "viewed", but I'm pretty sure that is very inefficient.. Regarding storing the session.. what do you mean by store the id of the session into the DB, store the values of that session? You lost me a little bit there.. for #2 Ah ok, that's an interesting idea with the loop function and using an array. That makes the scalability a little easier, but still slow. Any other ideas for that one? (your idea is still a vaste improvement on mine! ) What makes you say php rand isn't completely random? I know they say computers can't produce a truly "random" value, or is there something actually wrong with it? Thanks for the response
×
×
  • 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.