Jump to content

serien

Members
  • Posts

    16
  • Joined

  • Last visited

Profile Information

  • Gender
    Female

serien's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ahh, yep, screwed that up in my first answer XD. Definitely assumed that class2 was of type class1. Thanks guys ^^; 1internet, theirs will probably work better for you. That's what I get for answering questions at 3am haha.
  2. Thanks for the help! I had tried to do absolute paths using some global variables that I have set. This time I typed them in directly. The error changed! Warning: file_put_contents(http://localhost/dellusionary/images/ha/users/2.png): failed to open stream: HTTP wrapper does not support writeable connections in C:\wamp\www\dellusionary\classes\user_class.php on line 98 Turns out I need the direct path for the write-from file and the indirect path from the write-to file. Just needed to try that combination haha. Thank you so much!!!!!
  3. Quick update after a few more hours of searching I determined that the problem lies in my file_get_contents($url) returning an empty string. Not sure what is causing this, as when I type in the url of image directly into the address bar I definitely get an image. The file should also be readable, I have the permissions set to everything available for everone on it. I tried also using Curl instead of the file method, all to no avail. Everything is enabled, cannot for the life of me figure this darn thing out!
  4. The best way, I would say, would definitely be to make class2 extend class1 class class1 { public function variable($str) { $this->str = $str } } class class2 extends class1 { public function get() { echo $this->str; // because of extension, str is now a variable of class2 as well and can be called using $this } }
  5. I'm truly sorry if this is a repeat but I have searched and searched, but no answers seem to be helping my issue >< I'm either missing something really idiotic or my case is for some reason different. I am trying to save a generated 'GD' image using the file_get_contents function. However, I keep getting the following error: Warning: file_get_contents(../images/ha/haimg.php?skin=ff00ff): failed to open stream: No error in C:\wamp\www\dellusionary\classes\user_class.php on line 98 I have been stuck for hours... the image path should be correct. I've tried using the full path as well, "/dellusionary/images/ha/haimg.php?skin=ff00ff", but that doesn't help. I have also made sure that security settings on both the copy-from and copy-to files are read/write for all user groups. I am stumped ;.; Here's code //=========================================== The Image Creation Function ====================== public function updateha($skin) { $url = "../images/ha/haimg.php?skin=$skin"; $img = "../images/ha/users/".$this->userid.".png"; if(file_put_contents($img, file_get_contents($url)) ) // { return "<div id='alert'>Avatar successfully updated!</div>"; } else { return "<div id='warning'>I'm sorry, there has been an error while saving the image.</div>"; } } //======================================= The Actual Image File ================================== <?php //-------- VARIABLES! $skintone = ($_GET["skin"] != '') ? $_GET["skin"] : "0f0f0f"; // Create Base $basepath = 'http://localhost/dellusionary/images/ha/bases/female/fembasetorso.png'; $base = imagecreatefrompng($basepath); colorize($base,$skintone); list($width, $height) = getimagesize($basepath); // Merge Legs onto base $legpath = 'http://localhost/dellusionary/images/ha/bases/female/fembaselegs.png'; $legs = imagecreatefrompng($legpath); colorize($legs,$skintone); merge($base,$legs); // Add Body Lines $lines = 'http://localhost/dellusionary/images/ha/bases/female/femlinestorso.png'; $l = imagecreatefrompng($lines); merge($base,$l); // Add Leg Lines $lines2 = 'http://localhost/dellusionary/images/ha/bases/female/femlineslegs.png'; $l2 = imagecreatefrompng($lines2); merge($base,$l2); /* Output Image */ imageAlphaBlending($base, true); imageSaveAlpha($base, true); header('Content-Type: image/png'); imagepng($base); imagedestroy($base); /*---------------------------------------- Image Manip Functions --------------- */ function colorize(&$image, $color) { // Define RGB Values $red = hexdec(substr($color, 0, 2)); $green = hexdec(substr($color, 2, 2)); $blue = hexdec(substr($color, 4, 2)); // Colorize Layer imagealphablending($image, false); for ($x = imagesx($image); $x-- { for ($y = imagesy($image); $y-- { $rgb = imagecolorat($image, $x, $y); $c = imagecolorsforindex($image, $rgb); if ($c['red'] < 256 && $c['green'] < 1 && $c['blue'] < 1) { // dark colors // here we use the new color, but the original alpha channel $colorB = imagecolorallocatealpha($image, $red, $green, $blue, $c['alpha']); imagesetpixel($image, $x, $y, $colorB); } } } } function merge(&$base, $add) { imagealphablending($base, true); imagesavealpha($base, true); imagecopy($base, $add, 0, 0, 0, 0, imagesx($base), imagesy($base)); imagedestroy($add); } ?> Any help would be sincerely appreciated!!!!
  6. try this if($sent) {echo "<div align='center'><strong><p style='font-family:tahoma;font-size:9px;' >Your Email Change was sent successfully</p></strong></div>"; } else {echo "We encountered an error sending your mail"; } ?> You don't want to use both 'print' and 'echo', as they both do the same thing =] just use one or the other. this version also involves the html/css version of positioning and font styling EDIT: Put in if($sent) {echo "<CENTER><B><FONT SIZE=9 FACE=TAHOMA>Your Email Change was sent successfully" } else {print "We encountered an error sending your mail"; } ?> and it worked correctly also. so whichever you prefer!
  7. Your question is a bit hard to make out, at least for me. So you are basically creating a script that generates team match-ups in a league, one team vs another team. That part makes sense. The next is a tad unclear. How are you wanting to split the information? one table for each competitor showing all of their matches? Perhaps a little more insight into how you want the final tables organized would be helpful in finding an answer
  8. ^ That's interesting style, tibberous. I've never seen that sort of formatting learn something new every day! Aye, as other say, those are html/css properties. http://w3schools.com/ has some really awesome tutorials and advice for beginners to these languages, if you want further tips. HTML is used to create things and display them on a page, CSS styles those things. If the above is all you need, though, awesome. If you want to learn more, though, check out the w3 website!
  9. thanks! yeah, I thought about the "NULL" thing also, but the top of each page has a check. If $site->loggeduser = NULL, then it redirects back to the home page. the page where the error lies shouldn't be visible to viewers who aren't logged in on a session. here is the code for the Users class class User extends Site { // ====================================== Properties ==================== public $userid; // User's id public $username; // User's display name public $bio; // User's Profile Bio public $userdate; // User's join date public $userrank; // User's rank title public $userlevel; // User's access level public $staffbio; // If user is staff, the bio that displays public $template; // User's layout of choice public $online; // User's online status public $rankid; public $sitecash; public $realcash; public $activepet; // User's active pet, possibly move... private $loginname; //User's login private $password; // User's password //======================================== Methods ========================= public function User($id) { $this->userid = $id; $userinfo = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE userid = '$id'")); $this->username = $userinfo['displayname']; $this->bio = $userinfo['userbio']; $this->userdate = date("F j, Y", strtotime($userinfo['joindate'])); $this->template = $userinfo['template']; $this->sitecash = $userinfo['bits']; $this->realcash = $userinfo['bobs']; $this->activepet = $userinfo['activepet']; $this->online = ($userinfo['online'] == 1); $this->rankid = $userinfo['rank']; $rankinfo = mysql_fetch_array(mysql_query("SELECT * FROM ranks WHERE rankid = '".$userinfo['rank']."'")); $this->userrank = $rankinfo['ranktitle']; $this->userlevel = $rankinfo['ranklevel']; $this->staffbio = $userinfo['staffbio']; } } I will try the construct thing! see if it works... I was between using it and the function call, it makes sense that it would be the better option. I have never seen the parent::construct call though, that is very good to know! EDIT: The parent::__construct(); did the trick!!!!!! Thank you sooo much!!! On to different errors now =D I will still go back and change all of the constructors though, since it seems to be better programming practice. Awesome!
  10. I am writing a webpage for a friend and it involves forums. I have been working on switching the entire site into object oriented to better organize it (the straight php version was a bit too messy for me) I have been slowly working through the kinks, but I finally hit a snag that is broad enough to stump google and beyond my knowledge to hash out. Any help you guys can give will be greatly appreciated!! I have an overall master class called 'Site'. it holds the logged in user's session as well as database information. Here is the code for that. I am only including the constructor because the other functions are not involved in my current issue. class Site { // ====================================== Properties ==================== public $loggeduser; // User Class public $baseurl = '/dellusionary'; //======================================== Methods ========================= /* Constructor */ public function __construct() { $this->mysql_connect(); session_start(); $this->loggeduser = (!isset($_SESSION['userid'])) ? NULL : new User($_SESSION['userid']); } } Now, I want to be able to use this "loggeduser" object in my Board class in the forums. I wish to verify whether the current user has the correct level to view the forum (is staff vs is member). Here is that class class Board extends Site { // ====================================== Properties ==================== public $board_normaltopics; // array of normal Topics within Board public $board_stickytopics; // array of important, stickied Topics within Board public $board_subboards; // array of sub-Boards within Board public $board_id; public $board_category; // Category Class public $board_accesslevel; public $board_parent; // Board Class or NULL public $board_description; //======================================== Methods ========================= /* Constructor */ public function Board($id) { // Set Topics $topicquery = mysql_query("SELECT * FROM forum__topic WHERE topicboard = $id ORDER BY topicdate DESC"); while ($topic = mysql_fetch_array($topicquery)) { $this->board_topics[] = new Topic($topic['topicid']); } // Set Board Information $boardarray = mysql_fetch_array(mysql_query("SELECT * FROM forum__board WHERE boardid = $id")); $this->board_id = $id; $this->board_name = $boardarray['boardname']; //$this->board_category = new Category ($boardarray['boardcat']); $this->board_accesslevel = $boardarray['boardaccesslevel']; $this->board_parent = ($boardarray['boardparent'] == 0) ? NULL : new Board($boardarray['boardparent']); $this->board_description = $boardarray['boarddesc']; } /*******************/ /* Operation Functions */ public function valid_board() { $query=mysql_query("SELECT * FROM forum__board WHERE boardid = $this->board_id"); $num= mysql_num_rows($query); if ($num != 0) { return (($this->board_accesslevel) <= ($this->loggeduser->userlevel)); // LINE 133 } else { return false; } } } Again, only included problem functions. Is this possible? I keep getting the following error: Trying to get property of non-object in C:\wamp\www\dellusionary\classes\forum_class.php on line 133 I marked the line above Thank you!
  11. SOLVED! It was a url mistake. >< gotta love coding! The smallest things can completely mess you up. Thanks for all the help though guys!
  12. Ok, I will talk with the server mod, for some reason the user they gave me doesn't have access. I can login to phpmyadmin with it, but it is denying the query in the code. Thanks guys ^^ I'm still learning how error reporting works
  13. I thought that might be the problem, but I see nothing wrong with my connection query. I've checked over the spelling 5-6 times, and the syntax is the same when I connect to localhost. That is the most obvious answer, though, so I will check again
  14. It's definitely the form data, it doesn't echo out. the submit data obviously passes, however, because the function runs. No clue. EDIT: It may have something to do with the fact that it works on localhost and not on the host server. Does anyone have any idea what could cause that?
  15. Here are those two functions. The if wasn't even getting that far so I figured they couldn't be the problem. As far as streamlining into one query, I am hacking the basics out before I go back and really get everything composited into neater style ^^. I have a lot of work ahead of me! That is a good idea though. (code tags failed for some reason) <?php function existing_username($username) // CHECKS IF USERNAME EXISTS { $query = mysql_query("SELECT * FROM users WHERE username = '$username'" ); $result = mysql_num_rows($query); return !($result == 0); } function valid_match($username, $password) // CHECKS IF LOGIN VALID { $encryptpass = md5($password.$username); $query= mysql_query("SELECT * FROM users WHERE username = '$username'AND password ='$encryptpass'"); $result = mysql_num_rows($query); return ($result == 1); } ?>
×
×
  • 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.