Jump to content

lpxxfaintxx

Members
  • Posts

    181
  • Joined

  • Last visited

    Never

Everything posted by lpxxfaintxx

  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.
  14. $marital = form($_POST['marital']); $sexpref = form($_POST['sexpref']); $relview = form($_POST['relview']); $polparty = form($_POST['polparty']); $music = form($_POST['music']); $books = form($_POST['books']); $movies = form($_POST['movies']); $shows = form($_POST['shows']); $aboutme = form($_POST['aboutme']); $userid = form($_POST['userid']); $query = "UPDATE users SET marital='$marital',$sexpref='$sexpref',relview='$relview',polparty='$polparty',music='$music',books='$books',movies='$movies',tv='$shows',aboutme='$aboutme' WHERE user_id='$userid'" ; mysql_query($query) or die ("Error in query: $query"); I get an error, but I can't figure out what I did wrong. I looked at working examples, and they are structured the same.
  15. Wow, sorry for the troubles guys. I found my problem, and it's quite an embarrassing one. I only re-uploaded functions.php and not profilepic.php.
  16. profilepic.php $sessid = $_SESSION['id']; $user = queryuser($sessid); if ($user[profilepic] == "") { $imgurl = "images/nophoto.jpg"; } else { $imgurl = $user[profilepic]; } if(isset($_FILES['upload'])){ if(preg_match('/[.](jpg)|(gif)|(png)$/', $_FILES['upload']['name'])){ $filename = $_FILES['upload']['name']; $ext = pathinfo($filename, PATHINFO_EXTENSION); $filename2 = $user[user_id]; $source = $_FILES['upload']['tmp_name']; $target = $path_to_image_directory . $filename2 .'.'.$ext; move_uploaded_file($source, $target); createThumbnail($filename2,$ext); } functions.php function createThumbnail($filename2,$ext) { require 'config.php'; if(preg_match('/[.](jpg)$/', $filename2 .'.'.$ext)) { $im = imagecreatefromjpeg($path_to_image_directory . $filename2 .'.'.$ext); } else if (preg_match('/[.](gif)$/', $filename2 .'.'.$ext)) { $im = imagecreatefromgif($path_to_image_directory . $filename2 .'.'.$ext); } else if (preg_match('/[.](png)$/', $filename2 .'.'.$ext)) { $im = imagecreatefrompng($path_to_image_directory . $filename2 .'.'.$ext); } $ox = imagesx($im); $oy = imagesy($im); if($ox > 300){ $nx = $final_width_of_image; $ny = floor($oy * ($final_width_of_image / $ox)); $nm = imagecreatetruecolor($nx, $ny); imagecopyresized($nm, $im, 0,0,0,0,$nx,$ny,$ox,$oy); if(!file_exists($path_to_thumbs_directory)) { if(!mkdir($path_to_thumbs_directory)) { die("There was a problem. Please try again!"); } } imagejpeg($nm, $path_to_thumbs_directory . $filename2 .'.'.$ext); $tn = '<img src="' . $path_to_thumbs_directory . $filename2 .'.'.$ext . '" alt="image" />'; $tn .= '<br />Congratulations. Your file has been successfully uploaded, and a thumbnail has been created.'; echo $tn; } else { } Error: Warning: Missing argument 2 for createThumbnail(), called in /home/q94/public_html/alumnify.com/profilepic.php on line 30 and defined in /home/q94/public_html/alumnify.com/includes/classes.php on line 19 Any idea what I did wrong?
  17. Okay, so I got cocky and decided to give functions a go. (yes, I'm a newbie). I have profilepic.php and classes.php In profilepic.php, I called in the classes, include("classes.php"); and *attempted* to create a simple function: function queryuser($sessid){ $query = mysql_query("SELECT * FROM users WHERE user_id = '$sessid'") or die(mysql_error()); $row = mysql_fetch_array($query); } Pretty simple so far. I'm trying to get the function to work properly by doing: $sessid = $_SESSION['id']; queryuser($sessid); (I'm sure $sessid is storing its value properly, I have checked by echoing it.) BUT, when I try using any $row[field], the value is empty. In (my) theory, it should store the proper data in the variables, but I guess I'm missing something. Any idea? Thanks!
  18. <?php switch($_GET['action']){ case "login": if(isset($_POST['login'])) { $email = trim(addslashes($_POST['email'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE email = '$email' AND Password = '$password' LIMIT 1") or die (mysql_error()); $row = mysql_fetch_array($query); if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; $_SESSION['rank'] = $row['Activated']; } else { echo ' <p>Sorry, you must activate your account first. Please check your email for the activation email.</p> <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> '; } break; default: <html> include('includes/header.php'); <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="$_SERVER['PHP_SELF']"> <p>Email Address:<br> <input name="email" type="text" Cid="email"> <p>Password:<br> <input name="password" type="password" id="password"> </p> <p> <input name="login" type="submit" id="login" value="Submit"> </p> </form> <p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p> include('includes/footer.php'); </html> break; } ?> Same problem.
  19. I've been looking at the code for quite a while now, trying to see whats wrong. I just can't find it, so I thought some fresh eyes would do a better job. Parse error: syntax error, unexpected T_DEFAULT in /home/q94/public_html/alumnify.com/login.php on line 39 Line 39 is 'default:' <?php switch($_GET['action']){ case "login": if(isset($_POST['login'])) { $email = trim(addslashes($_POST['email'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE email = '$email' AND Password = '$password' LIMIT 1") or die (mysql_error()); $row = mysql_fetch_array($query); if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; $_SESSION['rank'] = $row['Activated']; } else { echo ' <p>Sorry, you must activate your account first. Please check your email for the activation email.</p> <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> '; } break; default: <html> include('includes/header.php'); <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <p>Email Address:<br> <input name="email" type="text" Cid="email"> <p>Password:<br> <input name="password" type="password" id="password"> </p> <p> <input name="login" type="submit" id="login" value="Submit"> </p> </form> <p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p> include('includes/footer.php'); </html> break; } ?>
  20. I want it to escape them, so that users CAN put in quotes in the title and description. (of course, while being protected from SQL injections)
  21. Thanks a bunch for your thoughtful reply. However, it is still not taking in quotes.
  22. The problem still occurs. $v_title = mysql_real_escape_string($_POST_DATA[field_myvideo_title]); $v_descr = mysql_real_escape_string($_POST_DATA[field_myvideo_descr]);
×
×
  • 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.