Jump to content

g3mma111

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

g3mma111's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have this script which resizes an uploaded picture, saves it to a folder, and then saves its url to a database. I still want to do this but i also want to keep the original image and save that to a different folder called horiginalpic/ and then save the url of that to the database. If any one could help it would be appreciated. $host = "***************"; $user = "****"; $pass = "******"; $db = "********"; $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); mysql_select_db($db) or die ("Unable to select database!"); $query = "SELECT * FROM members where (username = '$ses_username')"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $obj=mysql_fetch_object($result); $hname=$obj->hname; $uploadedfile = $_FILES['uploadfile']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); list($width,$height)=getimagesize($uploadedfile); $newwidth=100; $newheight=($height/$width)*100; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $thumbfilename = "hthumbpic/". $ses_username.$hname. ".jpg"; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); $query = " INSERT INTO `".$pics."` ( `username` , `thumburl` ) VALUES ( '".$ses_username."' , '".$thumbfilename."' )"; if(mysql_query($query)){ echo 'Query executed successfully'; } else { echo 'Query failed'; } mysql_close();
  2. sorry - the profilepicthumb/ is meant to be images/
  3. i got a image upload and resize script from the internet and want to change it so that when the image is resized it is not saved to the /images folder with its original file name but the value of $username and then the file name. Here is the code at the moment: <?php $uploadedfile = $_FILES['uploadfile']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); list($width,$height)=getimagesize($uploadedfile); $newwidth=100; $newheight=($height/$width)*100; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = "profilepicthumb/". $_FILES['uploadfile']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); ?> im guessing the code goes in here somewhere but i dont really have a clue what i am doing! any help would be appreciated!
  4. Im fairly new to PHP and am having a problem with the following script: <? if ($gender='F') { ?> <img name="" src="/images/woman.jpg" width="101" height="140" alt=""> <? } else { ?> <img name="" src="/images/man.jpg" width="101" height="140" alt=""> <? } ?> I am trying to make it so that if gender is F then a woman pic gets displayed and otherwise it is a man one. Can anyone see where ive gone wrong? at the moment it just displays a woman pic regardless of what the gender is.
  5. I am trying to get records from the database where the username= $username and the comment does not equal $comment. Ive heard != means not equal so this is what i have so far: $sql="select * from comments where (tousername= '$username') AND (commment != $comment) ORDER by date"; im not sure if its meant to be in brackets??? I basically dont have a clue what im doing..
  6. Hi. Im fairly new to PHP and cant work out how to do this code properly: if (mysql_num_rows($result) > 0 ) { or ('$username' = '$ses_username') echo '' } else { i want to make it so that if there are more than 0 results or the session username = the username then it doesnt say anything. I get the error that there should be no 'or' but im not sure how to do it without the or!?
  7. g3mma111

    HELP.

    I am new to PHP and need help with a resizing script. I realise that there are lots of other posts like this but i have been through them and cant apply them to my case. I have an image rating website and on the homepage it selects a picture at random to display. Problem is that the pic is often too wide and messes up the page. I need to make it so that the image is resized in proportion if the width is over 500. Here is the bit i code that i think it goes into: <td height="19" td width="400"colspan="4" align="center" ><? print $pic ?> </td> Any help would be appreciated!
×
×
  • 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.