Jump to content

mythic

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mythic's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm sorry for the extremely lame title. The problem I'm having is that I'm using phpbb3 and a mod on it to create avatars. The mod is no longer supported, dude dropped off the face of the earth. But right now, we're having a trouble with our images saving all messed up. Because there are too many colors. They look like this: That hair is meant to be black... Anyway, I'm wondering how I can fix this in the coding, or if its because of the GD library. The code where it saves the image is here: // START Save case save: // Check if user has an Avatar yet! If not, create one! $sql = "SELECT * FROM $table_avatar_characters WHERE user = $user_id"; $result = $db->sql_query($sql); $tot_users = $db->sql_affectedrows($result); if ($tot_users < 1) { $sql2 = "SELECT * FROM $table_avatar_layers ORDER BY position DESC"; $result2 = $db->sql_query($sql2); $tot_layers = $db->sql_affectedrows($result2); $insert_values = ''; $insert_layers = ''; for( $i = 0; $i < $tot_layers; $i++ ) { $row2 = $db->sql_fetchrow($result2); $row2_name = $row2['name']; $insert_layers .= ",$row2_name"; $insert_values .= ",'' "; } // Create character! $sql3 = "INSERT INTO $table_avatar_characters (user$insert_layers) VALUES ('$user_id'$insert_values)"; $db->sql_query ( $sql3 ); } // Now that they got a character, insert the selected images into the db! $sql = "SELECT * FROM $table_avatar_layers ORDER BY position DESC"; $result = $db->sql_query ( $sql ); $tot_layers = $db->sql_affectedrows($result); $insert_values = ''; $insert_layers = ''; $dont_show = ''; $no_show_list = ''; $dont_show_layers = ''; for( $i = 0; $i < $tot_layers; $i++ ) { $row = $db->sql_fetchrow($result); $insert_layers .= ",$row2_name"; if($insert_values != "") { $insert_values .= ', '; } $row_name = $row['name']; $post_row_name = $_POST[$row_name]; $insert_values .= "$row_name = '$post_row_name'"; } $camorea_display = 'avatar_save'; // Update character! $sql = "UPDATE $table_avatar_characters SET $insert_values WHERE user = '$user_id' "; $db->sql_query ( $sql ); // START At last, create the PNG image! $tot_width = $avatar_width; $tot_height = $avatar_height; // Get all layers in the correct order! $sql = "SELECT * FROM $table_avatar_layers ORDER BY position ASC"; $result = $db->sql_query ( $sql ); $tot_layers = $db->sql_affectedrows($result); $crtavatar = false; for( $i = 0; $i < $tot_layers; $i++ ) { $row = $db->sql_fetchrow($result); if ($_POST[$row['name']] != 'spacer.gif') { if($crtavatar == false) { $avatar_front = @$avatar_build($phpbb_root_path.$sprites_path.'/'.$_POST[$row['name']]); $crtavatar = true; } else { $image = @$avatar_build($phpbb_root_path.$sprites_path.'/'.$_POST[$row['name']]); @imagecopy ($avatar_front, $image, 0, 0, 0, 0, $tot_width, $tot_height); @ImageDestroy($image); } } } $save = $user_id; imagealphablending($avatar_front, false); imagesavealpha($avatar_front, true); imagepng($avatar_front, $phpbb_root_path . $chars_path . '/' . $save . '.png'); imagedestroy($avatar_front); // END At last, create the PNG image! $exported_save = $chars_path."/".$save.".png"; break; // END Save I have a feeling that it's saving as 8-bit, but I want to up that so that the images don't appear messed up. Does anyone know how?
  2. okay, I got it work. Let me just die.. Y.Y I put the space / in after the image stuff, and it worked. I just have one last thing. What do you mean by: >>>>Query: If you have $avatar already then why the above query you are executing ?? I thought I had to have $result = mysql_query("SELECT * FROM users WHERE avatar = '$avatar'"); to call on the database to get the right info from the right database for the right user o.O or at least that's how I took it from the tutorials I was reading. If I take it out it doesn't work. But if you've got a nicer cleaner safer way where I don't have to post all that jazz then please let me in on it!
  3. Your confusing. You said you never connect to your database then post something about what it should be. I'm not trying to display the username info, I'm trying to display the avatar. The avatar doesn't share the same name as the username, so that command won't work for me. I already stated what works and what doesn't. I'm trying to get it to work the way I want, or understand why it won't and try to work around it. As I've stated I'm new at this. Can anyone please help?
  4. I didn't really know what to call the subject, because I don't know what you'd call my problem, I'm still new to this stuff. Okay, what I'm trying to do is I'm trying to make is so that a user can choose what avatar they want to use in my website. But I'm trying to make the avatar show up after the log in. I did get it to work the other day, but I erased the code (stupidest thing I've ever done). And now I'm trying to get it to work again. <?php $result = mysql_query("SELECT * FROM users WHERE avatar = '$avatar'"); while($row = mysql_fetch_array($result)) { echo "<img src=avatars/"; echo $row['avatar']; echo ".jpg>"; } ?> If you change the 'avatar' stuff so username, and place an image with say the persons username, testing, in the right folder then it shows up and works. Why won't it work if I change the info? And if anyone has a short code which I can use without all that long mumbojumpbo, I'd love them a lot!
  5. This site might be of some help to you: http://www.gentlesource.com/comment-script/ I haven't looked at it yet. But from what I read it seems pretty okay. Maybe you could work with it?
  6. Okay, this is the coding for the main page sort thing. It's where I have the login info for the sidebar so far. <?php include("conf.inc.php"); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. <a href=register.php>Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area header("Location: members.php"); } } } else { // if they are not logged in } ?> <?php include("header.php"); ?> <span class="header">Coming Soon</span><p> <h1> Sorry this page is coming soon. Please check soon! <br><br> </h1> </td> <td width="6" background="images/divider.gif"> </td> <?php include("sidebar.php"); ?> <?php include("footer.php"); ?> And this is the code of the sidebar, where the form is, since it's an include. <td align="center" valign="top" width="200"> <br> <span class="header">Login</span><p> <h1> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan="2" align="right"><h1><a href="register.php">Register</a></h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> </h1> The reason why I don't know how to make it change if they are logged in is because the html code is off else where. It wasn't to begin with. It was mixed in the middle of the php. That's why I don't know how I'd code it to make is disappear, and replace it with something else.
  7. I had a look around and I noticed that I could use the else statement, but that only problem is that the login box is in the html, and the php coding is at the top of the page. How could I get around this?
  8. I'm new to php, and have only started in fact yesterday. I have worked with php a little before, but only tweaking scripts and messing around till it worked my way. However, yesterday I started my own script. So far so good. I've got it hooked up to the database, I've got a basic login, register, and logout page. The only problem I have, is that in my template, I have a side bar. That's where I keep the login box. I was wondering if anyone new of a tutorial or code that could help me remove the login box if they are logged in, or after they login. so that I can display other info, like their user info and so on. I've tried searching the net but have had no luck, because I have no idea what it'd be called to know what to search for. :S
×
×
  • 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.