Search the Community
Showing results for tags 'please help'.
-
GOOD DAY phpfreaks.com Can Anyone Help about my code. My search engine can search and display if there is no user logged-in, but it goes wrong when it have user logged-in ? //The Error Shown Every time I have user Loginerror.txt Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in E:\pagong\ProgramFiles\wamp\www\mandaya\pages\modifier\search.php on line 103 //The Search Form search-form.txt <form action="search.php" method="get" id="form1" name="form1" > <input name="keysearch" type="text" value="<?php echo $_GET['keysearch']; ?>" size="30" height="30px" placeholder="Search Mandaya Topics" id="s_box" /> <input type="submit" value="SEARCH" class="s_in"/> </form> // my php search code searchcode.txt <?php $keysearch = $_GET['keysearch']; $keysearch = filter_var($_GET['keysearch'], FILTER_SANITIZE_STRING); $keysearch = htmlspecialchars($_GET['keysearch']); $terms = explode(" ", $keysearch); $query = "Select * from images Where "; foreach ($terms as $each){ $i++; if ($i==1) $query .= "search like '%$each%' "; else $query .= "Or search like '%$each%' "; } //connect mysql_connect("localhost", "root"); mysql_select_db("mandaya"); //Done if Search is filled if(!empty($keysearch)){ $query = mysql_query($query); //Execute the query $query $numrows = mysql_num_rows($query); //Count the result of query //Get the DB fields from query if ($numrows > 0 ){ //Set each other while ($row = mysql_fetch_assoc($query)){ $id_topic = $row ['id_img']; $title = $row ['title']; $description = $row ['description']; $a = $row ['desc_a']; $b = $row ['desc_b']; $c = $row ['desc_c']; $d = $row ['desc_d']; $e = $row ['desc_e']; $link1 = $row ['link1']; $link2 = $row ['link2']; $key = $row ['keywords']; echo "<ul class='image_list'> <li><form method='POST' action='index.php'> <input type='hidden' name='topic' value='$id_topic'/> <input type='hidden' name='title' value='$title'/> <input type='image' name='img' value='$link1' src='$link1' size='100px' height='100px' title='$title'/> <input type='hidden' name='desc' value='$description'/> <input type='hidden' name='desc_a' value='$a'/> <input type='hidden' name='desc_b' value='$b'/> <input type='hidden' name='desc_c' value='$c'/> <input type='hidden' name='desc_d' value='$d'/> <input type='hidden' name='desc_e' value='$e'/> <input type='hidden' name='key' value='$key'/> <input type='hidden' name='image1' value='$link1'/> <input type='hidden' name='image' value='$link2'/> </form></li> </ul>"; } } else echo " <center>No results found for \"<b>$keysearch</b>\""; } //disconnect mysql_close(); ?>
-
$from = "test@localhost.com"; $to = "test@localhost.com"; $subject =$_POST['subject']; $message = $_POST['body']; // include the from email in the headers $headers = "From: $from"; // boundary $time = md5(time()); $boundary = "==Multipart_Boundary_x{$time}x"; // headers used for send attachment with email $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$boundary}\""; // multipart boundary $message = "--{$boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // Fily Type Validation $allowedExtensions = array("jpeg","jpg"); // attach the attachments to the message $files = $_FILES['imgupload']; for($i=0; $i < count($files['name']); $i++) { if ($files['name'][$i] != '') { $file_name = $files['name'][$i]; $file_path = pathinfo($file_name); $file_ext = $file_path['extension']; if (in_array($file_ext, $allowedExtensions)) { $tmp_name = $files['tmp_name'][$i]; $content = chunk_split(base64_encode(file_get_contents($tmp_name))); $message .= "--{$boundary}\n" . "Content-Type: {\"application/octet-stream\"};\n" . " name=\"{$file_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$file_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $content . "\n\n"; } else { $errormgs= 'alert("File Type is not accepted, please use an image.")'; $formerrors = 'true'; } } // else { $errormgs= 'alert("You Forgot to Attach the Photo")'; $formerrors = 'true'; } } // sending mail if (!$formerrors) { $sendmail = mail($to, $subject, $message, $headers); } else { print '<script type="text/javascript">'; print $errormgs; print '</script>'; } ----------------------------------------------------------------------- Hello Everybody, I hope somebody can help me with the script that I have written. It allows me to create as many input field in my form and deliver the attachment to the dedicated email without changing the PHP code for every additional attachment input field. The only problem I have is an alert for the attachment fields. If there is no file selected I want the popup with the message demanding the image to be added. For some reason it doesn't work. If I add the else statement with the message the form keeps giving me that alert no matter if I add the Image or don't. What am I doing wrong? Thank you all for help and sorry if I am expressing myself baddly.