john010117 Posted December 12, 2006 Share Posted December 12, 2006 Hi.First of all, don't get me wrong by reading the title. I'm [b][u]not[/u][/b] trying to make a dictionary with alll the words in it. I just wanted to make a SEARCHABLE dictionary with some terms coming from a game. I know that MySQL is involved, and I know that i'll take me a while. Can somebody start me off? Thanks.PS: If this is in the wrong forum, please move it. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/ Share on other sites More sharing options...
wattsup88 Posted December 12, 2006 Share Posted December 12, 2006 There is a bunch of basic knowledge that you must gain before you can just start this project... First you need to make the database that you want to pull information from... Then you have to tell your server in php of course what information to pull by making "queries"... I dont know how much you know so im starting at the beginning... There are a bunch of great tutorials out there on this matter... a few on phpfreaks.com of course but the most basic ones I've found are on this site: http://preview.arutha.co.uk/tutorials/PHP/All/1/1/... As i said earlier the first thing is making a database so do that first... I hope that gave you a direction to head in... Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-139468 Share on other sites More sharing options...
john010117 Posted December 12, 2006 Author Share Posted December 12, 2006 I've created a database a long time ago. :D I'm not very familiar with PHP, nor MySQL. I'm on a free web hosting account that [i]has[/i] PHPMyAdmin enabled, but the [i]coding function is disabled[/i]. The website you've gave me doesn't work for me, because it requires you to code things into the db, which I'm unable to do. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-139469 Share on other sites More sharing options...
trq Posted December 12, 2006 Share Posted December 12, 2006 [quote]The website you've gave me doesn't work for me, because it requires you to code things into the db, which I'm unable to do[/quote]What are you talking about? Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-139498 Share on other sites More sharing options...
wattsup88 Posted December 12, 2006 Share Posted December 12, 2006 you dont code things into the db you code them in your html page that you display using php... Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-139716 Share on other sites More sharing options...
john010117 Posted December 12, 2006 Author Share Posted December 12, 2006 [quote author=thorpe link=topic=118259.msg483156#msg483156 date=1165903349][quote]The website you've gave me doesn't work for me, because it requires you to code things into the db, which I'm unable to do[/quote]What are you talking about?[/quote]I meant that the codes on that website require you to put those codes into PHPMyAdmin (right?), which I'm unable to do. And [b]wattsup88[/b], which tuturiol do you want me to look at? There are 3 pages of tutorials... Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-139986 Share on other sites More sharing options...
Psycho Posted December 12, 2006 Share Posted December 12, 2006 No you do NOT put those "codes" into PHPMyAdmin. PHPMyAdmin is just a front-end tool for administrating your database. You would write database queries into your PHP page to pull the appropriate data from the database to display on your page. If you cannot do THAT then there is no point in your host providing a database! Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-139988 Share on other sites More sharing options...
john010117 Posted December 12, 2006 Author Share Posted December 12, 2006 [quote author=mjdamato link=topic=118259.msg483652#msg483652 date=1165965825]No you do NOT put those "codes" into PHPMyAdmin. PHPMyAdmin is just a front-end tool for administrating your database. You would write database queries into your PHP page to pull the appropriate data from the database to display on your page. If you cannot do THAT then there is no point in your host providing a database![/quote]Ok, I can do that. Now I need a code that can start me in the right direction... :D Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-139991 Share on other sites More sharing options...
fert Posted December 12, 2006 Share Posted December 12, 2006 [code]$result=@mysql_query("SELECT * FROM `words` WHERE `word`='$word'",$cn) or die(mysql_error());[/code]That query will do exactly what you want. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-139996 Share on other sites More sharing options...
john010117 Posted December 12, 2006 Author Share Posted December 12, 2006 It only showed an error...[quote][b]SQL Query:[/b]$result = @mysql_query ("SELECT * FROM `phpbb` WHERE `word`='$word'", $cn) OR die(mysql_error()) [b]MySQL said:[/b]#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$result=@mysql_query("SELECT * FROM `words` WHERE `word`='$word'[/quote]Is there something I have to change in that code? (Yes, I know. I know NOTHING about MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140007 Share on other sites More sharing options...
fert Posted December 13, 2006 Share Posted December 13, 2006 you need to have a column named word in the table Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140017 Share on other sites More sharing options...
rempires Posted December 13, 2006 Share Posted December 13, 2006 you might want to look into reading a book on this area, a really good one is "PHP & MySQL For Dummies, 2nd Edition (2004)" it will get you started in the right direction, it did for me. This book and similar eons will start you off from nothing and teach you the basics you'll need. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140064 Share on other sites More sharing options...
wattsup88 Posted December 13, 2006 Share Posted December 13, 2006 yeah i agree books help conect areas that tutorials cannot... However, the tutorial that i was speaking of was on making queries the address is...http://preview.arutha.co.uk/viewtut/18/ Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140141 Share on other sites More sharing options...
john010117 Posted December 13, 2006 Author Share Posted December 13, 2006 [color=red]Edit:[/color] I've just gotten this code from the website. I've sucessfully installed it, and no error messages appear. But something seems to be wrong. Let me show you the code first.This goes into the db.[code]CREATE TABLE `search` (`id` int(5) NOT NULL auto_increment,`name` varchar(50) NOT NULL default '',`description` varchar(255) NOT NULL default '',PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=6 ;-- -- Dumping data for table `search`-- INSERT INTO `search` VALUES (1, 'Arutha', 'Arutha is a talented coder and designer who runs http://arutha.co.uk');INSERT INTO `search` VALUES (2, 'Psycho_Phrog', 'A freind off arutha writes the occasional ps tutorial');INSERT INTO `search` VALUES (3, 'Djc123', 'another freind of arutha, he''s currently doing the photography side of photoshop with promising results');INSERT INTO `search` VALUES (4, 'Stu', 'Moderator at p2l, provides critisim and advice on arutha.co.uk to arutha');INSERT INTO `search` VALUES (5, 'you', 'are reading this tutorial and hopefully finding it usefull');[/code]I'll show you the other part of the code later (but I seriously think the above code has something wrong in it).So, when I search the word "Arutha", it has to give me results, right? But it doesn't. What seems to be the problem with this? Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140214 Share on other sites More sharing options...
john010117 Posted December 14, 2006 Author Share Posted December 14, 2006 Wow... buried under 3+ pages... Can [i]anybody[/i] help me? Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140767 Share on other sites More sharing options...
JasonLewis Posted December 14, 2006 Share Posted December 14, 2006 i dont think its anything wrong with your database. it would be something wrong with how you are getting the results when people search. you should post that part of the code. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140775 Share on other sites More sharing options...
john010117 Posted December 14, 2006 Author Share Posted December 14, 2006 Ok then.[code]<?php // Search Tutorial Code // Arutha.co.uk // Standard Connection Data. $db_host = "****.awardspace.com"; $db_user = "****_db1"; $db_pass = "********"; $db_name = "****_db1"; $dbac = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); if (!$_POST['search']){ // Breaking out of php to display the form. ?> <form name="Search Tutorial" method="post" action=""> Search Words:<br> <label> <input name="swords" type="text" size="30" maxlength="30"> </label> <br> <label> <input name="search" type="submit" id="search" value="Search"> </label> </form> <?php }else{ // Adding slashes and changing tags so that people trying to take advantage of the system can't $searchwords = addslashes(htmlspecialchars($_POST['swords'])); // Checking the length of string to make sure its more than 3 characters long if (strlen($searchwords) < 3){ echo "The word you have inputted is too short, please enter another one."; }else{ $words = explode(' ',$searchwords); $totalwords = count($words); $i = 0; $searchstring = ""; // Now we are looping to get the search string, however we could use a for loop. // But i think while loops are much easier to teach with/edit while ($i != $totalwords){ if ($i != 0 and $i != $wordcount){ $searchstring .= " and ";; } $searchstring .= "description LIKE '%$words[$i]%' or name LIKE '%$words[$i]%'"; // Incrementing the value $i = $i + 1; } // Now we are gong to execute the query with the search string we have just created. $query = mysql_query("SELECT DISTINCT * FROM Search where $searchstring"); // Want to check that we got something if (mysql_unbuffered_query($query) == 0){ echo "No results where found sorry :("; }else{ while ($fet = mysql_fetch_array($query)){ echo "<p>Name: {$fet['name']}<br /> Description: {$fet['description']}</p>"; }// End While }// End Else }// End Else }// End Else ?> [/code][color=red]Note:[/color] I've double checked to see that the MySQL entries are correct (I put those stars to prevent anyone from seeing sensitive information).Can you please figure out what's wrong? I always get the same result: "No results were found sorry :(". Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140821 Share on other sites More sharing options...
wattsup88 Posted December 14, 2006 Share Posted December 14, 2006 I would love to try and help you but you need to display the current code you are having problems with... and what your trying to do with it... I'm sorry arutha wasn't of much help... it did help me tho so i thought id pass that along... The code arutha puts out tho is not incorrect... at least i cant find anything wrong with it... Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140828 Share on other sites More sharing options...
john010117 Posted December 14, 2006 Author Share Posted December 14, 2006 Ok, then. I'll first learn a bit more about PHP and MySQL, then try again. (dang, the MySQL database is down... something about "having too much connections"... there's no way I can test this right now...) Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-140840 Share on other sites More sharing options...
JasonLewis Posted December 14, 2006 Share Posted December 14, 2006 i just cleaned up your code and removed the while loop to replace it with a for loop.[code=php:0]<?php // Search Tutorial Code // Arutha.co.uk // Standard Connection Data. $db_host = "****.awardspace.com"; $db_user = "****_db1"; $db_pass = "********"; $db_name = "****_db1"; $dbac = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); if (!$_POST['search']){ // Breaking out of php to display the form. ?> <form name="Search Tutorial" method="post" action=""> Search Words:<br> <label> <input name="swords" type="text" size="30" maxlength="30"> </label> <br> <label> <input name="search" type="submit" id="search" value="Search"> </label> </form> <?php }else{ // Adding slashes and changing tags so that people trying to take advantage of the system can't $searchwords = addslashes(htmlspecialchars($_POST['swords'])); // Checking the length of string to make sure its more than 3 characters long if (strlen($searchwords) < 3){ echo "The word you have inputted is too short, please enter another one."; }else{ $words = explode(" ",$searchwords); $searchstring = ""; // Now we are looping to get the search string, however we could use a for loop. // But i think while loops are much easier to teach with/edit for($i = 0; $i <= count($totalwords); $i++)if ($i != 0 and $i != $wordcount){ $searchstring .= " and ";; } $searchstring .= "description LIKE '%{$words[$i]}%' or name LIKE '%{$words[$i]}%'"; } // Now we are gong to execute the query with the search string we have just created. $query = mysql_query("SELECT DISTINCT * FROM Search where $searchstring"); // Want to check that we got something if (mysql_num_rows($query) == 0){ echo "No results where found sorry :("; }else{ while ($fet = mysql_fetch_array($query)){ echo "<p>Name: {$fet['name']}<br /> Description: {$fet['description']}</p>"; }// End While }// End Else }// End Else }// End Else ?> [/code]i also changed the mysql_unbuffered_query($query) == 0 to mysql_num_rows($query) == 0. This counts all the found rows, if its 0 then it will display no search results, else display them..that might've been the problem anyway. good luck... Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-141084 Share on other sites More sharing options...
wattsup88 Posted December 14, 2006 Share Posted December 14, 2006 Give your code so I (and other people) can try and help you out... If you don't post code its hard to help ya... Also, I am pretty sure the arutha code is right... but again im no expert... Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-141187 Share on other sites More sharing options...
john010117 Posted December 15, 2006 Author Share Posted December 15, 2006 [b]ProjectFear[/b], I've used your code, but when I load the page, it says the following message:[quote][b]Parse error[/b]: parse error, unexpected '}' in [b]/****/****/****.awardspace.com/test5.php[/b] on line [b]56[/b][/quote]Ok, so then I removed the "}"s in front of the "//End While" and "// End Else" tags. Now, it says this:[quote][b]Parse error[/b]: parse error, unexpected $ in [b]/****/****/****.awardspace.com/test5.php[/b] on line [b]58[/b][/quote]The problem is... there is no "$" tag in line 58 (or anywhere near that). Please help.PS: [b]wattsup88[/b], if you look on top of this page, and the near bottom of the previous page, you'll see that I've posted both of the codes. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-141491 Share on other sites More sharing options...
gtitsworth Posted December 15, 2006 Share Posted December 15, 2006 Just doing a quick scan of ProjectFear's code and not actually looking at the logic, there just has one extra "}// End Else " at the end. Try taking that out. but not the "}" in front of the end while comment.G. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-141548 Share on other sites More sharing options...
john010117 Posted December 15, 2006 Author Share Posted December 15, 2006 Ok, I've gotten rid of [i]that[/i] error. Now, it's saying something like this:[quote][b]Warning[/b]: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /****/****/****.awardspace.com/test5.php on line [b]47[/b]No results where found sorry :([/quote][color=red]Note[/color] That last line is supposed to be there when no results are found.I've searched the [url=http://us3.php.net/manual/en/function.mysql-num-rows.php]MySQL manual for that code[/url], but it said that it should be used this way... anyone care to help please? ??? Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-141573 Share on other sites More sharing options...
Woad.php Posted December 15, 2006 Share Posted December 15, 2006 I've accidentally posted. Could an admin please delete my post? Sorry. Quote Link to comment https://forums.phpfreaks.com/topic/30306-making-an-online-dictionary/#findComment-141575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.