Dose any one know mysqli?

Messages
92
Reaction score
1
Points
8
Hi,
I have found a nice thing. An automatic search suggestion just like apple from here [URL]http://www.marcofolio.net/webdesign/a_fancy_apple.com-style_search_suggestion.html[/utl]. Buy my problem is the code in php written for mysqli and I can not figure out where to edit I am giving the code here . Can any one tell me how to modify it for mysql please.
Code:
[COLOR=#000000][FONT=Times New Roman][FONT=Georgia]<p id="searchresults">
<?php
    // PHP5 Implementation - uses MySQLi.
    // mysqli('localhost', 'yourUsername', 'yourPassword', 'yourDatabase');
    $db = mysql_connect('localhost', 'newdbusr', 'newdbusrpassword', 'mynewdb');
    
    if(!$db) {
        // Show error if we cannot connect.
        echo 'ERROR: Could not connect to the database.';
    } else {
        // Is there a posted query string?
        if(isset($_POST['queryString'])) {
            $queryString = $db->real_escape_string($_POST['queryString']);
            
            // Is the string length greater than 0?
            if(strlen($queryString) >0) {
                $query = $db->query("SELECT * FROM search s INNER JOIN categories c ON s.cat_id = c.cid WHERE name LIKE '%" . $queryString . "%' ORDER BY cat_id LIMIT 8");
                
                if($query) {
                    // While there are results loop through them - fetching an Object.
                    
                    // Store the category id
                    $catid = 0;
                    while ($result = $query ->fetch_object()) {
                        if($result->cat_id != $catid) { // check if the category changed
                            echo '<span class="category">'.$result->cat_name.'</span>';
                            $catid = $result->cat_id;
                        }
                         echo '<a href="'.$result->url.'">';
                         echo '<img src="search_images/'.$result->img.'" alt="" />';
                         
                         $name = $result->name;
                         if(strlen($name) > 35) { 
                             $name = substr($name, 0, 35) . "...";
                         }                         
                         echo '<span class="searchheading">'.$name.'</span>';
                         
                         $description = $result->desc;
                         if(strlen($description) > 80) { 
                             $description = substr($description, 0, 80) . "...";
                         }
                         
                         echo '<span>'.$description.'</span></a>';
                     }
                     echo '<span class="seperator"><a href="http://www.marcofolio.net/sitemap.html" title="Sitemap">Nothing interesting here? Try the sitemap.</a></span><br class="break" />';
                } else {
                    echo 'ERROR: There was a problem with the query.';
                }
            } else {
                // Dont do anything.
            } // There is a queryString.
        } else {
            echo 'There should be no direct access to this script!';
        }
    }
?>
</p>
[/FONT][/FONT][/COLOR]
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
I can't imagine anyone is going to be willing to do this for you. Why you may ask...? Mysql_ is way out of date, insecure and slow, so changing this script from mysqli would be a massive backwards step and downgrade. What I suggest is that you learn mysqli rather than always trying to rely on mysql_
 
Messages
92
Reaction score
1
Points
8
I do not want to use mysqli I want use this script. I do not know any thing about mysqli So, I asked any one can tell em what change and where I have to do to use this script. As far as I know x10hosting dose not provide mysqli services so there is no options for using mysqli.
I just want to know what change I have to make on this script.

---------- Post added at 06:04 AM ---------- Previous post was at 06:01 AM ----------

I do not want to use mysqli I want use this script. I do not know any thing about mysqli So, I asked any one can tell em what change and where I have to do to use this script. As far as I know x10hosting dose not provide mysqli services so there is no options for using mysqli.
I just want to know what change I have to make on this script.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
mysqli is just another DB driver to interface PHP scripts with MyQSL. As long as the extension is part of the local PHP install, it will work just as well (if not better; it has greater functionality) than the outdated mysql driver. If you want to know more, read the manual.
 
Last edited:

callumacrae

not alex mac
Community Support
Messages
5,257
Reaction score
97
Points
48
/me waves a watch about

You want to use MySQLi

~Callum
 
Top