Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. Well you got that far. You need to make sure you have the correct spelling and the right information to connect to your database properly.
  2. yeah I see the issue change this: $search = $GET_['search']; to this: $search = $_GET['search'];
  3. do me a favor and post both the form and the current code remember to wrap them in code tags...lol
  4. I saw you had this http://www.gpcoin.monkeyserve.com/search.php?textfield=test&search=search so in your form you have the get value as textfield, but in your code you are looking for get values of search. so use the example of the form i gave in that code and try it What I'm saying is you never had any values for $_GET['search'] because your form never sends any
  5. ok back to basics, try this link and do a search, then will see the results would show same page and everything works as it should. The code displays after the search is submitted. http://get.blogdns.com/sample-search.php Here's the code for it anyway. <form action="" method="get"> Search: <input type="text" name="search" /> <input type="submit" value="Search"/> </form> <?php $search = mysql_real_escape_string($_GET['search']); if (!isset($search) OR $search == "") { echo "Enter a search word"; } else { echo "<h2>$search</h2>"; } echo "<br />"; ?> This line targets results same page as script <form action="" method="get"> otherwise you can do to target the different page <form action="search.php" method="get">
  6. ahh, i see now textfield=funny&search=search you have 2 gets, so rename textfield to search and just use that in your form try this <form action="search.php" method="get"> <font face='sans-serif' size=5> <center> Search Engine<br /> <input type="text" name="search" id="search" size="40"/> <input type="submit" /> <center> </font> </form>
  7. double check your database location and your login parameters to be sure they are correct
  8. All you really need to do is use the one and not the button. <?php $search = $GET_['search']; if (!isset($search)) { echo "Please enter a keyword!"; } else { if (strlen($search)<2){ echo "search term to short"; } else { echo "you searched for $search <hr size='1'>"; } mysql_connect("ftp.gpcoin.monkeyserve.com","seanhall_seanhall","*********"); mysql_select_db("seanhall_search"); $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { $x++; if ($x==1) { $construct .= "keywords LIKE '%$search_each%'"; } else { $construct .= " OR keywords LIKE '%$search_each%'"; } $construct = "SELECT * FROM searchengine WHERE $construct"; echo $construct; $run = mysql_query($construct); $found = mysql_num_rows($run); if ($found==0) { echo "No results Found."; } else { echo "$foundnum results found!<p>"; while ($runrows = mysql_fetch_assoc($run)) { $title = $runrows['title']; $desc = $runrows['description']; $url = $runrows['url']; echo " <b>$title</b><br> $desc<br> <a herf='$url'>$url</a><br> "; } } } } ?>
  9. Are you sure button has a value? try to echo button and see the result, maybe is not coming through to the form. Or can try if (!isset($button)) { Maybe even if ($button == "") {
  10. You had a lot of brackets missing and also semicolons, try this and double check your brackets as how to group your else. <?php $button = $GET_['submit']; $search = $GET_['search']; if (!$button) { echo "Please enter a keyword!"; } else { if (strlen($search)<2){ echo "search term to short"; } else { echo "you searched for $search <hr size='1'>"; } mysql_connect("ftp.gpcoin.monkeyserve.com","seanhall_seanhall","81834567"); mysql_select_db("seanhall_search"); $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { $x++; if ($x==1) { $construct .= "keywords LIKE '%$search_each%'"; } else { $construct .= " OR keywords LIKE '%$search_each%'"; } $construct = "SELECT * FROM searchengine WHERE $construct"; echo $construct; $run = mysql_query($construct); $found = mysql_num_rows($run); if ($found==0) { echo "No results Found."; } else { echo "$foundnum results found!<p>"; while ($runrows = mysql_fetch_assoc($run)) { $title = $runrows['title']; $desc = $runrows['description']; $url = $runrows['url']; echo " <b>$title</b><br> $desc<br> <a herf='$url'>$url</a><br> "; } } } ?>
  11. actually you forgot the ; in many of the echo's go through them all and add them where missing.
  12. change this: $search_exploded = explode(" ",$search) to this: $search_exploded = explode(" ",$search);
  13. Let me give you a few demo of codes I wrote up and can look at them a bit. A simple navigation http://get.blogdns.com/navigation/ This one creates single posts http://get.blogdns.com/dynaindex/post-variable.php Here's some pagination ones. http://get.blogdns.com/paginate/ http://get.blogdns.com/dynaindex/paginate.php A post in the forum parsing urls http://www.phpfreaks.com/forums/index.php?topic=319755.0 This is the function code to find path one http://www.phpfreaks.com/forums/index.php?topic=319755.msg1506929#msg1506929 If any more questions feel free to ask.
  14. That unique key of 4 you speak of could be a GET value, doing an if/else statement of the GET could determine what content is displayed on the same page by using includes or writing the different mysql queries inside the if/else statement.
  15. This can explain it better than I can. http://php.net/manual/en/function.simplexml-load-file.php
  16. <?php $xml = simplexml_load_file('http://www.britishinternettv.co.uk/vlc.xml'); $url=$xml->url[0]; echo "<a href='$url'>$url</a>"; ?> Made hyperlink
  17. Here is an example of one of my search queries using boolean mode which incorporates single or multiple values using spaces or the +,- for include,exclude $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); Some LIKE examples exact match in field1 SELECT * FROM table WHERE field1 = '$name' field1 contains the search word anywhere using LIKE and both '%%' SELECT * FROM table WHERE field1 LIKE '%$word%' field1 contains the value that begins with our word using LIKE and the last ' %' SELECT * FROM table WHERE field1 LIKE '$word%' field1 contains the value that ends with our word using LIKE and the first '% ' SELECT * FROM table WHERE field1 LIKE '%$word' word appears in both fields using AND SELECT * FROM table WHERE field1 LIKE '%$word%' AND field2 LIKE '%$word%' word appears in any of the two fields using OR SELECT * FROM table WHERE field1 LIKE '%$word%' OR field2 LIKE '%$word%' word is in field1 OR in field2 AND field3 using Parentheses SELECT * FROM table WHERE field1 LIKE '%$word%' OR (field2 LIKE '%$word%' AND field3 LIKE '%$word%') ORDER BY id DESC
  18. There is always issues when comes to different characters and encodings/languages, gotta work your way through them all as there is no best solution to this as of yet. As some pointers, save all data to database as utf-8 Adding this line before the insert should ensure it mysql_query("SET NAMES 'utf8'"); You need to find ways of detecting the encoding/language and then convert them as needed. http://php.net/manual/en/function.mb-detect-encoding.php Then convert it http://www.php.net/manual/en/function.mb-convert-encoding.php Is also another option to convert http://php.net/manual/en/book.iconv.php On display: header("Content-Type:text/html; charset=UTF-8"); <meta charset="utf-8"> If is any characters that you need different can replace the characters yourself with maybe a custom function.
  19. Some or should say many sites do as you describe, that's all up to the person who creates the site really. I could see one not wanted such a structure as it would then become a more complex longer link. More searching for exact file locations. More places to look when editing. example: http://mysite.com/About/President.html could have just been http://mysiyte,com/President.html But really here you are thinking of static websites where the folders names are the links. In a more dynamic site such as php,asp and so on the menu determines the link, is usage of a template system, and the content is generated onto a main or designated page usually. When the link is clicked it just loads data from a database or a script file. So when writing code for something it's a lot easier to just include a file than finding the actual locations for everything you do. Where these script files reside does not really matter, as long as the website creator knows the location to include them. You are free to do as you wish with your own creation, if you want to organize the folders and files more you can. Organization is good actually. Just keep in mind if it's a file that's to be reused a lot it would be better if were in the higher directory.
  20. I made a safe filter that the bad words are kept in a text file. Here's the demo and the download is also there. http://get.blogdns.com/dynaindex/Safe-Filter/ You will see it can block either words or entire posts with the dropdown selection. The x can also be whatever like it to be, such as OOPS, replacement of words or w/e you like
  21. Use the freelancing section http://www.phpfreaks.com/forums/index.php?board=8.0
  22. As per http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html In implementing this feature, MySQL uses what is sometimes referred to as implied Boolean logic, in which * + stands for AND * - stands for NOT * [no operator] implies OR
  23. Try to take a look here for some examples, and yeah use action="" instead of action="formname.php" if not targeting it to a new page. It's easier. http://www.w3schools.com/php/php_forms.asp
  24. You do have a very complex code there, must have taken you a while and also with problems along the way. I do think this entire process could be made simpler, that's for sure. LIKE searches are kinda slow, I believe doing full text indexing on your database would remedy a lot of your issues, as can see I only used LIKE for when checking the first characters and not the rest. Anyway here's another snippet of code for you to try out. $startrow ="0"; $posts_per_page ="20"; $search_query = "('"; for($i=0;$i < $word_count;$i++){ $search_query .= '+'.$search_words[$i].'* '; } $search_query .= "' IN BOOLEAN MODE)"; $sql="SELECT * FROM table WHERE MATCH (title,description) AGAINST" . $search_query . "ORDER BY id DESC LIMIT $startrow,$posts_per_page";
×
×
  • 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.