Jump to content

tjhilder

Members
  • Posts

    136
  • Joined

  • Last visited

    Never

About tjhilder

  • Birthday 01/13/1984

Contact Methods

  • Website URL
    http://ceti.astroempires.com/?ref=C.31611

Profile Information

  • Gender
    Male
  • Location
    Kent, UK

tjhilder's Achievements

Member

Member (2/5)

0

Reputation

  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.
×
×
  • 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.