Jump to content

contra10

Members
  • Posts

    402
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

contra10's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Hi, I'm trying to improve my search so that it searches all words that i write in the search box and matches keywords my code right now is <?php $sub = $_GET['article']; echo "<h2>search results for: $sub</h2><br><br>"; $sub = str_replace(" ", "%", $sub); $alb = mysql_connect("localhost", "", "") or die(mysql_error()); mysql_select_db("articles") or die(mysql_error()); mysql_set_charset('utf8', $alb); $query2 = "SELECT * FROM `blog` WHERE `title` like '%$sub%'"; $result2 = mysql_query($query2) or die(mysql_error()); while ($postede2 = mysql_fetch_assoc($result2)) { $title = "{$postede2['title']}"; $author = "{$postede2['author']}"; $section = "{$postede2['section']}"; $description = "{$postede2['description']}"; $url = "{$postede2['url']}"; echo "<a href='$url'><h3><b>$title</b></h3></a><br>"; echo "By $author, Category: $section<br>"; echo "$description ...<br><br>"; } ?> How do i break down the search even further?
  2. i'm having trouble working with my search bar, when i used wamp it worked but now online i keep getting this message I placed that code for the search bar above the html tags but i keep getting the error here is my coding <?php mysql_connect("localhost", "user", "pass") or die(mysql_error()); if (isset($_POST['submit'])) { $search = mysql_real_escape_string($_POST['search']); $type = mysql_real_escape_string($_POST['type']); if ($type == true) { header("Location:http://www.link.com/searchresults.php?subdirectory=$search&type=$type"); } } ?>
  3. I don't really understand preg_match when using it, although i understand the concept i did this as a trial <?php $html = file_get_contents('http://www.google.com/'); preg_match('google', "$html", $matches); preg_match_all("<a href", $html, $match); foreach($match[1] as $val); { echo $val."<br>"; } ?> i don't really get how to get the actual a href links from all the links on the page
  4. sorry, I guess my question is: How do I create a spider that searches a website extracts links, and certain keywords, then organizes it so that it will be saved in a database?
  5. Hello, this is more of a question since I don't know where to begin. I want to use a spider to search a website and gather information and then organize it into a table the specific information from the site that I need. For example lets say I wanted to search a sports website and only get the details of the teams and their scores and then place it into my database without getting other information of that website?
  6. i did that before the data gets placed in the database, the same has to work for when im displaying it?
  7. hello, i keep getting a syntax error message when I try to display my data from my database, heres the code that i use fo veiwing the data <?php $alb = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("programs") or die(mysql_error()); mysql_set_charset('utf8', $alb); $query = "SELECT * FROM `canpro` WHERE `directory` = '$sub' ORDER BY area, school ASC"; $result = mysql_query($query) or die(mysql_error()); while ($postede = mysql_fetch_assoc($result)) { $area = "{$postede['area']}"; $dn = "{$postede['dn']}"; $dl = "{$postede['dl']}"; echo "<font size='3'><b>$school</b></font><br>"; echo "<font size='2'><b>$dn</b></font><br><font size='2' color = '#3B5998'><b>$dl</b></font><br>"; mysql_select_db("schools") or die(mysql_error()); $query2 = "SELECT * FROM `canschools` WHERE `name` = '$area'"; $result2 = mysql_query($query2) or die(mysql_error()); while ($postede2 = mysql_fetch_assoc($result2)) { $city = "{$postede2['city']}"; $area2 = "{$postede2['area']}"; echo "<font size='2'><b>$city, $area2</b></font><br><br>"; } } ?> The display message i get is it shows all my information except when the word contains an apostrohpe then it doesn't shows the error and all the information afterwords won't get displayed
  8. sry by better I meant allows more flexibility with the search I used implode seems to be working well but for example because my site is a music site when someone searches for black eyed peas I gotta feeling the song comes up in search results as black eyed peas - i gotta feeling which is what is in the db as the title but when someone searches i gotta feeling black eyed peas no results comes up
  9. hey I'm trying to create a better search bar because I find LIKE to be very simple <?php $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query("SELECT * FROM `musiclinks` WHERE `title` LIKE '%$sr%' $max") or die(mysql_error()); if ($data_p){ //This is where you display your query results while ($postede = mysql_fetch_assoc($data_p)) { $name = "{$postede['title']}"; $genre = "{$postede['genre']}"; $filename = "{$postede['filename']}"; $embed = "{$postede['embed']}"; $false = 'False'; $true = 'True'; } ?> how can I make the search a lot better I know I have to work on variable $sr, should i break it down into strings. how should i go about doing that?
  10. is there something wron with the max variable
  11. ok I'm using my pagination script and everything seems to be echoing on the first page and every other page <?php //This checks to see if there is a page number. If not, it will set it to page 1 $pagenum = $_GET['pagenum']; $linkgenre = $_GET['l']; if ($pagenum) { } else{ $pagenum = 1; } //Here we count the number of results $querye = "SELECT DISTINCT * FROM `musiclinks` WHERE `genre` ='$linkgenre' AND `embed` = 'True'"; $result = mysql_query($querye); $rows= mysql_num_rows($result); //This is the number of results displayed per page $page_rows = 5; $es = ($rows/$page_rows); //This tells us the page number of our last page $last = ceil($es); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it $data_p = mysql_query("SELECT * FROM `musiclinks` WHERE `genre` = '$linkgenre' AND `embed` = 'True' $max"); if ($data_p){ //This is where you display your query results while ($postede = mysql_fetch_assoc($result)) { $name = "{$postede['title']}"; $genre = "{$postede['genre']}"; $filename = "{$postede['filename']}"; echo "<tr><td width='%50'><a href='http://www.site.com/music/plisten.php?f=$filename'>$name</a></td><td width='%50'>$genre</td>"; $queryear = "SELECT * FROM `ratings` WHERE `songtitle` = '$name'"; $resultear = mysql_query($queryear) or die(mysql_error()); while ($postedear = mysql_fetch_assoc($resultear)) { $avsong = "{$postedear['songtitle']}"; $linksong = "{$postedear['song']}"; $ratedavg = "{$postedear['average']}"; if ($ratedavg > 1){ echo"<td>$ratedavg / 10</td></tr>"; }else{ echo "<td>No Rating</td></tr>"; } } } // This shows the user what page they are on, and the total number of pages echo " Page $pagenum of $last ($rows Results)<p>";?> I don't understand why its not working and the max variable changes when i click on a different page
  12. i did this and it worked <?php echo "<div class='date'>"; echo '<a href="http://www.site.com/music/plisting.php?l=', rawurlencode('R&B'), '">'; echo "View All ($rnbcountp)</a></div>"; ?>
  13. hey, I'm trying to pass a variable in my url and i think im suppose to use slashes for this one because the variable that I'm passing contains an & in it. In this case the variable l=R&B but when the page recieves the link it interprets l as just R because the & sign follows after making it seem as if there is another variable that is supposed to be passed along. <?php echo "<div class='date'><a href='http://www.site.com/music/plisting.php?l=R&B'>View All ($rnbcountp)</a></div>"; ?>
  14. i jus dun get why it shows as a file download in a gmail email
  15. I'm having trouble with emails and php when it sends to a hotmail account everything shows but in gmail or yahoo accout it shows a download link for a no name file, the actual writing doesn't show <?php $to = ($email); $subject = "Verification"; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); $from = "admin@url.com"; $headers = "From: $from"; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <div style="width:800px; height:400px; border:4px dashed grey; "> <table bgcolor="black" width="800" > <tr><td> <img src="http://www.url.com/images/logo.png"/><br><br><font size="12" color="white">You have sucessfully become a member</font><br> <?php echo"<p align='center'>"; echo"<table background='#6D6D6D' width='700' height='250'>"; echo "<tr><td><b><font color='white'>Dear, $usere <br><br> To complete your activation please click on the \"Verify\" link below."; echo "<b>To contine to verify your account please follow the link </b><a href='http://www.url.com/verify.php?v=$usere' target='_blank'><font color='red'>Verify Account</font></a>"; echo"</font></td></tr>"; echo "</table>"; echo"</p>"; ?> </td></tr> <tr><td align="center"><font size="1" color="white">Copyright 2009</font></td></tr> </table> </div> --PHP-alt-<?php echo $random_hash; ?>-- <?php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( "$to", $subject, $message, $headers ); ?>
×
×
  • 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.