Jump to content

mallen

Members
  • Posts

    316
  • Joined

  • Last visited

Everything posted by mallen

  1. I fixed the problem. I was entering in a file path like "images" but I left it like below and it worked. But now I want to see if i can change the path. The file resides in the same folder as the image files. If I moved it out of the current folder, would I leave the dot like ./images ? $imagefolder='.'; $thumbsfolder='.';
  2. function createthumb($name,$filename,$new_w,$new_h) { $system=explode(".",$name); if (preg_match("/jpg|jpeg/",$system[1])) { $src_img= imagecreatefromjpeg($name); } if (preg_match("/png/",$system[1])) { $src_img= imagecreatefrompng($name); } What do you mean make sure $ name is a qualified path? What should be after explode"."
  3. I am trying to use PHP GD module to create thumbnail images from this example http://icant.co.uk/articles/phpthumbnails/ It is generating thumbnails but they are black. I have read alot about this issue and tried them all but still won't work. I changed the function names to lowercase. I used ImageCreateTrueColor() instead of imagecreatefromjpeg() . I have tired different path settings. And it also gives me errors such as Warning: imagesx(): supplied argument is not a valid Image resource in ..... Warning: imagesy(): supplied argument is not a valid Image resource in .... Warning: imagecopyresampled(): supplied argument is not a valid Image resource in .... Warning: imagedestroy(): supplied argument is not a valid Image resource in .... Below is the code. <?php $imagefolder="images"; $thumbsfolder="thumbnails"; $pics=directory($imagefolder,"jpg,JPG,JPEG,jpeg,png,PNG"); $pics=ditchtn($pics,"tn_"); if ($pics[0]!="") { foreach ($pics as $p) { createthumb($p,"tnh_".$p,100,100); } } /* Function ditchtn($arr,$thumbname) filters out thumbnails */ function ditchtn($arr,$thumbname) { foreach ($arr as $item) { if (!preg_match("/^".$thumbname."/",$item)){$tmparr[]=$item;} } return $tmparr; } /* Function createthumb($name,$filename,$new_w,$new_h) creates a resized image variables: $name Original filename $filename Filename of the resized image $new_w width of resized image $new_h height of resized image */ function createthumb($name,$filename,$new_w,$new_h) { $system=explode(".",$name); if (preg_match("/jpg|jpeg/",$system[1])){$src_img=ImageCreateTrueColor($name);} if (preg_match("/png/",$system[1])){$src_img=ImageCreateTrueColor($name);} $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $dst_img=ImageCreateTruecolor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if (preg_match("/png/",$system[1])) { imagepng($dst_img,$filename); } else { imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img); } /* Function directory($directory,$filters) reads the content of $directory, takes the files that apply to $filter and returns an array of the filenames. You can specify which files to read, for example $files = directory(".","jpg,gif"); gets all jpg and gif files in this directory. $files = directory(".","all"); gets all files. */ function directory($dir,$filters) { $handle=opendir($dir); $files=array(); if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}} if ($filters != "all") { $filters=explode(",",$filters); while (($file = readdir($handle))!==false) { for ($f=0;$f<sizeof($filters);$f++): $system=explode(".",$file); if ($system[1] == $filters[$f]){$files[] = $file;} endfor; } } closedir($handle); return $files; } ?>
  4. At the bottom of my login page it displays a link if I am signed in. echo "You are signed in. <p><a href=logout.php>Click here to log out.</a></p>
  5. <?php session_start(); unset ($_SESSION['username']); unset ($_SESSION['password']); session_destroy(); or session_start(); session_destroy(); Both examples don't work.
  6. That will send me back to my login page that says I am logged in. Nothing is killing the session to log me out.
  7. I tried changing it to this and it still says i am logged in. <?php session_start(); session_destroy(); echo "You have been successfully logged out. <br><br> You will now be returned to the login page. <META HTTP-EQUIV=\"refresh\" content=\"2; URL=login.php\"> "; ?>
  8. I turned off the notice. But the log out page will not end the session. It takes me back to the log in page where it shows me logged. 1. I need for the log out page to kill the session 2. I need a check to see if its set when the page loads
  9. No I am using a phpbb database for testing. As for the spaces its working just not the sessions part. I don't want to turn off all errors. Is there one setting I should check?
  10. I have this simple sign in page. Sets a session for user and password. The problem is when I first load the page it shows the form and shows this error: Notice Undefined index: username in ........on line 21 Then I type in a wrong user and password to test it and it clears the error and shows the "You are not logged in". message like it should. The other problem is my logout page. Seems simple it says you have been logged out, but it sends you back to the login page, shows that I am logged in and still shows the error: Notice Undefined index: username in ........on line 21 Login Page: <?php session_start(); if ($dbc = @mysql_connect ('localhost', 'root', 'xxx')) { if (!mysql_select_db ('phpbb')) { die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>'); } } else { die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>'); } // convert username and password from _POST or _SESSION if($_POST){ $_SESSION['username']=$_POST["username"]; $_SESSION['password']=$_POST["user_password"]; } // query for a user/pass match $result=mysql_query("select * from phpbb_users where username='" . $_SESSION['username'] . "' and user_password='" . $_SESSION['password'] . "'"); // retrieve number of rows resulted $num=mysql_num_rows($result); // print login form and exit if failed. if($num < 1){ echo "You are not signed in.<br> <form method=POST action=login.php> username: <input type=text name=\"username\"> password: <input type=password name=\"user_password\"> <input type=submit> </form>"; } else { echo "You are signed in."; } exit; ?> --------------------------------------- Logout page: <?php session_start(); unset ($_SESSION['username']); unset ($_SESSION['password']); session_destroy(); echo "You have been successfully logged out. <br><br> You will now be returned to the login page. <META HTTP-EQUIV=\"refresh\" content=\"2; URL=login.php\"> "; ?>
  11. Thanks guys. While you both posted your replies I tried different combinations and somehow it worked! $query = "UPDATE phpbb_users SET title='{$_POST['title']}' , description='{$_POST ['description']}' , images='{$image_name}', address='{$_POST ['address']}', price='{$_POST ['price']}', contact='{$_POST ['contact']}', phone='{$_POST ['phone']}' WHERE user_id= '{$_SESSION['user_id']}'"; I will try your suggestions and play around more with it.
  12. Yes just one property for now. Maybe its not working because I am not listing all the other fields. See I am adapting a huge phpbb forum database. So if they register in the forum or on the site its all going to one database. I figured it would be easier to add extra columns to the users table since its just what they are selling, ect. The reason for all the {''} is this form uploads the info, uploads an image, changes its name and stores it. I am trying to put two things together since they could come from the either side, the forum or the web site. Does that make sense? There are 30 tables in the database and inside the users table there are about 30 fields. So I just added a few to the users table. Maybe I should make a sellers table?
  13. Yes I have a users table. That is where I am entering the data. Does this look better? $query = "UPDATE phpbb_users SET(title, description, images, address, price, contact, phone) VALUES (0,'{$_POST['title']}', '{$_POST ['description']}','{$image_name}', '{$_POST ['address']}', '{$_POST ['price']}', '{$_POST ['contact']}', '{$_POST ['phone']}' WHERE user_id=$_SESSION['user_id'] " ;
  14. Maybe I wasn't clear. The user will not have these records so i won't be updating them. Its a form for them to enter property for sale. So most of these fields will be blank. Say user 1 has name, email, age ect. But the rest of the records are blank. I am just entering in the house they are selling ect. I want to enter it into the correct record. Like if the user id is 1, and the session id is telling it is 1, then enter the data in record 1, do not make a new record.
  15. I have this form that I want to enter data. But I want it to read a session variable called "user_id" And when the form is submitted it enters it in the database corresponding to the correct user_id. So I figure I needed to tweek my code to say WHERE $_SESSION["user_id"]; but I can't get the SQL statement right. $query = "INSERT INTO users (user_id, title, description, images, address, price, contact, phone) VALUES (0,'{$_POST['title']}', '{$_POST ['description']}','{$image_name}', '{$_POST ['address']}', '{$_POST ['price']}', '{$_POST ['contact']}', '{$_POST ['phone']}')";
  16. I am working on an application where users will upload images. I also have a forum using PHPBB. Is it possible to have a database for the users including ID, posts, and images and a separate database for the forums? The forum database has 30 tables and it seems easier to just add the extra tables to it. But if I can use some type of join I would rather keep the two separate. I have to keep the two linked somehow so if they log in to the web site they are logged in to the forum and vice versa.
×
×
  • 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.