Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default Tutorial: Search Engine

    Since i don't use my i guess someone else can get something out of it.

    Mysql:
    Code:
    CREATE TABLE search(  
    id INT NOT NULL AUTO_INCREMENT,  
    PRIMARY KEY(id),  
    name VARCHAR(30) NOT NULL,
     url VARCHAR(30) NOT NULL, 
    about TEXT NOT NULL)';
    Run that in phpmyadmin

    Index.php
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
    <html>  
    <head>  
    <title></title>  
    <link type="text/css" rel="stylesheet" href="/css.css">  
    </head>  
    <body>  
    <div align="center">  
    <img style="margin: 0px;" width="690" height="150" src="banner url here" alt="" title="">  
    <br></div>  
    <center>  
    <form action="search.php" method="get"><font size="1" face="Verdana"><strong>Search:</strong></font> 
    <input type="text" size="20" name="search">  
    <input type="submit" value="Search!"></form>  
    <table style="border: 1px solid rgb(0, 0, 0);" width="50%"></table><font size="1" face="Verdana"><span class="nav">| <a title="" href="/add.php">Add Your Site</a> | </span></font> 
    <br></center>  
    </body>  
    </html>
    Basicly Just the search form

    ADD.PHP
    PHP Code:
    <center><?php  // set your infomation.  
    $dbhost='localhost'// host  
    $dbusername='colin_shout'// database username  
    $dbuserpass='cococo'// database password  
    $dbname 'colin_search'//database  

    // connect to the mysql database server.  
    mysql_connect ($dbhost$dbusername$dbuserpass);  
    //select the database  
    mysql_select_db($dbname) or die('Cannot select database');  
    //submits the form 
    if ($_POST['name']) {  
    $name $_POST['name'];  
    if (
    $_POST['about']) {  
    $about $_POST['about'];  
    if (
    $_POST['url']) {  
    $url $_POST['url'];  
    // inserts the results into mysql  $query = "INSERT INTO search (name,about,url) VALUES ('".$name."','".$about."','".$url."')";  mysql_query($query)or die(mysql_error());  
    echo $name." was inserted successfully";  
    }else{  
    echo 
    "About/Url was left blank";  
    //echos if they missed a feild 
    }  
    }  
    }  
    ?>  
    <html>  
    <head>  
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">  
    <title></title>  
    <link type="text/css" rel="stylesheet" href="/css.css">  
    </head>  
    <body>  
    <img style="margin: 0px;" width="690" height="150" src="banner url" alt="" title="">  
    <br></div>  
    <form action='add.php' method='POST'>  
    <font size="1" face="Verdana">Name:</font><input type='text' name='name' size='33' /></br>  
    <font size="1" face="Verdana">Url:</font><input type='text' name='url' size='33' /></br>  
    <font size="1" face="Verdana">About:</font><textarea name='about' cols='25' rows='5'/></textarea></br> 
    <input type='submit' value='Add!' />  
    </form>  
    <span class="nav"><font size="1" face="Verdana"><span class="nav">| <a href="/add.php" title="">Add Your Site</a> | <a href="/index.php">Search</a> | </span></font> 
    </center>  
    </body>  
    </html>
    make sure to put your details to mysql in.

    Search.php
    PHP Code:
    <?php  $dbhost='localhost';  //host  $dbusername='colin_shout'; //database username  $dbuserpass='cococo';  //database pass$dbname = 'colin_search';  //database search  mysql_connect ($dbhost, $dbusername, $dbuserpass);  mysql_select_db($dbname) or die('Cannot select database');   // connects to database  
    $rowsPerPage 5;  //amount of search results per page 
    $pageNum 1;  

    if(isset(
    $_GET['page']))  
    {  
    $pageNum $_GET['page'];  
    }  
    if(isset(
    $_GET['search']))  
    {  
    $search $_GET['search'];  
    }  

    // counting the offset  
    $offset = ($pageNum 1) * $rowsPerPage;  //offsets page number 

    $keywords explode(" "$search);  //graps searched word 

    $query "SELECT id,name,about,url FROM search " .  
    "WHERE about LIKE '%".$keywords['0']."%'";  // searches for searched word in database 

    for ($i=1$i<count($keywords); $i++) {  
    $query $query." AND about LIKE '%".$keywords[$i]."%'";  //counts the results 
    }  
    $query $query." ORDER BY id LIMIT $offset$rowsPerPage";  //orders by rank 

    $result2 mysql_query($query) or die(mysql_error());  // kills mysql if query didnt work 
    ?>  
    <html>  
    <head>  
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">  
    <title></title>  
    <link type="text/css" rel="stylesheet" href="/css.css">  
    </head>  
    <body>  
    <center>  
    <img style="margin: 0px;" width="690" height="150" title="" alt="" src="banner url">  
    </br>  
    <form method="GET" action="search.php">  
    <b>Search:</b> <input type="text" name="search" size="20" />  
    <input type="submit" value="Search!" />  
    </form>  
    <table width="50%" style="border:1px solid #000000;">  
    </body>  
    </html>  
    <?php  
    $keywords 
    explode(" "$search);  

    $query "SELECT COUNT(id) AS numrows FROM search " .  //displays id number 
    "WHERE about LIKE '%".$keywords['0']."%'";  

    for (
    $i=1$i<count($keywords); $i++) {  
    $query $query." AND about LIKE '%".$keywords[$i]."%'";   
    }  

    $result mysql_query($query) or die('Error, query failed');  //displays error that query failed 
    $row mysql_fetch_array($resultMYSQL_ASSOC);  
    $numrows $row['numrows'];  

    $maxPage ceil($numrows/$rowsPerPage);  //sets number of pages 

    $self $_SERVER['PHP_SELF'];  
    $nav '';  

    for(
    $page 1$page <= $maxPage$page++) // shows list of pages  
    {  
    if (
    $page == $pageNum)  
    {  
    $nav .= $page ";  
    }  
    else  
    {  
    $nav .= " <a href="$self?page=$page&search=$search">$page</a> "// sets target for pages 
    }  
    }  

    if (
    $pageNum 1)  
    {  
    $page $pageNum 1;  
    $prev " <a href="$self?page=$page&search=$search">[Prev]</a> "// displays option of prev page  

    $first " <a href="$self?page=1&search=$search">[First Page]</a> ";  //displays option of first page 
    }  
    else  
    {  
    $prev ' ';  
    $first ' ';  
    }  

    if (
    $pageNum $maxPage)  
    {  
    $page $pageNum 1;  
    $next " <a href="$self?page=$page&search=$search">[Next]</a> ";  //displays option of next page 

    $last " <a href="$self?page=$maxPage&search=$search">[Last Page]</a> ";  //displays option of last page 
    }  
    else  
    {  
    $next ' ';  
    $last ' ';  
    }  

    while(
    $row mysql_fetch_array($result2))  
    {  
    echo 
    "<tr>";  
    echo 
    "<td style='border-bottom: 1px solid #000000;'>";  //echos tables 
    echo "<b><a href="".$row['url']."">".$row['name']."</a></b>";  // echos the results name 
    echo "<p>".$row['about']."</p>";  // echos about the result 
    echo "<p><a href="".$row['url']."">".$row['url']."</a></p>";  //echos about the url 
    echo "</td>";  
    echo 
    "</tr>";  
    }  

    echo 
    "<tr>";  
    echo 
    "<td>";  
    echo 
    "<center>".$first $prev $nav $next $last."</center>";  //displays the next/prev/last links made above 
    echo "</td>";  
    echo 
    "</tr>";  
    ?>  
    </td>  
    </tr>  
    </table>  
    </br>  
    <span class="nav"><font size="1" face="Verdana"><span class="nav">| <a href="/add.php" title="">Add Your Site</a> | </span></font> 
    </center>
    agian make sure to add your details

    Css.css
    Code:
    body    {  
        margin: 24px 0px 24px 0px ;  
        padding: 0px;  
         
    }  
    
    .border {  
        border: 1px solid #BBBBBB;  
    }  
    
    .border-a {  
        border: 1px solid #BBBBBB;  
        background-color: #EEEEEE;  
    }  
    
    /* Text */  
    
    .main    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 11px;  
        color: #333333;  
        line-height: 16px;  
    }  
    .main a:link    {  
        text-decoration: underline;  
        color: #0000FF;  
    }  
    .main a:visited     {  
        text-decoration: underline;  
        color: #0000FF;  
    }  
    .main a:hover     {  
        text-decoration: none;  
        color: #0000FF;  
    }  
    .main a:visited     {  
        text-decoration: none;  
        color: #0000FF;  
    }  
    .lighter    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 11px;  
        color: #666666;  
        line-height: 16px;  
    }  
    .lighter a:link    {  
        text-decoration: underline;  
        color: #0000FF;  
    }  
    .lighter a:visited     {  
        text-decoration: underline;  
        color: #0000FF;  
    }  
    .lighter a:hover     {  
        text-decoration: none;  
        color: #0000FF;  
    }  
    
    .darker    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 11px;  
        color: #222222;  
        line-height: 16px;  
        border: none;  
    }  
    .darker a:link    {  
        text-decoration: underline;  
        color: #0000FF;  
    }  
    .darker a:visited     {  
        text-decoration: underline;  
        color: #0000FF;  
    }  
    .darker a:hover     {  
        text-decoration: none;  
        color: #0000FF;  
    }  
    
    .large    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 18px;  
        color: #333333;  
        font-weight:bold;  
        line-height: 22px;  
    }  
    
    .largewhite    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 18px;  
        color: #FFFFFF;  
        font-weight:bold;  
        line-height: 22px;  
    }  
    
    .medium    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 11px;  
        color: #333333;  
        font-weight:bold;  
        line-height: 22px;  
    }  
    
    .mediumwhite    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 11px;  
        color: #FFFFFF;  
        font-weight:bold;  
        line-height: 22px;  
    }  
    
    .small    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 10px;  
        color: #333333;  
    }  
    .small a:link    {  
        text-decoration: none;  
        color: #0000FF;  
    }  
    .small a:visited     {  
        text-decoration: none;  
        color: #0000FF;  
    }  
    .small a:hover     {  
        text-decoration: underline;  
        color: #0000FF;  
    }  
    
    .nav    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 10px;  
        color: #CCCCCC;  
    }  
    .nav a:link    {  
        text-decoration: none;  
        color: #666666;  
    }  
    .nav a:visited     {  
        text-decoration: none;  
        color: #666666;  
    }  
    .nav a:hover     {  
        text-decoration: none;  
        color: #333333;  
    }  
    
    .field    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 10px;  
        color: #333333;  
    }  
    
    .white    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 10px;  
        color: #FFFFFF;  
    }  
    .white a:link    {  
        text-decoration: none;  
        color: #FFFFFF;  
    }  
    .white a:visited     {  
        text-decoration: none;  
        color: #FFFFFF;  
    }  
    .white a:hover     {  
        text-decoration: none;  
        color: #999999;  
    }  
    
    .italic    {  
        font-family: Verdana, Arial, Helvetica, sans-serif;  
        font-size: 11px;  
        color: #777777;  
        line-height: 16px;  
        font-style: italic;  
    }
    There enjoy i hope i commented enough.

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  2. #2
    Join Date
    May 2006
    Location
    Wakefield, West Yorkshire
    Posts
    1,118
    Tokens
    0

    Latest Awards:

    Default

    Nice +rep

  3. #3
    Join Date
    May 2006
    Location
    Huntingdon (Cambridgeshire UK)
    Posts
    3,395
    Tokens
    0

    Latest Awards:

    Default

    +rep gr88 xx

  4. #4
    Join Date
    Oct 2006
    Posts
    263
    Tokens
    0

    Default

    REP+ I needed that!
    VB Programmer looking for work

  5. #5
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    This is okay apart from all it does is add a index of pages, not a search engine. The script does not crawl the pages or anything.

  6. #6
    Join Date
    Apr 2006
    Location
    Australia
    Posts
    307
    Tokens
    0

    Default

    Quote Originally Posted by SQL Entry
    Error

    There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

    ERROR: Unclosed quote @ 144
    STR: '
    SQL: CREATE TABLE search( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30) NOT NULL, url VARCHAR(30) NOT NULL, about TEXT NOT NULL)'


    SQL query:

    CREATE TABLE search( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30) NOT NULL, url VARCHAR(30) NOT NULL, about TEXT NOT NULL)'

    MySQL said: Documentation
    #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 ''' at line 1
    That's what happened with mine when i entered the SQL.

  7. #7
    Join Date
    Oct 2006
    Location
    London
    Posts
    342
    Tokens
    0

    Default

    I have 1 MYSQL database, can i use that database with this even though its still inuse??

  8. #8
    Join Date
    Sep 2005
    Posts
    5,253
    Tokens
    3,625

    Latest Awards:

    Default

    i woudn't recommend it

  9. #9
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default

    ye i made errors in the mysql query ill fix it in a sec & organised ye i realize that but hey it works great for like lyric search engine.

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  10. #10
    Join Date
    Feb 2006
    Location
    Inside your PC
    Posts
    1,626
    Tokens
    0

    Latest Awards:

    Default

    There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem

    ERROR: Unclosed quote @ 151
    STR: '
    SQL: CREATE TABLE search(
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
    name VARCHAR(30) NOT NULL,
    url VARCHAR(30) NOT NULL,
    about TEXT NOT NULL)'


    SQL query:

    CREATE TABLE search( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30) NOT NULL, url VARCHAR(30) NOT NULL, about TEXT NOT NULL)'

    MySQL said:

    #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 ''' at line 6

    when i do mine

    can osmeone make a crawling spider for this
    Last edited by -::Mr.Dave::-; 04-11-2006 at 12:28 PM.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •