Jump to content

vinpkl

Members
  • Posts

    448
  • Joined

  • Last visited

Everything posted by vinpkl

  1. hi suresh this is the error i m getting Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in E:\xampp\htdocs\custm\search.php on line 101 vineet
  2. hi suresh the query is returning no values from table. means zero result is showing. if i am not using replace function then $result = mysql_query ("SELECT * FROM product_table WHERE product_name LIKE '%$keyword%'"); then results are showing. Is replace function any version dependent of mysql. vineet
  3. hi suresh $keyword is the name of the search form input field. <input name="keyword" id="keyword" type="text" value="Enter Product Name" onfocus="this.value=''" class="search" /> "product_name" is the name of the field in "product_table" in database This is the code i m using <? if(isset($_REQUEST['keyword'])) { $keyword=$_REQUEST['keyword']; $result = mysql_query ("SELECT * FROM product_table WHERE product_name = REPLACE($keyword,'-','') or product_name LIKE '%$keyword%'"); if(mysql_num_rows($result)>0) { while($row=mysql_fetch_array($result)) { $p_name=$row['product_name']; echo "<tr>"; echo "<td valign=top>". $row['product_name'] ."</td>"; echo "</tr>"; } } ?> please tell if any other information is required. vineet
  4. hi suresh this query doesnt show any result $result = mysql_query ("SELECT * FROM product_table WHERE product_name = REPLACE($keyword,'-','') or product_name LIKE '%$keyword%'"); vineet
  5. Hi suresh so will search query be like this "SELECT * FROM product_table WHERE product_name = REPLACE(product_name,'-','') and product_name LIKE '%$keyword%'" vineet
  6. hi all In the database some product names have hypens in between names like AC-3A, NB-FL. So in my search form if somebody enters keyword like AC3A, NBFL then these products doesnt show in results. I want that these product should get show on both the keywords AC-3A and also AC3A. With string replace i can remove hyphen from the keyword entered but how can i remove hyphen from the product name that is in database because in search query syntax we always write the field name not the product name. $keyword=$_REQUEST['keyword']; $result = mysql_query ("SELECT * FROM product_table WHERE product_name LIKE '%$keyword%'"); vineet
  7. hi cbolson thanks for the reply. your provided solution worked for me. its now deleting the images fine as required. thanks vineet
  8. hi all i want to remove the uploaded images and thumb names from my product table in database. but its not deleting. This is the checkbox in from <input type="checkbox" name="rem" id="rem" /> This is the delete qry if(isset($_REQUEST['rem'])) { $qry_rm="delete '$oldpic2', '$oldthumb2' from product_table where product_id=$id"; echo $qry_rm; $result_rm=mysql_query($qry_rm); } on echoing the qry i get the correct output the images are not deleting. delete 'htc_t8282_flip2.jpg', 'htc_t8282_flip2.jpg' from product_table where product_id=199 vineet
  9. hi thorpe thanks for the reply. it works fine now. vineet
  10. hi all i have set my phone number database field as int. if i enter 0123456 then in the database it gets enter as 123456 leaving 0. vineet
  11. hi all i am sending email with php mail(). i m using the following headers $to= $log_id; $subject= "welcome to company"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:info@domain.com' . "\r\n"; $headers .= "CC:info@domain.com" . "\r\n"; $headers .= "Reply-To:".$log_id . "\r\n"; $headers .= "Return-Path:".$log_id . "\r\n"; $body=" "; if(mail($to,$subject,$body,$headers)) { $msg="email processed";; } else { $msg="order not processed"; } This email function works fine and email is sent successfully. Now i want to send one more email with Different "Reply to" address and rest all remains same. As the $body test is lengthy, so i want to ask that instead of writing two separate full emails code, is there anyother way i can sent two emails simultaneously without repeating my $body code but with different "Reply-To" addresses. vineet
  12. hi avvllvva thanks for the solution. it works great. vineet
  13. hi avvllvva it works fine now but it works for only once. means it replaces only one time. if the string is $pn="sony ericsson w995 black" then it will output sony ericsson, w995 black that is fine but if the string is $pn="sony ericsson w995 black new model just get" then also i get only one comma sony ericsson, w995 black new model just get is it possible to replace every alternate blank space with "," vineet
  14. hi avvllvva i used your code but i didnt understand <?php $new_str =''; $pn="sony ericsson w995 black"; $array_splitted = explode(" ", $pn); for($k=1; $k<=sizeof($array_splitted);$k++){ $new_str .= $array_splitted[$k]; } $final_str = $array_splitted[0]." ".$new_str; echo $final_str; ?> it outputs sony ericssonw995black but i want to output sony ericsson, w995 black vineet
  15. hi oni-kun may be my question was not clear. so here is explanation. like the string is "sony ericsson w995 black". so here with second blank space i mean the blank space after sony ericsson. with your code $pn=$row_ot['product_name']; $pn = str_replace(" ", " ,", $pn); it will search for two blank spaces together. vineet
  16. hi all i can replace every " " blank space with "," str_replace $pn=$row_ot['product_name']; $pn = str_replace(" ", ",", $pn); but if i want to replace every "alternate blank space" then what will be the solution. Means i want to leave first blank space as it is and would like to replace the second blank space with ",". vineet
  17. hi does trim() function works with email id i m using it to remove extra blank space from start and end of email id $customer_email=trim($_REQUEST['customer_email']); but its not working vineet
  18. hi crayon thanks. it works great now vineet
  19. hi all some of the customers have saved their password in the notepad file. when they copy it, sometimes extra blank spaces get copied in the begining or end of the password with which password becomes incorrect. so i m trying to accept the password without the extra spaces in beginging and end of the password entered. i tried $password=trim(base64_encode($_REQUEST['password'])); but still its accepting the blank spaces and showing mesage password is incorect. if i enter password manually then it works fine. vineet
  20. hi patrick if i change move_uploaded_file($_FILES['file']['tmp_name'], "/upload/" . $_FILES['file']['name']); to move_uploaded_file($_FILES['file']['tmp_name'], "upload/" . $_FILES['file']['name']); then i get error Error processing uploaded file banner.jpg whether i remove the slash from front or slash from back of "upload" i get the same error. vineet
  21. hi all i m using the following gd script http://www.anyexample.com/programming/php/php_multiple_photo_thumbnail_generator.xml <?php // Don't forget to change next two variables // Or create web-server writable directory aeupload in // the directory with this php file $upload_dir = "e:/www/htdocs/upload"; // Directory for file storing // filesystem path $web_upload_dir = "/www/htdocs/upload"; //chmod('/test_images/', 0777); // Directory for file storing // web-server dir /* upload_dir is filesystem path, something like /var/www/htdocs/files/upload or c:/www/files/upload web upload dir, is the webserver path of the same directory. If your upload-directory accessible under www.your-domain.com/files/upload/, then web_upload_dir is /files/upload */ // testing upload dir // * * * * * // INSERT SOURCE CODE OF thumbnail_calcsize() AND thumbnail_generator() HERE // * * * * * function thumbnail_calcsize($w, $h, $square) { $k = $square / max($w, $h); return array($w*$k, $h*$k); } function thumbnail_generator($srcfile, &$params){ // getting source image size @list($w, $h) = getimagesize($srcfile); if ($w == false) return false; // checking params array if (!(is_array($params)&&is_array($params[0]))) return false; $src = ImageCreateFromJpeg($srcfile); list($s1_w, $s1_h) = thumbnail_calcsize($w, $h, $params[0]['size']); // Create first thumbnail // Remember, first thumbnail should be largest thumbnail $img_s1 = imagecreatetruecolor($s1_w, $s1_h); imagecopyresampled($img_s1, $src, 0, 0, 0, 0, $s1_w, $s1_h, $w, $h); imagedestroy($src); // Destroy source image // Other thumbnails are just downscaled copies of the first one for($i=1; $i<sizeof($params); $i++) { list($cur_w, $cur_h) = thumbnail_calcsize($w, $h, $params[$i]['size']); $img_cur = imagecreatetruecolor($cur_w, $cur_h); imagecopyresampled($img_cur, $img_s1, 0, 0, 0, 0, $cur_w, $cur_h, $s1_w, $s1_h); imagejpeg($img_cur, $params[$i]['file'], 90); imagedestroy($img_cur); } // Saving first thumbnail imagejpeg($img_s1, $params[0]['file'], 90); imagedestroy($img_s1); return true;} // Upload processing part: if (isset($_FILES['file']) && ($_FILES['file']['size'] > 0)) { $u_filename = basename($_FILES['file']['name']); move_uploaded_file($_FILES['file']['tmp_name'], "/upload/" . $_FILES['file']['name']); // Setting params array for thumbnail_generator $params = array(array('size' => 220, 'file' => $upload_dir.'/s1-'.$u_filename), array('size' => 140, 'file' => $upload_dir.'/s2-'.$u_filename), array('size' => 80, 'file' => $upload_dir.'/s3-'.$u_filename)); if (thumbnail_generator($upload_dir.'/'.$u_filename, $params) == false) die("Error processing uploaded file {$u_filename}"); // ok, redirecting // same host (HTTP_HOST), same script (PHP_SELF) // add ?file=filename parameter header("Location: http://{$_SERVER['HTTP_HOST']}{$PHP_SELF}?file={$u_filename}"); exit();} // Upload processing end ?> <html><head> <title>PHP multiple thumbnail generator</title> </head><body> <?php if (!isset($_GET['file'])) {// Following HTML code is outputed when user just loads this page?> <h1>Upload image:</h1> <form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data"> <script type="text/javascript"> /* This function is called when user selects file in file dialog */ function checkext(upload_field) { // this is just an example of checking // image file extension - jpg/jpeg var re_text = /\.jpeg|\.jpg/i; var filename = upload_field.value; /* Checking file type */ if (filename.search(re_text) == -1) { alert("Please select JPEG file"); upload_field.value = ''; } return true; } </script> Select jpeg photo: <input type="file" name="file" id="file" onChange="return checkext(this)"> <br><br><input type="submit" value="upload & generate thumbnails"> </form> <?php }else { // And this HTML code is shown when image was uploaded $file = $_GET['file'];?> <h1>Photo: <?php echo $file; ?> </h1> <div align="center"> <!-- Outputting thumbnails --> <img src="<?php echo $web_upload_dir.'/s1-'.$file; ?>"> <img src="<?php echo $web_upload_dir.'/s2-'.$file; ?>"> <img src="<?php echo $web_upload_dir.'/s3-'.$file; ?>"> <br><br> <!-- Outputting uploaded photo --> <img src="<?php echo $web_upload_dir.'/'.$file; ?>"> </div> <?php }?> <br><br><br> Example by <a href="http://www.anyexample.com/">AnyExample</a> </body> </html>?> everytime i get the following error Warning: move_uploaded_file(/upload/banner.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in E:\xampp\htdocs\gd_upload.php on line 59 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'E:\xampp\tmp\php13.tmp' to '/upload/banner.jpg' in E:\xampp\htdocs\gd_upload.php on line 59 Error processing uploaded file banner.jpg i have created "upload" folder in E:/Xampp/htdocs i have amended this in that script $upload_dir = "e:/www/htdocs/upload"; vineet
  22. hi Andy i saw the link you gave but they have no where explained how to separate the two numeric values that we get. what they are checking is about numeric and alpha numeric values. that i have already done. vineet
  23. hi all i have a string like "123 abc 45". i am using the below code to extract numeric from string. The result i get for numeric value is "12345". How can i get the result as "123" and "45" as separate two keywords. <?php $string = "123 abc 45"; $chars = ''; $nums = ''; for ($index=0;$index<strlen($string);$index++) { if(isNumber($string[$index])) $nums .= $string[$index]; else $chars .= $string[$index]; } echo "Chars: $chars<br>Nums: $nums"; function isNumber($c) { return preg_match('/[0-9]/', $c); } ?> vineet
  24. hi ignace i didnt know anything about array_shift(). thanks. now its fine. vineet
×
×
  • 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.