Jump to content

upendra470

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

About upendra470

  • Birthday 09/02/1988

Profile Information

  • Gender
    Male

upendra470's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i am using this phpmailer script. $body = $message; $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "mail.hdd.net.in"; // SMTP server $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "abc@hdd.net.in"; // GMAIL username $mail->Password = "*******"; // GMAIL password $mail->Subject = $subject; $mail->MsgHTML($body); $mail->AddAddress($to); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } } ?> But it shows SMTP -> ERROR: Failed to connect to server: Connection timed out (110) SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
  2. I have been using simple mail function for mailing but the problem is the mail client has been configured in google apps. So whenever this script runs , it sends mail to webmail but not to gmail. What kind of mail function should i use to send emails to gmail. My domain registrar told me to use user authentication mail function but i am unable to find any such function in PHP. Please provide any concrete solution. <?php if(isset($_POST['submit'])){ $name = $_POST['nameText']; $email = $_POST['emailText']; $phone= $_POST['phoneText']; $campany = $_POST['subjectText']; $query = $_POST['messagetText']; $replyback = $_POST['categoryRadio']; $headers = 'From : info@hdd.net.in'. "\r\n" .'Reply-To: info@hdd.net.in' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $to="abd@domain.in"; $subject="Requirements of a client"; if($replyback==1) { $message="Name - ".$name. "\n Company Name - " .$campany. "\n Email - ".$email. "\n Phone No - " .$phone. "\n Query - " .$query."\nReply by Email"." "; } else { $message="Name - ".$name. "\n Company Name - " .$campany. "\n Email - ".$email. "\n Phone No - " .$phone. "\n Query - " .$query."\nReply by Phone"." "; } $result = mail($to, $subject, $message, $headers); if($result){ echo "<script type = 'text/javascript'> alert('Mail Sent. We will get back to you shortly');</script>"; } } ?>
  3. Thanks alot. I should have concentrated on my code . I interchange the last four lines and it worked. Thanks once again.
  4. I want to delete an image file from a folder using unlink. The code is : $movie_id = $checkbox[$i]; $sql = "DELETE from movie_basic_details where `movie_id` = '$movie_id'"; $result = mysql_query($sql) or die(mysql_error()); $sql1 = "DELETE from movie_details where `movie_id` = '$movie_id'"; $result = mysql_query($sql1) or die(mysql_error()); $sql2 = "DELETE from movie_stars where `movie_id` = '$movie_id'"; $result = mysql_query($sql2) or die(mysql_error()); $query = "select movie_name from movie_basic_details where movie_id = '$movie_id'"; $res = mysql_query($query) or die(mysql_error()); $data = mysql_fetch_array($res); unlink("upload/movies/".$data['movie_name']); } The entries in the database have been deleted but only the image corresponds to that entry do not get deleted. The following warning comes up : Warning: unlink(upload/movies/) [function.unlink]: Permission denied in C:\wamp\www\ContentPanel\deletemovies.php on line 23 I have uploaded the files using $_FILES server variable and move_uploaded_file function. I am running this script on windows 7. Please Help.
  5. I can upload a number of images in localhost but when i uploaded my site on remote server then on multiple uploading of images it shows this error Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 10240 bytes) in /home/ihroydc/public_html/control/addgallery.php on line 51 here is my code <?php ob_start(); ?> <?php include "session.php"; include "connect.php"; if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>8097152){ echo "<script type = 'text/javascript'>alert('Upload files is too large. Cannot add to the gallery'); window.location = 'gallery.php';</script>"; exit(); } else{ $n_width = 100; $n_height = 100; if(count($_FILES["image_id"]["name"]) > 0){ for($j=0; $j < count($_FILES["image_id"]["name"]); $j++){ if ((($_FILES["image_id"]["type"][$j] == "image/gif") || ($_FILES["image_id"]["type"][$j] == "image/jpeg") || ($_FILES["image_id"]["type"][$j] == "image/pjpeg")) && ($_FILES["image_id"]["size"][$j] < 40000000)) { if ($_FILES["image_id"]["error"][$j] > 0) { echo "Return Code: " . $_FILES["image_id"]["error"][$j] . "<br />"; } else { if (file_exists("/home/ihroydc/public_html/control/upload/compressed/" . $_FILES["image_id"]["name"][$j])) { echo "<script type = 'text/javascript'>alert('Image already exist'); window.location = 'gallery.php';</script>"; } else { move_uploaded_file($_FILES["image_id"]["tmp_name"][$j], "/home/ihroydc/public_html/control/upload/gallery/" . $_FILES["image_id"]["name"][$j]); echo "Stored in: " . "upload/gallery/" . $_FILES["image_id"]["name"][$j]; $tsrc = "/home/ihroydc/public_html/control/upload/thumbs/".$_FILES["image_id"]["name"][$j]; $im = imagecreatefromjpeg("/home/ihroydc/public_html/control/upload/gallery/".$_FILES["image_id"]["name"][$j]); $width = imagesx($im); $height = imagesy($im); $newimage = imagecreatetruecolor($n_width,$n_height); imagecopyresampled($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagejpeg($newimage, $tsrc); chmod("$tsrc", 0777); $im_info = getimagesize("/home/ihroydc/public_html/control/upload/gallery/".$_FILES["image_id"]["name"][$j]); $im_width = $im_info[0]; $im_height = $im_info[1]; $im_flag = $im_info[2]; $im_divicew = $im_width / 800; $im_diviceh = $im_height / 600; $thumb_width = $im_width / $im_divicew; $thumb_height = $im_height / $im_diviceh; $thumb = imagecreatetruecolor($thumb_width, $thumb_height); imagecopyresampled($thumb, $im, 0, 0, 0, 0, $thumb_width, $thumb_height, $im_width, $im_height); $csrc = "/home/ihroydc/public_html/control/upload/compressed/".$_FILES["image_id"]["name"][$j]; imagejpeg($thumb,$csrc, 100); @unlink("/home/ihroydc/public_html/control/upload/gallery/".$_FILES["image_id"]["name"][$j]); } } } else { echo "Invalid file"; } } } } $category = $_POST['category']; $desc = $_POST['desc']; for($j=0; $j < count($_FILES["image_id"]["name"]); $j++){ $pic_name = $_FILES["image_id"]["name"][$j]; $sql= "insert into gallery (category, pic_desc, pic_name) values('$category', '$desc', '$pic_name')"; $result = mysql_query($sql) or die(mysql_error()); } if($result){ echo "<script type = 'text/javascript'>alert('Picture uploaded sucessfully'); window.location = 'gallery.php';</script>"; //echo "<h4 style='color:green;'>Picture uploaded sucessfully</h4>"; //echo "<meta http-equiv=\"refresh\" content=\"1;URL=gallery.php\" />"; //header("location: galleryadded.php"); } else{ echo " <script type = 'text/javascript'>alert('Image cannot be added. It already exist'); window.location = 'gallery.php'; </script>"; } ?> <?php ob_flush(); ?> [\code] Any help would be appreciated. Thanx
  6. I have been trying to compress a set of images which are entered through a form. But I am not able to compress the images. The images are uploaded in the 'gallery' folder but not in the 'thumbs' folder which stores the compressed images. Here is my code: $tsrc = "upload/thumbs/".$_FILES["image_id"]["name"][$j]; $imgfile = $_FILES["image_id"]["tmp_name"][$j]; move_uploaded_file($imgfile , "upload/gallery/" . $_FILES["image_id"]["name"][$j]); list($width,$height)=getimagesize($imgfile); echo $width; echo $height; $imgratio=$width/$height; if($imgratio>1) { $newwidth=$thumbsize; $newheight=$thumbsize/$imgratio; } else { $newheight=$thumbsize; $newwidth=$thumbsize*$imgratio; } $thumb=imagecreatetruecolor($newwidth,$newheight); // Making a new true color image $source=imagecreatefromjpeg($imgfile); // Now it will create a new image from the source imagecopyresampled($thumb,$source,0,0,0,0,$newwidth,$newheight,$width,$height); // Copy and resize the image imagejpeg($thumb,$tsrc,100); Please tell where i am wrong. Any help would be appreciated.
  7. The problem is solved now. I changed the permission of my uploaded folder to 0777 and added the full path to the move_uploaded_file function. Tha full path i gave /home/gal37542/public_html/control/upload/gallery/ And it worked fine!! Thank you to all of you!
  8. Warning: move_uploaded_file(upload/gallery/Image0081.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/gal37542/public_html/control/addgallery.php on line 48 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpzhEQW5' to 'upload/gallery/Image0081.jpg' in /home/gal37542/public_html/control/addgallery.php on line 48 I got these two warning while uploading the files. Can anyone tell my what i have to do to correct it. Any help will be appreciated. Thanx.
  9. Thanx for the advice. But can you please tell me where i can find the error.log file?
  10. Nothing works. Can you tell me the exact path or exact correction i need to make in this code. I have been trying for so long but still not got anything positive.
  11. I have uploaded a folder on web for storing images. When I ran my php code to add images on localhost, it works perfectly fine but when i uploaded it on the web server, no image is produced inside the folder but it says 'image successfully added' Please help. Here is my addgallery.php code <?php include "session.php"; include "connect.php"; if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>8097152){ echo "<script type = 'text/javascript'>alert('Upload files is too large. Cannot add to the gallery'); window.location = 'gallery.php';</script>"; exit(); } else{ $n_width = 100; $n_height = 100; if(count($_FILES["image_id"]["name"]) > 0){ for($j=0; $j < count($_FILES["image_id"]["name"]); $j++){ if ((($_FILES["image_id"]["type"][$j] == "image/gif") || ($_FILES["image_id"]["type"][$j] == "image/jpeg") || ($_FILES["image_id"]["type"][$j] == "image/pjpeg")) && ($_FILES["image_id"]["size"][$j] < 40000000)) { if ($_FILES["image_id"]["error"][$j] > 0) { echo "Return Code: " . $_FILES["image_id"]["error"][$j] . "<br />"; } else { //echo "Upload: " . $_FILES["image_id"]["name"] . "<br />"; //echo "Type: " . $_FILES["image_id"]["type"] . "<br />"; //echo "Size: " . ($_FILES["image_id"]["size"] / 1024) . " Kb<br />"; // echo "Temp file: " . $_FILES["image_id"]["tmp_name"] . "<br />"; if (file_exists("upload/gallery/" . $_FILES["image_id"]["name"][$j])) { echo $_FILES["image_id"]["name"][$j] . " already exists. "; } else { move_uploaded_file($_FILES["image_id"]["tmp_name"][$j], "upload/gallery/" . $_FILES["image_id"]["name"][$j]); echo "Stored in: " . "upload/gallery/" . $_FILES["image_id"]["name"][$j]; /* $tsrc = "upload/thumbs/".$_FILES["image_id"]["name"][$j]; $im = imagecreatefromjpeg("upload/gallery/".$_FILES["image_id"]["tmp_name"][$j]); $width = imagesx($im); $height = imagesy($im); $newimage = imagecreatetruecolor($n_width,$n_height); //$background = imagecolorallocate($newimage,255,255,255); //imagecolortransparent($newimage, $background); //imagealphablending($newimage, false); //imagesavealpha($image, true); imagecopyresampled($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagejpeg($newimage, $tsrc);*/ //chmod("$tsrc", 0777); } } } else { echo "Invalid file"; } } } } $category = $_POST['category']; $desc = $_POST['desc']; for($j=0; $j < count($_FILES["image_id"]["name"]); $j++){ $pic_name = $_FILES["image_id"]["name"][$j]; $sql= "insert into gallery (category, pic_desc, pic_name) values('$category', '$desc', '$pic_name')"; $result = mysql_query($sql) or die(mysql_error()); } if($result){ //echo "<h4 style='color:green;'>Picture uploaded sucessfully</h4>"; //echo "<meta http-equiv=\"refresh\" content=\"1;URL=gallery.php\" />"; header("location: galleryadded.php"); } else{ echo " Images cannot be added"; } ?>
  12. I have been running my project on localhost, it works perfectly fine. But as soon as I have uploaded on web i got two warnings. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/gal37542/public_html/control/_includes/header.html: in /home/gal37542/public_html/control/session.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at /home/gal37542/public_html/control/_includes/header.html: in /home/gal37542/public_html/control/session.php on line 34 Here my header.html file <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Control Panel for IHROYDC</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="Galaxias" content="cpanel " /> <meta name="description" content="Cpanel for IHROYDC" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="header">International Human Rights Organization<div class="header">Control Panel for IHROYDC Official Website</div></div> <div id="menu"> <div class="menu"><a href="home.php">home</a></div><div class="menu"><a href="user.php">User</a></div><div class="menu"><a href="news.php">News</a></div> <div class="menu"><a href="gallery.php">gallery</a></div><div class="menu"><a href="testimonials.php">Testimonials</a></div><div class="menu"><a href="events.php">Events</a></div><div class="menu"><a href="legaladvice.php">Legal Advice/Complaints</a></div><div class="menu"><a href="casestudies.php">Case Studies</a></div><div class="menu"><a href="sendmail.php">send mail</a></div> </div> and here is session.php <?php session_start(); if (isset($_SESSION['valid_user'])) { echo '<h3>You are logged in as: '.$_SESSION['valid_user'].'</h3>'; echo '<h1 align = "right"><a href = "logout.php">Logout </a></h1>'; $now = time(); $limit = $now - 60 * 10; if (isset ($_SESSION['last_activity']) && $_SESSION['last_activity'] < $limit) { // if too old, clear the session array and redirect $_SESSION = array(); header('Location: index.html'); exit; } else { // otherwise, set the value to the current time $_SESSION['last_activity'] = $now; } } else { if(isset($username)) { echo 'Could not log you in'; } else { header("location:access-denied.php"); } } ?> Please tell me asap. Any info will be of great help!!
  13. I changed the path also still not getting the desired result. Same black image of size thumbnail is produced
  14. Thanks for replying but i have uploaded a jpg image and still the same thumbnail was produced i.e a small black image.
  15. I have been trying for so long but not got any success. When i try to make thumbnails for an array of images, a blank image of size same as that of thumbnail is created. No image is shown. Here is my code: <?php include "session.php"; include "connect.php"; if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>8097152){ echo 'Upload FAILED, file is too large !'; exit(); } else{ $n_width = 100; $n_height = 100; if(count($_FILES["image_id"]["name"]) > 0){ for($j=0; $j < count($_FILES["image_id"]["name"]); $j++){ if ((($_FILES["image_id"]["type"][$j] == "image/gif") || ($_FILES["image_id"]["type"][$j] == "image/jpeg") || ($_FILES["image_id"]["type"][$j] == "image/pjpeg")) && ($_FILES["image_id"]["size"][$j] < 40000000)) { if ($_FILES["image_id"]["error"][$j] > 0) { echo "Return Code: " . $_FILES["image_id"]["error"][$j] . "<br />"; } else { //echo "Upload: " . $_FILES["image_id"]["name"] . "<br />"; //echo "Type: " . $_FILES["image_id"]["type"] . "<br />"; //echo "Size: " . ($_FILES["image_id"]["size"] / 1024) . " Kb<br />"; // echo "Temp file: " . $_FILES["image_id"]["tmp_name"] . "<br />"; if (file_exists("upload/gallery/" . $_FILES["image_id"]["name"][$j])) { echo $_FILES["image_id"]["name"][$j] . " already exists. "; } else { move_uploaded_file($_FILES["image_id"]["tmp_name"][$j], "upload/gallery/" . $_FILES["image_id"]["name"][$j]); echo "Stored in: " . "upload/gallery/" . $_FILES["image_id"]["name"][$j]; $tsrc = "upload/thumbs/".$_FILES["image_id"]["name"][$j]; $im = imagecreatefromjpeg($_FILES["image_id"]["name"][$j]); $width = imagesx($im); $height = imagesy($im); $newimage = imagecreatetruecolor($n_width,$n_height); imagecopyresampled($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height); imagejpeg($newimage, $tsrc); //chmod("$tsrc", 0777); } } } else { echo "Invalid file"; } } } } $category = $_POST['category']; $desc = $_POST['desc']; for($j=0; $j < count($_FILES["image_id"]["name"]); $j++){ $pic_name = $_FILES["image_id"]["name"][$j]; $sql= "insert into gallery (category, pic_desc, pic_name) values('$category', '$desc', '$pic_name')"; $result = mysql_query($sql) or die(mysql_error()); } if($result){ //echo "<h4 style='color:green;'>Picture uploaded sucessfully</h4>"; //echo "<meta http-equiv=\"refresh\" content=\"1;URL=gallery.php\" />"; header("location: newsadded.php"); } else{ echo " News cannot be added"; } ?> Please tell me where i am wrong.
×
×
  • 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.