Jump to content

KDM

Members
  • Posts

    100
  • Joined

  • Last visited

    Never

Everything posted by KDM

  1. I didn't copy / paste anything. I did both tutorials, I don't know how to combine the two. It seems that's the best way to learn, by hiring developers and having them comment the code. I've wasted so much time on forums and tutorials that aren't practical. A tutorial is not meant to be an exact fit for any one implementation. It is meant to instruct the user on the basic processes to complete a task. It is up to the developer to determine how to modify the code to his/her specific needs and implementation. Yea but I learn by code. I can not write code out of thin air yet. I can manipulate some code to do what I want but not everything. Lol @ people who expect someone learning php to be an expert after a couple of tutorials. I often get discouraged, but I know a lot more about php then I did a year ago and that's enough to make me keep going.
  2. I didn't copy / paste anything. I did both tutorials, I don't know how to combine the two. It seems that's the best way to learn, by hiring developers and having them comment the code. I've wasted so much time on forums and tutorials that aren't practical.
  3. I did a tutorial on uploading a profile pic and also did a tutorial on an image re-size class. The only thing is the tutorial on the re-size class is done without using a form which is pointless. Can someone help me integrate this into the profile pic tutorial? Here's a link to the re-size tutorial. http://net.tutsplus.com/tutorials/php/image-resizing-made-easy-with-php/comment-page-3/#comment-401884 index.php <?php session_start(); //include the class include("resize-class.php"); //1 initialize / load image $resizeObj = new resize('sample.jpg'); //2 Resize image (options: exact, potrait, landscape, auto, crop) $resizeObj -> reseizeImage(150,100, 'crop'); //3 Save image $resizeObj -> saveImage('sample-resized.gif', 100); include "connect.php"; $_SESSION['username']='Anomalous'; $username = $_SESSION['username']; if ($_POST['submit']) { //get file attributes $name = $_FILES['myfile']['name']; $tmp_name = $_FILES['myfile']['tmp_name']; if ($name) { //start upload process $location = "avatars/$name"; move_uploaded_file($tmp_name,$location); $query = mysql_query("UPDATE users SET image='$location' WHERE username='$username'"); die("Your profile pic has been uploaded! <a href='view.php'>My Profile</a>"); } else die("Please select a file!"); } echo "Welcome, ".$username."!<p>"; echo "Upload your image: <form action='index.php' method='POST' enctype='multipart/form-data'> File: <input type='file' name='myfile'> <input type='submit' name='submit' value='Upload!'> </form>"; ?> resize-class.php <?php # ========================================================================# # # Author: Jarrod Oberto # Version: 1.0 # Date: 17-Jan-10 # Purpose: Resizes and saves image # Requires : Requires PHP5, GD library. # Usage Example: # include("classes/resize_class.php"); # $resizeObj = new resize('images/cars/large/input.jpg'); # $resizeObj -> resizeImage(150, 100, 0); # $resizeObj -> saveImage('images/cars/large/output.jpg', 100); # # # ========================================================================# Class resize { // *** Class variables private $image; private $width; private $height; private $imageResized; function __construct($fileName) { // *** Open up the file $this->image = $this->openImage($fileName); // *** Get width and height $this->width = imagesx($this->image); $this->height = imagesy($this->image); } ## -------------------------------------------------------- private function openImage($file) { // *** Get extension $extension = strtolower(strrchr($file, '.')); switch($extension) { case '.jpg': case '.jpeg': $img = @imagecreatefromjpeg($file); break; case '.gif': $img = @imagecreatefromgif($file); break; case '.png': $img = @imagecreatefrompng($file); break; default: $img = false; break; } return $img; } ## -------------------------------------------------------- public function resizeImage($newWidth, $newHeight, $option="auto") { // *** Get optimal width and height - based on $option $optionArray = $this->getDimensions($newWidth, $newHeight, $option); $optimalWidth = $optionArray['optimalWidth']; $optimalHeight = $optionArray['optimalHeight']; // *** Resample - create image canvas of x, y size $this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight); imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height); // *** if option is 'crop', then crop too if ($option == 'crop') { $this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight); } } ## -------------------------------------------------------- private function getDimensions($newWidth, $newHeight, $option) { switch ($option) { case 'exact': $optimalWidth = $newWidth; $optimalHeight= $newHeight; break; case 'portrait': $optimalWidth = $this->getSizeByFixedHeight($newHeight); $optimalHeight= $newHeight; break; case 'landscape': $optimalWidth = $newWidth; $optimalHeight= $this->getSizeByFixedWidth($newWidth); break; case 'auto': $optionArray = $this->getSizeByAuto($newWidth, $newHeight); $optimalWidth = $optionArray['optimalWidth']; $optimalHeight = $optionArray['optimalHeight']; break; case 'crop': $optionArray = $this->getOptimalCrop($newWidth, $newHeight); $optimalWidth = $optionArray['optimalWidth']; $optimalHeight = $optionArray['optimalHeight']; break; } return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight); } ## -------------------------------------------------------- private function getSizeByFixedHeight($newHeight) { $ratio = $this->width / $this->height; $newWidth = $newHeight * $ratio; return $newWidth; } private function getSizeByFixedWidth($newWidth) { $ratio = $this->height / $this->width; $newHeight = $newWidth * $ratio; return $newHeight; } private function getSizeByAuto($newWidth, $newHeight) { if ($this->height < $this->width) // *** Image to be resized is wider (landscape) { $optimalWidth = $newWidth; $optimalHeight= $this->getSizeByFixedWidth($newWidth); } elseif ($this->height > $this->width) // *** Image to be resized is taller (portrait) { $optimalWidth = $this->getSizeByFixedHeight($newHeight); $optimalHeight= $newHeight; } else // *** Image to be resizerd is a square { if ($newHeight < $newWidth) { $optimalWidth = $newWidth; $optimalHeight= $this->getSizeByFixedWidth($newWidth); } else if ($newHeight > $newWidth) { $optimalWidth = $this->getSizeByFixedHeight($newHeight); $optimalHeight= $newHeight; } else { // *** Sqaure being resized to a square $optimalWidth = $newWidth; $optimalHeight= $newHeight; } } return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight); } ## -------------------------------------------------------- private function getOptimalCrop($newWidth, $newHeight) { $heightRatio = $this->height / $newHeight; $widthRatio = $this->width / $newWidth; if ($heightRatio < $widthRatio) { $optimalRatio = $heightRatio; } else { $optimalRatio = $widthRatio; } $optimalHeight = $this->height / $optimalRatio; $optimalWidth = $this->width / $optimalRatio; return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight); } ## -------------------------------------------------------- private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight) { // *** Find center - this will be used for the crop $cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 ); $cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 ); $crop = $this->imageResized; //imagedestroy($this->imageResized); // *** Now crop from center to exact requested size $this->imageResized = imagecreatetruecolor($newWidth , $newHeight); imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight); } ## -------------------------------------------------------- public function saveImage($savePath, $imageQuality="100") { // *** Get extension $extension = strrchr($savePath, '.'); $extension = strtolower($extension); switch($extension) { case '.jpg': case '.jpeg': if (imagetypes() & IMG_JPG) { imagejpeg($this->imageResized, $savePath, $imageQuality); } break; case '.gif': if (imagetypes() & IMG_GIF) { imagegif($this->imageResized, $savePath); } break; case '.png': // *** Scale quality from 0-100 to 0-9 $scaleQuality = round(($imageQuality/100) * 9); // *** Invert quality setting as 0 is best, not 9 $invertScaleQuality = 9 - $scaleQuality; if (imagetypes() & IMG_PNG) { imagepng($this->imageResized, $savePath, $invertScaleQuality); } break; // ... etc default: // *** No extension - No save. break; } imagedestroy($this->imageResized); } ## -------------------------------------------------------- } ?> view.php <?php include ("connect.php"); $username = $_SESSION['username']; echo $username; $query = mysql_query("SELECT * FROM users WHERE username='$username'"); if (mysql_num_rows($query)==0) die("user not found"); else { $row = mysql_fetch_assoc($query); $location = $row['image']; echo "<img src='$location'>"; } ?> connect.php <?php session_start(); mysql_connect('localhost', 'root', 'root'); mysql_select_db('DB'); ?>
  4. Thanks for the reply. None of that is the problem. I've built sites before with the same attributes and never got this problem, I've tried everything. Time to post a job to scriptlance. Oh and min-height is used so the footer will stick to the bottom of the page.
  5. css root { display: block; } #wrapper{ width: 980px; margin-left: auto; margin-right: auto; min-height:100%; } #wrapper:before { /* Opera and IE8 "redraw" bug fix */ content:""; float:left; height:100%; margin-top:-999em; } * html #wrapper { /* IE6 workaround */ height:100%; } #sign_up{ width:100%; margin-left: auto; margin-right: auto; height:50px; margin-bottom: -50px; } #logo{ width:980px; height: 100px; margin-left: auto; margin-right: auto; text-align: center; } #log_in{ width:500px; margin-left: auto; margin-right: auto; text-align: center; margin-bottom: 20px; } #footer{ width:100%; height:220px; background-image: url(../images/footer.png); margin-top: -220px; } body{ background-image: url(../images/bg.jpg); background-position: center center; background-attachment: fixed; background-color: #4176bd; background-repeat: no-repeat; font-family: Lucida, Tahoma, Verdana; color: #FFF; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; height:100%; } .inputfields { background-image: url(../images/inputfields.png); background-position: center center; background-color: #FFF; width: 180px; height: 35px; font-family: Tahoma, Geneva, sans-serif; font-size: 19px; color: #999; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; } #username { background-image: url(../images/inputfields.png); background-repeat: no-repeat; background-position: center center; height: 40px; width: 206px; text-align: center; padding-top: 4px; float: left; } #password { background-image: url(../images/inputfields.png); background-repeat: no-repeat; background-position: center center; height: 40px; width: 206px; text-align: center; padding-top: 4px; float: left; } #log_in_btn { height: 40px; width: 85px; text-align: center; float: left; } #center_content{ width: 980px; height: 200px; margin-left: auto; margin-right: auto; top: 35%; position: absolute; text-align: center; } a:active { color: #FFF; } a:visited { color: #FFF; } a:link { color: #FFF; text-decoration:none; } a:hover { text-decoration:underline; color: #FFF; } .smallText{ font-size: 14px; text-align: left; } html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=MacRoman"> <title></title> <link href="assets/styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="sign_up"><img src="images/sign_up.png" alt="" /> </div> <div id="wrapper"> <div id="center_content"> <div id="logo"><img src="images/logo.png" alt="" /> </div> <div id="log_in"> <form name="frmReg" action="index.php" method="POST" enctype="multipart/form-data" > <div id="username"> <input class="inputfields" type="text" name="username" placeholder="username"/> </div> <div id="password"><input class="inputfields" type="password" name="pwd" placeholder="password"/> </div> <div id="log_in_btn"> <input type="image" src="images/log_in.png" name="submit" value="submit" id="submit"/> </div> </form> </div> </div> </div> <div id="footer"> <br /> <br /> <br /> <br /> <br /> <br /> <table width="1416" border="0" align="center" class="smallText"> <tr> <td width="887">Copyright 2011-2012 Company LLC</td> <td width="100"><a href="advertise.php">Advertise</a></td> <td width="125"><a href="termsofuse.php">Terms of Use </a></td> <td width="90"><a href="contact.php">Contact</a></td> <td width="100"><a href="safetytips.php">Safety Tips</a></td> <td width="170"> <a href="company.com">Free</a></td> <td width="100"> <a href="help.php">Help</a></td> </tr> </table> </div> </body> </html>
  6. If you go to facebook and grab the bottom right corner of the browser window and drag it to the top shrinking it, you should notice the positions of the div's stay the same. When I do this with my file, the div's overlap each other. Any idea why this might be?
  7. I'm following a tutorial but can't this code to work properly for my project. // This all happens around 15 times per second due to looping and frame rate // Redefine the mouse X position myMouseX = Math.round(logos_bg_clip.mouseX); // Ready the calculations according to where the mouse is if (myMouseX > 280) { calcTravelNum = (myMouseX - 280) / 10; } else if (myMouseX < 220) { calcTravelNum = (220 - myMouseX) / 10; } // Move the menu according to calculations if (myMouseX <= 250 && sliding_logos.x <= 30) { sliding_logos.x = sliding_logos.x + calcTravelNum; } else if (myMouseX >= 250 && sliding_logos.x >= -330) { sliding_logos.x = sliding_logos.x - calcTravelNum; } // Go and play the loop label again, just keeps looping gotoAndPlay("loop");
  8. KDM

    Actionscript 3 error

    It's telling me it can't find Scene 1. I created a new scene and named it Scene 1. Why is it not being found? stop(); // logo click function function logoClick(event:MouseEvent):void { logo.gotoAndPlay(1, "Scene 1"); // go into logo movieclip and play the over frame label } // logo Listeners logo.addEventListener(MouseEvent.CLICK, logoClick);
  9. I think I figured it out. I thought I could put all of my actions on a layer at frame 1. I had to move the actionscript to the exact frame my button appears on the screen.
  10. // webhostingbtn Over function function webhostingbtnOver(event:MouseEvent):void { webhostingbtn.gotoAndPlay("over"); // go into webhostingbtn movieclip and play the over frame label } // webhostingbtn Out function function webhostingbtnOut(event:MouseEvent):void { webhostingbtn.gotoAndPlay("out"); // go into webhostingbtn movieclip and play the over frame label } // webhostingbtn Listeners webhostingbtn.addEventListener(MouseEvent.ROLL_OVER, webhostingbtnOver); webhostingbtn.addEventListener(MouseEvent.ROLL_OUT, webhostingbtnOut);
  11. Ok I will when I get home. How is an object null?
  12. TypeError: Error #1009: Cannot access a property or method of a null object reference. at movie_fla::services_1/frame1() thanks.
  13. Will this work? Godaddy form mail takes forever so I'm still waiting. $to = array('********@yahoo.com', '********@************.com'); $mailSent = mail('$to', '$subject', '$message', '$headers'); This is what I had when it was sending to one email address. $to = '********@yahoo.com'; $mailSent = mail( $to, $subject, $message, $headers);
  14. Thanks for the help! I tried if isset before but didn't use the post variable. And I had to change submit to send. It's working fine now. Thanks a lot. I learned something.
  15. Thanks for the help. I was trying to make it so that if the send button is pressed and $car_class is FALSE it would display the warning.
  16. i usually have a hard time understanding the manual actually because they don't explain much just show you with examples... i go there for syntax not for understanding but not all people are a like we all are unique and special like everyone else lol thanks, very well said.
  17. if ("$car_class") == FALSE { echo '<span class="warning">*</span>'; } Here is my error thanks Parse error: syntax error, unexpected T_IS_EQUAL in /home/content/30/6371630/html/register.php on line 421
  18. I'm trying to allow users to register and select their gender, and then have that info sent to the database.
  19. Ok wow thanks I see the problem Unknown column 'user_username' in 'field list'
  20. I'm following a members page tutorial. I have everything copied just like he does but I keep getting this error. Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/13/6987913/html/tutorials/user_profiles/core/inc/user.inc.php on line 8 Code <?php // fetches all of the users from the table function fetch_users(){ $result = mysql_query('SELECT `user_id` AS `id`, `user_username` AS `username` FROM `users`'); $users = array(); while (($row = mysql_fetch_assoc($result)) !== false){ $users[] = $row; } return $users; } ?>
  21. I'll just go to scriptlance...so much for learning over here.
  22. however.. if your willing to learn then maybe this will point you in the right direction change SELECT user_id, count(*) AS freq to SELECT user_id, count(*) AS freq, avatar $_info[0]['user'] = $_info2[0]['username']; $_info[0]['avatar'] = $_info2[0]['avatar']; //Add update with {$_info['freq']} to something like with {$_info['freq']} <img src="{$_info['avatar']}" /> Hope that helps! Thanks I'll give that a try. I just need a push in the right direction.
  23. I already paid someone to do work on this script. I'm trying to learn, not continue to pay people duh.
×
×
  • 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.