Jump to content

lpxxfaintxx

Members
  • Posts

    181
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    BagFullOfRice
  • MSN
    lpxxfaintxx@yahoo.com

Profile Information

  • Gender
    Not Telling

lpxxfaintxx's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Gah! SO sorry, I meant to paste the code in the original post, but I must've forgot. $featured_dir = 'albums/'.$random.'/original/'; $file_types = array('gif','jpg','png'); $dir = 'albums/'.$random.'/'; $scan = scandir($dir); for ($i=0; $i<count($scan); $i++) { if ($scan[$i] != '.' && $scan[$i] != '..' && in_array(end(explode('.', $scan[$i])), $file_types)) { echo ' <p class="photoind"> <a href="' . $featured_dir . $scan[$i] . '" rel="lightbox-'.$random.'"> <img src="'. $dir . $scan[$i] . '" alt="'. $scan[$i] . '" width="132" height="132" rel="lightbox"/> <br /> </a> </p>'; } }
  2. I wrote a simple piece that scans the directory for images only. How would I check if there are NO IMAGES in the folder? (Note, I said no images, not files). I want to make an if statement so that if no images exist in the folder, then echo 'whatever.' Thanks
  3. Thanks, I will look into that. What is the date format for MySQL? Is it YYYY-MM-DD? Also, when I echo out the date in PHP, how do I make the date more "user-friendly?" IE, how do I make it show up as "February 24, 2009" instead of "2009-02-24" After I change the column to date, then what do I do? Any query to get the dates in the future?
  4. I have a database of events that have a table 'date' that has dates stored in the format "Month Day, Year." How would I make make a query that only selects dates that are in the future, and not past? For example, today is February 9, 2009. Let's say I have the following rows with the 'date' tables: January 4, 2009 January 31, 2009 February 21, 2009 February 26, 2009 How would I make it so that I only get "February 21, 2009" and "February 26, 2009," since they are UPCOMING, and not in the past? Hope that makes sense. thanks
  5. I have echoed out a piece of HTML with PHP, which executes beautifully, but the Javascript aspect of it is giving me a hard time. echo '<li onselect="document.getElementById(\'schoolName\').value = '.$name.'; document.getElementById(\'schoolID\').value ='.$id.'; "><span>'.$state.'</span>'.$name.'</li>'; I was hoping that my form value would change on the spot, but that's not the case. It won't change at all. I have made sure that my form names were set properly (schoolName and schoolID). I have made sure that $name and $id stores the correct values. Anyone have any ideas? =/ Thanks
  6. Oh god, I feel like an idiot. Anyways, thank you very much.
  7. WOW, I feel so stupid now. One thing though... It echos out the literal '$name', not the value stored in $name. I made sure that the correct values were stored in $name and $id. Any idea what's up? while ($row = mysql_fetch_array( $results )) { $id = $row["ID"]; $name = ucwords( strtolower( $row["School_name"] ) ); $name = preg_replace("/(" . $q . ")/i", "<b>$1</b>", $name); echo '<li onselect="this.text.value = '.$name.'; document.getElementById(\'schoolID\').value ='.$id.'; ">$name</li>n'; } Once again, I made sure that values were indeed stored in $name and $id, but currently its echoing out literally "$name" and $id" Thanks!
  8. Basically, this is what I want to output: <li onselect="this.text.value = 'name'; document.getElementById('schoolID').value = 'id'; "> name </li> I have tried the following: echo '<li onselect="this.text.value = '.$name.'; document.getElementById('schoolID').value ='.$id.' \; ">$name</li>n'; But because of the semicolon, it thinks that the echo ENDS where the semicolon is. Any way to work around that? Thanks
  9. So basically, I am using a script that automatically grabs an image and create a thumbnail. It works like a charm on a different enviroment where only 1 image is uploaded, but when I try to upload multiple files, I get several errors. foreach ($_FILES["pictures"]["name"] as $key => $value) { $uploaddir = 'albums/'.$album.'/original/'; //a directory inside $uploadfile = $uploaddir . basename($_FILES["pictures"]["name"][$key]); if (move_uploaded_file($_FILES["pictures"]["tmp_name"][$key], $uploadfile)) { echo $value . ' uploaded<br>'; } include 'cropimage.php'; $crop = new Crop_Image_To_Square; $crop->source_image = $_FILES['pictures']['tmp_name'][$key]; $ext = end(explode('.', $_FILES['pictures']['name'][$key])); $crop->save_to_folder = 'albums/'.$album; $crop->new_image_name = basename($_FILES["pictures"]["name"][$key]); $process = $crop->crop('center'); cropimage.php: <?php /* -------------------------------------------------------------------------------------------- Credits: Bit Repository Source URL: http://www.bitrepository.com/web-programming/php/crop-rectangle-to-square.html -------------------------------------------------------------------------------------------- */ /* Crop Image Class */ class Crop_Image_To_Square { var $source_image; var $new_image_name; var $save_to_folder; function crop($location = 'center') { $info = GetImageSize($this->source_image); $width = $info[0]; $height = $info[1]; $mime = $info['mime']; // What sort of image? $type = substr(strrchr($mime, '/'), 1); switch ($type) { case 'jpeg': $image_create_func = 'ImageCreateFromJPEG'; $image_save_func = 'ImageJPEG'; $new_image_ext = 'jpg'; break; case 'png': $image_create_func = 'ImageCreateFromPNG'; $image_save_func = 'ImagePNG'; $new_image_ext = 'png'; break; case 'bmp': $image_create_func = 'ImageCreateFromBMP'; $image_save_func = 'ImageBMP'; $new_image_ext = 'bmp'; break; case 'gif': $image_create_func = 'ImageCreateFromGIF'; $image_save_func = 'ImageGIF'; $new_image_ext = 'gif'; break; case 'vnd.wap.wbmp': $image_create_func = 'ImageCreateFromWBMP'; $image_save_func = 'ImageWBMP'; $new_image_ext = 'bmp'; break; case 'xbm': $image_create_func = 'ImageCreateFromXBM'; $image_save_func = 'ImageXBM'; $new_image_ext = 'xbm'; break; default: $image_create_func = 'ImageCreateFromJPEG'; $image_save_func = 'ImageJPEG'; $new_image_ext = 'jpg'; } // Coordinates calculator if($width > $height) // Horizontal Rectangle? { if($location == 'center') { $x_pos = ($width - $height) / 2; $x_pos = ceil($x_pos); $y_pos = 0; } else if($location == 'left') { $x_pos = 0; $y_pos = 0; } else if($location == 'right') { $x_pos = ($width - $height); $y_pos = 0; } $new_width = $height; $new_height = $height; } else if($height > $width) // Vertical Rectangle? { if($location == 'center') { $x_pos = 0; $y_pos = ($height - $width) / 2; $y_pos = ceil($y_pos); } else if($location == 'left') { $x_pos = 0; $y_pos = 0; } else if($location == 'right') { $x_pos = 0; $y_pos = ($height - $width); } $new_width = $width; $new_height = $width; } $image = $image_create_func($this->source_image); $new_image = ImageCreateTrueColor($new_width, $new_height); // Crop to Square using the given dimensions ImageCopy($new_image, $image, 0, 0, $x_pos, $y_pos, $width, $height); if($this->save_to_folder) { if($this->new_image_name) { $new_name = $this->new_image_name.'.'.$new_image_ext; } else { $new_name = $this->new_image_name(basename($this->source_image)).'_square_'.$location.'.'.$new_image_ext; } $save_path = $this->save_to_folder.$new_name; } else { /* Show the image (on the fly) without saving it to a folder */ header("Content-Type: ".$mime); $image_save_func($new_image); $save_path = ''; } // Save image $process = $image_save_func($new_image, $save_path) or die("There was a problem in saving the new file."); return array('result' => $process, 'new_file_path' => $save_path); } } function new_image_name($filename) { $string = trim($filename); $string = strtolower($string); $string = trim(ereg_replace("[^ A-Za-z0-9_]", " ", $string)); $string = ereg_replace("[ \t\n\r]+", "_", $string); $string = str_replace(" ", '_', $string); $string = ereg_replace("[ _]+", "_", $string); return $string; } ?> Any ideas? Any other ways of creating thumbnails for multiple images? Thanks
  10. I've tried everything, still not working. =/ $query3 = mysql_query("INSERT INTO pms (`from`,`to`,`subject`,`message`,`time`) VALUES (`$from`, `$finalto`, `$subject`, `$message`, `$time`") or die(mysql_error()); $query3 = mysql_query("INSERT INTO pms (`from`,`to`,`subject`,`message`,`time`) VALUES ('$from', '$finalto', '$subject', '$message', '$time'") or die(mysql_error()); $query3 = mysql_query("INSERT INTO pms (`from`,`to`,subject,message,time) VALUES ('$from', '$finalto', '$subject', '$message', '$time'") or die(mysql_error());
  11. $finalto = $user[to]; $from = $messagefrom; $subject = $_POST['subject']; $message = $_POST['message']; $time = date("F j, Y"); $query3 = mysql_query("INSERT INTO `pms` (from, to, subject, message, time) VALUES ('$from', '$finalto', '$subject', '$message', '$time'") or die(mysql_error()); Seriously, did I do something wrong, or am I just going crazy?
  12. So I created a simple function that strips all posted data from potential malicious data, but I realized a big flaw. All the apostrophes were stripped, resulting in awkward looking text when saved. Is there any better way of doing this? How would I output it? function form($data) { global $db_connect; $data = ereg_replace("[\'\")(;|`,<>]", "", $data); $data = mysql_real_escape_string(trim($data), $db_connect); return stripslashes($data); }
  13. Very frustrating. I have echoed out $sessid and $friendid to make sure that data is indeed stored in those two variables. $query = mysql_query("SELECT * FROM friends WHERE username = '$sessid' AND friendname = '$friendid'") or die(mysql_error()); $result = mysql_query($query); $row = mysql_fetch_array($result); $num_results = mysql_num_rows($result); if ($num_results > 0){ $isfriend = 'y'; }else{ $isfriend = 'n'; } Error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/q94/public_html/alumnify.com/profile.php on line 46 Any ideas? Thanks a bunch.
×
×
  • 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.