Jump to content

tjhilder

Members
  • Posts

    136
  • Joined

  • Last visited

    Never

Everything posted by tjhilder

  1. Hi, this script used to work, but i'm not sure why it isn't now. this script basicly uploads an image, makes a thumbnail of it, then uploads some info into a database. <?php define ("MAX_SIZE","100"); define ("WIDTH","150"); define ("HEIGHT","100"); function make_thumb($img_name, $filename, $new_w, $new_h) { $ext = getExtension($img_name); if(!strcmp("jpg", $ext) || !strcmp("jpeg", $ext)) { $src_img = imagecreatefromjpeg($img_name); } if(!strcmp("png", $ext)) { $src_img = imagecreatefrompng($img_name); } if(!strcmp("gif", $ext)) { $src_img = imagecreatefromgif($img_name); } $old_x = imageSX($src_img); $old_y = imageSY($src_img); $ratio1 = $old_x / $new_w; $ratio2 = $old_y / $new_h; if($ratio1 > $ratio2) { $thumb_w = $new_w; $thumb_h = $old_y / $ratio1; } else { $thumb_h = $new_h; $thumb_w = $old_x / $ratio2; } $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(!strcmp("png", $ext)) { imagepng($dst_img, $filename); } else { imagejpeg($dst_img, $filename); } imagedestroy($dst_img); imagedestroy($src_img); } function getExtension($str) { $i = strrpos($str, "."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str, $i+1, $l); return $ext; } $errors = 0; if(isset($_POST['submit'])) { $image = $_FILES['image']['name']; if($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $intel[] = "Error: Wrong Extention, can only be jpg, jpeg, png or gif.";; $errors=1; } else { $size = getimagesize($_FILES['image']['tmp_name']); $sizekb = filesize($_FILES['image']['tmp_name']); if ($sizekb > MAX_SIZE * 10240) { $intel[] = "Error: File is bigger than 10mb"; $errors = 1; } $image_name = $_FILES['image']['name']; $newname = $config_gallery_dir . $image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { $intel[] = "Error: Your image was not uploaded."; $intel[] = "Error: Your thumbnail was not created."; } else { $thumb_name = $config_thumbnail_dir . $image_name; $thumb = make_thumb($newname, $thumb_name, WIDTH, HEIGHT); $intel[] = "Success! Your image was uploaded."; $intel[] = "Success! Your thumbnail was created."; } } } $insert_query = "INSERT INTO " . $config_gallery_mysql_tbl . " (image, image_ext) VALUES ('" . $_FILES["image"]["name"] . "', '" . $extension . "')"; if($insert_result = mysql_query($insert_query)) { $intel[] = "Success! the database has been updated."; } else { $intel[] = "Error! the database was not updated."; } if(isset($intel)) { echo "<ul>\n"; foreach($intel AS $value) { echo "<li>" . $value . "</li>\n"; } echo "</ul>\n"; } } else { ?> <form action="?action=add" method="post" enctype="multipart/form-data"> <table cellspacing="0" cellpadding="0" border="0" id="admin-table"> <tr> <td class="admin-left">Upload an image</td> <td class="admin-right"><input type="file" name="image" size="50" /></td> </tr> <tr> <td class="admin-left"> </td> <td class="admin-right"><input type="submit" name="submit" value="Submit" /></td> </tr> </table> </form> But when I try to run this script, I get these errors: $config_gallery_dir and $config_thumbnail_dir are located in an external config.inc.php file and as far as I know are not pointing to the wrong area because it uploads the image fine.
  2. there's an easier way, but it means not using tables (Horrah!) if you style a page based on CSS you can use the CSS to display them how you want. example HTML: <div id="gallery"> <h6>img</h6> <h6>img</h6> <h6>img</h6> <h6>img</h6> <h6>img</h6> <h6>img</h6> <h6>img</h6> <h6>img</h6> <h6>img</h6> </div> then the CSS #gallery { padding : 0; width : 600px; height : auto; display : block; float : left; } #gallery h6 { width : 200px; height : 200px; margin : 0; display : block; float : left; } that will display them 3 in a row, for two rows (obviously change your CSS width/height to suite your needs. means you don't need to do anything special with your php code.
  3. if you're looking to get a user's data based on their profile number, you could use this code: $pfno = $_GET['pfno']; $query = "SELECT lname, fname, oname, department, pfno FROM user_table WHERE pfno='$pfno'"; if($result = mysql_array($query) { echo "<p> PFNO : ".$_SESSION["pfno"]. "<p>Logged in: " .date("m/d/Y", $_SESSION["valid_time"]); while(list($lname, $fname, $oname, $department, $pfno) = mysql_fetch_array($result)) { echo $lname . "<br />"; echo $fname . "<br />"; echo $oname . "<br />"; echo $department . "<br />"; } } else { echo "Error: " . mysql_error() . ". Query: " . $query; }
  4. ok I changed the code to: function str_break($string) { $str_limit = 15; if(strlen($string) >= $str_limit) { $string = substr($string, 0, 15) . ".."; } return $string; } and works now, cheers!
  5. Hi, I've tried creating a small function that breaks up a string if longer than 15 characters but for some reason it's output is wrong. function str_break($string) { $str_limit = 15; if(strlen($string) >= $str_limit) { echo substr($string, 0, 15) . ".."; } else { echo $string; } } and then outputs this way: <?php echo $image_id . ": " . str_break($image) . "\n"; ?> but it outputs as if it is coded this way: <?php echo str_break($image) . $image_id . ": \n"; ?> what's wrong with it?
  6. I'm not sure what I am supposed to do here, I had a look at the function but I couldn't figure out how I was meant to use it? EDIT: figured it out, put it at the top of my config.php file
  7. I get this error: the code: $date = date('d M y', strtotime($date)); $date being a date in the 0000-00-00 00:00:00 format. PHP Version 5.2.6 solution?
  8. Sorry if there are currently loads of topics, I'm not sure what I'm looking for atm so pardon me if this is a repeat topic of some sort. Right I haven't been doing web design for at least a couple years due to ill health so I probably had this solution before but it's gone right out of my head right now lol this is my code, but i'm not sure if this is correct for the subdirectories that i've currently got it in. $query = "SELECT rank, username, member_id FROM members WHERE (username='$u' AND password='$p')"; if($result = @mysql_query ($query)) { list($rank, $username, $member_id) = mysql_fetch_array($result); if($rank == '1') { $redirect_url = $_POST['direction']; if(isset($_POST['v3_cookies'])) { setcookie('username', $username, time()+60*60*24*30, '/', 'website.com', 0); setcookie('member_id', $member_id, time()+60*60*24*30, '/', 'website.com', 0); } else { $_SESSION['username'] = $username; $_SESSION['member_id'] = $member_id; } mysql_free_result($result); ob_end_clean(); // Delete the buffer. header("location: /index.php"); exit(); } else { echo "<font style=\"color : #F00; font-weight : bold;\">NOTE:</font> You do not have permission to Access the Administration Area."; } } else { $info[] = 'The Username and Password entered do not match those on file.'; $info2[] = '<br /><br />Error: ' . mysql_error() . '<br /><br />Query : ' . $query; } what is the right way of putting this bit of code when it's in a few subdirectories? setcookie('username', $username, time()+60*60*24*30, '/', 'website.com', 0); setcookie('member_id', $member_id, time()+60*60*24*30, '/', 'website.com', 0); thanks very much for reading, as previously mentioned it's been a while since I've done this and i'm getting a bit of a headache right now so can't think straight :'(
  9. yes 2.78125 appears as 66:45:00 (HH:MM:SS) in excel, but I want it to appear like that by doing the same calculation in PHP.
  10. Hi, I'm working on a little calculation thing, the result turned out to be 2.78125 this however is in days (it would appear as 66 hours, 45 minutes, 0 seconds. how do I format 2.78125 so that PHP displays it as HH:MM:SS ?? thanks in advance.
  11. ok so I tested it, all " and ' are replaced with htmlentities() but I'm still getting the following error.. EDIT: firefox no longer works with the feeds after htmlentities() is used.. RSS feed code can be found on this text file http://www.integritynewz.com/feeds/ineconomy.txt
  12. thanks, that should work (i hope) will test it in a sec. what other things does xml not allow between tags other then " and ' ?
  13. Hi, I have my own news script which recently got it's own RSS builder built into it. the problem I'm having is that whenever there is a ' (example: let's, I'm) it seems to make the RSS error when viewed by IE6. is there a way around this? i.e stripping the ' from the text before inputted (basicly grabs the info from mysql and writes to a file like test_rss.xml using php)
  14. Hi, first off I have these directories (sub domains) on the server: [1] /images.mysite.com/ [2] /mysite.com/feeds/ [3] /admin.mysite.com/ I have news feeds in [2] that I want to update via PHP in [3] subdomain (via browser) what happens is when a new article is added to the database, it loads a script (with an include() ) and then updates the feeds. but I can't get the include to work, i tried a few ../ and even copying the entire address but this does not seem to work. the same goes for another where I upload an image at [3] (via browser) to [1] but I can't get the include() url. all folders/files involved have been set to 0777. hope this is understandable.
  15. Ok so weirdly enough I changed the location of my files to another directory and they worked fine... weird
  16. ok I cleared everything on IE6 and still 404 error, I found it works on some pages and not others.
  17. Can anyone tell me why my webpage is working great in FF but when I look at it in IE6 it tells me 404 Error? it's driving me nuts!
  18. Ok so what would you suggest? any links to relative information would be helpful if you can provide some? TJ
  19. are you refering to a COUNT() ? or something else because I don't know. and what do you mean by not using the ID as a counter? do you mean the photo_id on my table? or something else?
  20. I managed to figure it out, here's my query. [code]SELECT COUNT(photo_url) FROM photos WHERE (album_name='{$category}') AND (photo_url BETWEEN 1 AND {$photo_id})) AS current_count[/code] I used a subquery so that I could give it it's own WHERE clause which I used to count the number of rows between 1 and the photo_id of the album_id which you would have been viewing, to count how what the [b]XX[/b] of XX would be regardless of what the the $_GET id would be.
  21. I'm trying to create an addon for my gallery that basicly says "Viewing XX of XX in xxcategoryxx" but I'm running into some problems. first I thought i'd try just using the $_GET['id'] in connection with the id in the mysql table to get the the Viewing [b]XX[/b] of XX which works fine so long as you don't delete any rows from the mysql database, so I need something that shows what mysql row i'm on I thought maybe $counting = current($row); would work but it's doing the same thing as if it was counting the id from the database say if theres' 5 pics but you deleted one like this.. id  |  pic 1      1 2      2 4      4 5      5 i want it to show up like this id 1 gets you 1 of X id 2 gets you 2 of x id 4 gets you 3 of x id 5 gets you 4 of x and so on, but I can't seem to find anything that works atm. my query: [code]SELECT photo_url, photos.album_name, photos.album_id, photo_views FROM photos LEFT JOIN albums ON photos.album_id=albums.album_id WHERE ( photos.album_name='{$category' AND photo_url='{$photoid}')[/code]
  22. Hi, I have a table called forums [code] `forum_id` INT(11) NOT NULL AUTO_INCREMENT, `title` VARCHAR(100) NOT NULL, `subtitle` TEXT NOT NULL, PRIMARY KEY (forum_id)) [/code] which works well. but now I want to add sub forums, so I thought I would do it this way: [code]`subforum` INT(11),[/code] but it seems doing a value of (forum_id being 2 would mean subforum's going in forum_id 2 would be that X but no idea how to group them, since I already group them by forum_id. I have these tables also: topics [code] `topic_id` INT(11) NOT NULL AUTO_INCREMENT, `date` datetime NOT NULL, `title` VARCHAR(100) NOT NULL, `article` TEXT NOT NULL, `views` INT(11) NOT NULL, `member_id` INT(11) NOT NULL, `forum_id` INT(11) NOT NULL, PRIMARY KEY (topic_id)) [/code] 'replies' [code] `reply_id` INT(11) NOT NULL AUTO_INCREMENT, `date` datetime NOT NULL, `article` TEXT NOT NULL, `member_id` INT(11) NOT NULL, `topic_id` INT(11) NOT NULL, PRIMARY KEY (reply_id)) [/code] so I'm wondering if better to do a table called subforums instead? would this work better or is there a sollution to my already made table? thanks for reading. -- TJ
  23. Hi, how would I go about using a [code]$categories = '1,3,4';[/code] then splitting them up so they come out with a mysql query like this: [code]SELECT * FROM news WHERE cat_id='1' AND cat_id='3' AND cat_id='4' ORDER BY date LIMIT 5[/code] I tried using functions like [code]explode() list() foreach()[/code] etc, but I haven't found anything that works yet. can anyone give me some advice on how I would need to do this? -- TJ
×
×
  • 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.