Jump to content

EchoFool

Members
  • Posts

    1,074
  • Joined

  • Last visited

Everything posted by EchoFool

  1. How is that done whilst keeping the ratio ?
  2. Hey, I was wondering if there is a way to use PHP to resize images when they are a above a size limit? Im not referring to file size here, but rather the width by height ratio. As currently i upload images and echo them with: style="width:250px;height:200px;" But this means my server is loading large images when i would rather resize them down upon upload to reduce loading times... Is this possible in php ?
  3. Oh it works now my directory permission had to be 777 not 775. Works now yay !
  4. The file could not be moved. Hmm, this is strange... =/
  5. Using move_uploaded_file() Gives me "Copy unsuccessfull" outcome =/
  6. Hey, I have found a script off the net which uploads an image to a directory but even though it says the image was uploaded successfully - it didn't actually upload it. The folder permission is 775 (im assuming that is correct). The script i found is here: http://www.reconn.us/content/view/30/51/ <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","100"); //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 != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $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 '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="images/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfully! Try again!</h1>"; } ?> <!--next comes the form, you must set the enctype to "multipart/frm-data" and use an input type "file" --> <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> I was also wondering how do upload images to separate folders related to a UserID ?
  7. Thanks - that seems to have solved the issue
  8. Well the script i bought from a website for my live chat feature.. Its in a function called load messages, which says: So my guess here is that the line trying to get messages from my message.txt file ? But currently as no one has spoken yet, the message.txt is empty - would that be the likely cause of the problem ?
  9. Hey I got this script which is trying to unserialize but i get this error and have no idea what it means so i equally have no idea how to fix the problem. This is what it says: This is the line which causes the error: <?php $contents = unserialize(file_get_contents($this->msgsFile)); ?> Does any one know what the error means? And what i need to look for to fix it.
  10. Argh i worked it out Had to use strtotime() in order for it to work on my variable! Thanks for the tip!
  11. I saw that function though i don't get how it converts it to what i need? If i put <?php date("Y-m-d H:i:s",time()); ?> That just gives me the server time, but im trying to convert a stored timestamp from the database...
  12. Hey, Is there a PHP function that converts a timestamp to words automatically? I have the timestamp in this format: 0000-00-00 00:00:00 But i want it to display into words like for example: Mon 12th December 2011 8:00PM Can't work out how to do it with my own function it seems over complex to work out what day it would be so am wondering if PHP already has a such a function?
  13. Well i don't know how to store it in date time formate because it asks for the second which i don't require. IT inserts in that format then i load it from a query and then i want to display it but also do some checks against in time format =/
  14. In the database the value is stored in that precise format shown above as it was created from a form that the user enters the data.
  15. Hey, I need help with my date & time string. I need to edit it do show in a string + also use it for calculating things like when the date has passed. The string is like this: <?php $string = '2011-01-01 00:00 AM'; ?> So i wanted to check if there was a function that can automatically convert it, so it would say for example: But at the same time compare $string against server time to see if the date has expired? Hope you can help
  16. If i SUM won't that only create one row result similar to count? or is it : <?php SUM(t2.userid) AS totalfans FROM eventtable t1 LEFT JOIN eventfans t2 ON t1.eventid=t2.eventid ORDER BY totalfans ?>
  17. Hey, I have a query which loads events and i want to order them by total number of fans of that event. The number of fans is based on how many people are a fan of the event which is stored in a secondary table for example: How do i do it ?
  18. Well because how can i check what GETs are set in order to put them in to the href?
  19. IS there a way to include the GETs for HTTP_REFERE? I often use it as a "go back" link but it doesn't include the GETs that were in the url which is a pain... Any ideas? This is what i use: <a href="<?php echo $_SERVER['HTTP_REFERER'];?>">Go Back</a>
  20. Think you have misread my post here i already have the status + comments loaded fine im referring to notifying users.
  21. Hey, Im busy making a social network style wall feed for my site where people make a status and people can comment. Now when some one comments the users active in the comment wall + original status maker gets notified but now the issue is theres so many while loops going on im thinking there must be a better way? My current method is as follows: 1) Get the userid of the person who made the status 2) Collect all unique userid's of all the people who made a comment 3) Create the array of userids 4) Loop the array and insert row after row of each userid to notify them a comment was made on a feed they are active on. Thing is - im thinking when i scale it up with alot of users this looping is going to increase the load alot so is there really any more efficient method i can use ?
  22. Argh never mind i fixed it i changed it to use a NOT EXISTS instead Seems to have done the trick!
  23. Hey i have written a really complex query to meet the criteria of my script but i can't get it to work.... this is what it is meant to do: Load news feed from users that have made a comment not including the users that you have blocked. This is my query: <?php $safe = 1; // my userid SELECT t1.comment,t1.userid,t1.timestamp,t2.username,t1.id FROM user_comments t1 INNER JOIN users t2 ON t1.userid=t2.userid WHERE t1.feedid='1' AND 1 NOT IN (SELECT count(id) AS total FROM users_blocked WHERE (user1='$safe' AND user2=t1.userid) OR (user1=t1.userid AND user2='$safe')) ?> Annoyingly it doesn't load any comments since adding the block check =/ Any ideas on my mistake?
  24. Thats very good! Though for this kind of string: <?php $text = "this is some stuffhttp://www.domain.com?d=13213124"; ?> because there is no space between stuff & http it doesn't notice that stuff is not part of the http etc. But as you say its probably impossible to improve upon its current situation =/ Unless i can some how insert a space before http where it can detect there is no space perhaps. Oh this doesn't work if there are any new lines in the text like: Fails. Im thinking if i make it remove all new lines this might fix it =/
  25. Okay but if thats in a paragraph say for a forum post how will i extract them out of the string including GETs on the domain: google.com?get=5 Also if the domain is in the post which is not spaced out from the words around (some spmammers do that like this "hello therewww.google.comhow are you". Then it won't pick it up in the check?
×
×
  • 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.