#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    830
    Rep Power
    0

    Which Styles Are They ?


    Folks,

    What style is this following code in ? It uses "->" which I am not familiar with.
    Is it oop ? Maybe even pdo ? But wait, it mentions 'mysqli' !!!
    I have never come across mysqli ever using '->'. Strange!
    PHP Code:
    <?php

    //TUTORIAL: https://developer-blog.net/en/build-your-own-search-engine/

        
    $url "http://www.developer-blog.net";
     
        
    $mysqli = new mysqli("localhost""root""""crawler_index");
        
        if(
    $mysqli->connect_error){
           echo 
    "unable to connect to Database: ".mysqli_connect_error()."\n";
           exit();
        }
     
        
    $links find_all_links($url);
        
    links_to_db($links$mysqli);
     
        function 
    find_all_links($url)
        {
            
    $htmlData file_get_contents($url);
            if(
    preg_match_all('/<a\s+href=["\']([^"\']+)["\']/i'$htmlData$linksPREG_PATTERN_ORDER))
            {
                return 
    array_unique($links[1]);
            }
            return 
    null;
        }
     
        function 
    links_to_db($links$mysql)
        {
            
    //urls to db
            
    foreach($links as $link){
            
    $allowed true;
     
            
    //check if url exists
            
    $statement "SELECT * FROM `crawler_index` WHERE internal_url = ?";
            if(
    $stmt $mysql->prepare($statement)){
                
    $stmt->bind_param("s"$link);
                
    $stmt->execute();
                
    $stmt->store_result();
                if(
    $stmt->num_rows>0){
                    
    $allowed=false;
                }
                
    $stmt->close();
            }
     
            
    //insert into DB
            
    if($allowed){
                
    $statement "INSERT INTO `crawler_index` (internal_url) VALUES (?)";
                if(
    $stmt $mysql->prepare($statement)){
                    
    $stmt->bind_param("s"$link);
                    
    $stmt->execute();
                    
    $stmt->close();
                }
            }
        }
    }

    ?>
    In short, I struggled to understand it at first. And so, tried converting it to the mysqli way I learn.
    Look below.
    Check the commented-out parts of the code. Those are the originals commented-out because I replaced them with my line of mysqli coding.
    PHP Code:
    <?php

        $url 
    "http://www.developer-blog.net";
     
        
    /*
        $mysqli = new mysqli("localhost", "root", "", "crawler_index");
            
        if($mysqli->connect_error){
           echo "unable to connect to Database: ".mysqli_connect_error()."\n";
           exit();
        }
        */


        //Connect to Mysql Database in this input format: "Server", "MySql User", "Mysql User Password", "MySql Database Name".
        
    $mysqli mysqli_connect("localhost""root""""crawler_index");

        if (!
    $mysqli
        {
            
    //Error Message to show user in technical/development mode to see errors.
            
    die("Database Error : " mysqli_error($mysqli));
        
            
    //Error Message to show User in Layman's mode to see errors.
            
    die("Database error.");
            exit();
        }

        
    $links find_all_links($url);
        
    links_to_db($links$mysqli);
     
        function 
    find_all_links($url)
        {
            
    $htmlData file_get_contents($url);
            if(
    preg_match_all('/<a\s+href=["\']([^"\']+)["\']/i'$htmlData$linksPREG_PATTERN_ORDER))
            {
                return 
    array_unique($links[1]);
            }
            return 
    null;
        }
     
        
    /*
        function links_to_db($links, $mysql)
        {
            //urls to db
            foreach($links as $link){
            $allowed = true;
     
            //check if url exists
            $statement = "SELECT * FROM `crawler_index` WHERE internal_url = ?";
            if($stmt = $mysql->prepare($statement)){
                $stmt->bind_param("s", $link);
                $stmt->execute();
                $stmt->store_result();
                if($stmt->num_rows>0){
                    $allowed=false;
                }
                $stmt->close();
            }
        */
        
        
    function links_to_db($links,$mysqli)
        { 
            
    //Urls to DB. 
            
    foreach($links as $link
            { 
                
    $query_1 "SELECT * FROM crawler_index WHERE internal_url = ?"
                
    //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ?"; 
                //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                
    if($stmt_1 mysqli_prepare($mysqli,$query_1))
                {
                    
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
                    
    mysqli_stmt_execute($stmt_1); 
                    
    $result_1 mysqli_stmt_bind_result($stmt_1,$db_link); 
                    
    mysqli_stmt_fetch($stmt_1); 
                    
    mysqli_stmt_free_result($stmt_1); 
                    
    //if(!$stmt_1) 
                    
    if($link == $db_link
                    {
                        
    $allowed false
                    }
                    
    mysqli_stmt_close($stmt_1); 
                }
     
            
    /*
            //insert into DB
            if($allowed){
                $statement = "INSERT INTO `crawler_index` (internal_url) VALUES (?)";
                if($stmt = $mysql->prepare($statement)){
                    $stmt->bind_param("s", $link);
                    $stmt->execute();
                    $stmt->close();
                }
            }
            */
            
            //Insert the user's inputs into Mysql database using php's sql injection prevention method "Prepared Statements".
            
    $query_2 "INSERT INTO crawler_index(url,internal_url) VALUES (?,?)"
            
    $stmt_2 mysqli_prepare($mysqli,$query_2);
            
    mysqli_stmt_bind_param($stmt_2,'ss',$url$internal_url);
            
    mysqli_stmt_execute($stmt_2);
            
    //Free Result Set. 
            
    mysqli_stmt_free_result($stmt_2); 
            
    //Close Statement Connection. 
            
    mysqli_stmt_close($stmt_2); 
            
    //Close Database Connection. 
            
    mysqli_close($mysqli);  
        }
    }

    ?>
    Now do tell me, what are the difference between my style and the style it was written in ? What do you call each of these 2 styles ?
    Anyway, check my next post ...
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    830
    Rep Power
    0
    As I try converting the style, I am getting this error.
    PHP Code:
    Warningmysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:\xampp\htdocs\cURL\crawler_test.php on line 74

    Warning: mysqli_prepare(): Couldn'
    t fetch mysqli in C:\xampp\htdocs\cURL\crawler_test.php on line 70

    Warning
    mysqli_prepare(): Couldn't fetch mysqli in C:\xampp\htdocs\cURL\crawler_test.php on line 99

    Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, null given in C:\xampp\htdocs\cURL\crawler_test.php on line 100

    Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, null given in C:\xampp\htdocs\cURL\crawler_test.php on line 101

    Warning: mysqli_stmt_free_result() expects parameter 1 to be mysqli_stmt, null given in C:\xampp\htdocs\cURL\crawler_test.php on line 103

    Warning: mysqli_stmt_close() expects parameter 1 to be mysqli_stmt, null given in C:\xampp\htdocs\cURL\crawler_test.php on line 105

    Warning: mysqli_close(): Couldn'
    t fetch mysqli in C:\xampp\htdocs\cURL\crawler_test.php on line 107 
    For the code, look at the final code in my previous post.
    Original problem is this:
    Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:\xampp\htdocs\cURL\crawler_test.php on line 74
    And it has been really pi**ing me off!
    How the heck is the bind variable not matching with the number of fields in prepared statements here ...
    PHP Code:
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
    PHP Code:
    $result_1 mysqli_stmt_bind_result($stmt_1,$db_link); 
    Both have one variable as their params. So, what is there not to match ? Doing my head-in!
    Context:
    PHP Code:
    function links_to_db($links,$mysqli)
        { 
            
    //Urls to DB. 
            
    foreach($links as $link
            { 
                
    $query_1 "SELECT * FROM crawler_index WHERE internal_url = ?"
                
    //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ?"; 
                //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                
    if($stmt_1 mysqli_prepare($mysqli,$query_1))
                {
                    
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
                    
    mysqli_stmt_execute($stmt_1); 
                    
    $result_1 mysqli_stmt_bind_result($stmt_1,$db_link); 
                    
    mysqli_stmt_fetch($stmt_1); 
                    
    mysqli_stmt_free_result($stmt_1); 
                    
    //if(!$stmt_1) 
                    
    if($link == $db_link
                    {
                        
    $allowed false
                    }
                    
    mysqli_stmt_close($stmt_1); 
                } 
    Look at all those queries I tried but no luck as same damn error!
    PHP Code:
    $query_1 "SELECT * FROM crawler_index WHERE internal_url = ?"
    //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
    //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ?"; 
    //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
    EDIT: i know I should be using the COUNT(*) here as that occured few mins ago. But still, I still want to sort this current mess out doing the things the way I did.
    Last edited by UniqueIdeaMan; May 27th, 2018 at 06:09 PM.
  4. #3
  5. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    6,265
    Rep Power
    4193
    -> is used to access properties and methods of an object.

    Required reading: Classes and Objects.
    Recycle your old CD's



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,946
    Rep Power
    4554
    Originally Posted by kicken
    -> is used to access properties and methods of an object.

    Required reading: Classes and Objects.
    Kicken,

    Perhaps you can help me, too. I recently discovered the * key and have been placing that character after all vowels in my code. Now I'm getting errors. Do you have any idea why??

    Comments on this post

    • UniqueIdeaMan agrees : keep up your criticisms. I'm going somewhere.
    -- Cigars, whiskey and wild, wild women. --
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    830
    Rep Power
    0

    Thumbs up


    Originally Posted by Sepodati
    Kicken,

    Perhaps you can help me, too. I recently discovered the * key and have been placing that character after all vowels in my code. Now I'm getting errors. Do you have any idea why??
    Thanks for the hint. You mean, I should be using:
    PHP Code:
    $query_1 "SELECT internal_url FROM crawler_index WHERE internal_url = ?";

    if(
    $stmt_1 mysqli_prepare($mysqli,$query_1))
                {
                    
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
                    
    mysqli_stmt_execute($stmt_1); 
                    
    $result_1 mysqli_stmt_bind_result($stmt_1,$db_link); 
    Or, using:

    PHP Code:
    $query_1 "SELECT internal_url FROM crawler_index WHERE internal_url = ?";

    if(
    $stmt_1 mysqli_prepare($mysqli,$query_1))
                {
                    
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
                    
    mysqli_stmt_execute($stmt_1); 
                    
    $result_1 mysqli_stmt_bind_result($stmt_1,$id,$db_date_and_time,$db_url,$db_title,$db_description,$db_link); 
    Last edited by UniqueIdeaMan; May 28th, 2018 at 03:04 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    830
    Rep Power
    0
    I got reminded that pdo is substitute for mysqli.
    Reminded that "->" is oop style.
    And my mysqli style that I use is procedural style (I know that).
    All these objects stuffs do my head-in. Don't understand it.
    Classes I used to deliberately ignore as they seemed adv stuff and not for beginners or intermediates. But, understood a little about classes from some or one of you guys from one of my threads. Not sure who it was. Barand or DSismad (or whatever his name is) or somebody else. Can't remember.

    Checking out Kicken's recommended links. But no one should expect me to read them all in one go. Will take probably wks to disgest all that or even mnths. When I do not understand something in the links then expect tonnes of questions flooding this forum way. You folks are gonna be left standing on the fringe of your toes!
    Last edited by UniqueIdeaMan; May 28th, 2018 at 02:15 PM.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    830
    Rep Power
    0
    Folks,

    Q1. Which query_1 would you use ?
    PHP Code:
    $query_1 "SELECT internal_url FROM crawler_index WHERE internal_url = ?"
    //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
    if($stmt_1 mysqli_prepare($mysqli,$query_1))
    {
         
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
         
    mysqli_stmt_execute($stmt_1); 
         
    $result_1 mysqli_stmt_bind_result($stmt_1,$db_link); 
         
    mysqli_stmt_fetch($stmt_1); 
         
    mysqli_stmt_free_result($stmt_1); 
        
    //if(!$stmt_1) 
        
    if($link == $db_link
        {
            
    $allowed false
        }
        
    mysqli_stmt_close($stmt_1); 


    Q2. Which one would you use ?

    This:

    PHP Code:
    if(!$stmt_1
    {
        
    $allowed false

    Or that:

    PHP Code:
    if($link == $db_link
    {
        
    $allowed false


    Q3. Why am I now getting this new error:
    Warning: mysqli_prepare(): Couldn't fetch mysqli in C:\xampp\htdocs\cURL\crawler_test.php on line 70

    Line 70 looks like this:
    PHP Code:
    if($stmt_1 mysqli_prepare($mysqli,$query_1)) 
    Context:
    PHP Code:
    $query_1 "SELECT internal_url FROM crawler_index WHERE internal_url = ?"
                if(
    $stmt_1 mysqli_prepare($mysqli,$query_1))
                {
                    
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
                    
    mysqli_stmt_execute($stmt_1); 
                    
    $result_1 mysqli_stmt_bind_result($stmt_1,$db_link); 
                    
    mysqli_stmt_fetch($stmt_1); 
                    
    mysqli_stmt_free_result($stmt_1); 
                    
    //if(!$stmt_1) 
                    
    if($link == $db_link
                    {
                        
    $allowed false
                    }
                    
    mysqli_stmt_close($stmt_1); 
                } 
    Full code again:
    PHP Code:
    <?php

        $url 
    "http://www.developer-blog.net";
     
        
    /*
        $mysqli = new mysqli("localhost", "root", "", "crawler_index");
            
        if($mysqli->connect_error){
           echo "unable to connect to Database: ".mysqli_connect_error()."\n";
           exit();
        }
        */


        //Connect to Mysql Database in this input format: "Server", "MySql User", "Mysql User Password", "MySql Database Name".
        
    $mysqli mysqli_connect("localhost""root""""crawler_index");

        if (!
    $mysqli
        {
            
    //Error Message to show user in technical/development mode to see errors.
            
    die("Database Error : " mysqli_error($mysqli));
        
            
    //Error Message to show User in Layman's mode to see errors.
            
    die("Database error.");
            exit();
        }

        
    $links find_all_links($url);
        
    links_to_db($links$mysqli);
     
        function 
    find_all_links($url)
        {
            
    $htmlData file_get_contents($url);
            if(
    preg_match_all('/<a\s+href=["\']([^"\']+)["\']/i'$htmlData$linksPREG_PATTERN_ORDER))
            {
                return 
    array_unique($links[1]);
            }
            return 
    null;
        }
     
        
    /*
        function links_to_db($links, $mysql)
        {
            //urls to db
            foreach($links as $link){
            $allowed = true;
     
            //check if url exists
            $statement = "SELECT * FROM `crawler_index` WHERE internal_url = ?";
            if($stmt = $mysql->prepare($statement)){
                $stmt->bind_param("s", $link);
                $stmt->execute();
                $stmt->store_result();
                if($stmt->num_rows>0){
                    $allowed=false;
                }
                $stmt->close();
            }
        */
        
        
    function links_to_db($links,$mysqli)
        { 
            
    //Urls to DB. 
            
    foreach($links as $link
            { 
                
    //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ?"; 
                //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                
    $query_1 "SELECT internal_url FROM crawler_index WHERE internal_url = ?"
                
    //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                
    if($stmt_1 mysqli_prepare($mysqli,$query_1))
                {
                    
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
                    
    mysqli_stmt_execute($stmt_1); 
                    
    //$result_1 = mysqli_stmt_bind_result($stmt_1,$db_id,$db_url,$db_title,$db_description,$db_link); 
                    
    $result_1 mysqli_stmt_bind_result($stmt_1,$db_link); 
                    
    mysqli_stmt_fetch($stmt_1); 
                    
    mysqli_stmt_free_result($stmt_1); 
                    
    //if(!$stmt_1) 
                    
    if($link == $db_link
                    {
                        
    $allowed false
                    }
                    
    mysqli_stmt_close($stmt_1); 
                }
     
            
    /*
            //insert into DB
            if($allowed){
                $statement = "INSERT INTO `crawler_index` (internal_url) VALUES (?)";
                if($stmt = $mysql->prepare($statement)){
                    $stmt->bind_param("s", $link);
                    $stmt->execute();
                    $stmt->close();
                }
            }
            */
            
            //Insert the user's inputs into Mysql database using php's sql injection prevention method "Prepared Statements".
            
    $query_2 "INSERT INTO crawler_index(url,internal_url) VALUES (?,?)"
            
    $stmt_2 mysqli_prepare($mysqli,$query_2);
            
    mysqli_stmt_bind_param($stmt_2,'ss',$url$internal_url);
            
    mysqli_stmt_execute($stmt_2);
            
    //Free Result Set. 
            
    mysqli_stmt_free_result($stmt_2); 
            
    //Close Statement Connection. 
            
    mysqli_stmt_close($stmt_2); 
            
    //Close Database Connection. 
            
    mysqli_close($mysqli);  
        }
    }

    ?>
    Last edited by UniqueIdeaMan; May 28th, 2018 at 03:26 PM.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    830
    Rep Power
    0
    Folks,

    I have decided that, the way I am trying to convert things is becoming more of a nuisance than it is worth and so might aswell stick to the style (oop) of the tutorial than try to convert it to mysqli procedural.
    But saying all this, I still need to know why I am getting this error:
    Warning: mysqli_prepare(): Couldn't fetch mysqli in C:\xampp\htdocs\cURL\crawler_test.php on line 71
    Line 71 looks like this:
    PHP Code:
    if($stmt_1 mysqli_prepare($mysqli,$query_1)) 
    Trying to use the COUNT(column) function this time compared to what I tried in my previous post.

    Context:
    PHP Code:
    //Urls to DB. 
            
    foreach($links as $link
            { 
                
    $query_1 "SELECT COUNT(internal_url) FROM crawler_index WHERE internal_url = ?"
                
    //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ?"; 
                //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ?"; 
                //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                
    if($stmt_1 mysqli_prepare($mysqli,$query_1))
                {
                    
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
                    
    mysqli_stmt_execute($stmt_1); 
                    
    //$result_1 = mysqli_stmt_bind_result($stmt_1,$db_id,$db_date_nad_time,$db_url,$db_title,$db_description,$db_link); 
                    
    $result_1 mysqli_stmt_bind_result($stmt_1,$link_count); 
                    
    mysqli_stmt_fetch($stmt_1); 
                    
    mysqli_stmt_free_result($stmt_1); 
                    
    //if(!$stmt_1) 
                    
    if($link_count>0
                    {
                        
    $allowed false
                    }
                    
    mysqli_stmt_close($stmt_1); 
                } 
    Full code:
    PHP Code:
    <?php

        $url 
    "http://www.developer-blog.net";
     
        
    /*
        $mysqli = new mysqli("localhost", "root", "", "crawler_index");
            
        if($mysqli->connect_error){
           echo "unable to connect to Database: ".mysqli_connect_error()."\n";
           exit();
        }
        */


        //Connect to Mysql Database in this input format: "Server", "MySql User", "Mysql User Password", "MySql Database Name".
        
    $mysqli mysqli_connect("localhost""root""""crawler_index");

        if (!
    $mysqli
        {
            
    //Error Message to show user in technical/development mode to see errors.
            
    die("Database Error : " mysqli_error($mysqli));
        
            
    //Error Message to show User in Layman's mode to see errors.
            
    die("Database error.");
            exit();
        }

        
    $links find_all_links($url);
        
    links_to_db($links$mysqli);
     
        function 
    find_all_links($url)
        {
            
    $htmlData file_get_contents($url);
            if(
    preg_match_all('/<a\s+href=["\']([^"\']+)["\']/i'$htmlData$linksPREG_PATTERN_ORDER))
            {
                return 
    array_unique($links[1]);
            }
            return 
    null;
        }
     
        
    /*
        function links_to_db($links, $mysql)
        {
            //urls to db
            foreach($links as $link){
            $allowed = true;
     
            //check if url exists
            $statement = "SELECT * FROM `crawler_index` WHERE internal_url = ?";
            if($stmt = $mysql->prepare($statement)){
                $stmt->bind_param("s", $link);
                $stmt->execute();
                $stmt->store_result();
                if($stmt->num_rows>0){
                    $allowed=false;
                }
                $stmt->close();
            }
        */
        
        
    function links_to_db($links,$mysqli)
        { 
            
    //Urls to DB. 
            
    foreach($links as $link
            { 
                
    $query_1 "SELECT COUNT(internal_url) FROM crawler_index WHERE internal_url = ?"
                
    //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ?"; 
                //$query_1 = "SELECT * FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ?"; 
                //$query_1 = "SELECT internal_url FROM crawler_index WHERE internal_url = ? LIMIT 1"; 
                
    if($stmt_1 mysqli_prepare($mysqli,$query_1))
                {
                    
    mysqli_stmt_bind_param($stmt_1,'s',$link); 
                    
    mysqli_stmt_execute($stmt_1); 
                    
    //$result_1 = mysqli_stmt_bind_result($stmt_1,$db_id,$db_date_nad_time,$db_url,$db_title,$db_description,$db_link); 
                    
    $result_1 mysqli_stmt_bind_result($stmt_1,$link_count); 
                    
    mysqli_stmt_fetch($stmt_1); 
                    
    mysqli_stmt_free_result($stmt_1); 
                    
    //if(!$stmt_1) 
                    
    if($link_count>0
                    {
                        
    $allowed false
                    }
                    
    mysqli_stmt_close($stmt_1); 
                }
     
            
    /*
            //insert into DB
            if($allowed){
                $statement = "INSERT INTO `crawler_index` (internal_url) VALUES (?)";
                if($stmt = $mysql->prepare($statement)){
                    $stmt->bind_param("s", $link);
                    $stmt->execute();
                    $stmt->close();
                }
            }
            */
            
            //Insert the user's inputs into Mysql database using php's sql injection prevention method "Prepared Statements".
            
    $query_2 "INSERT INTO crawler_index(url,internal_url) VALUES (?,?)"
            
    $stmt_2 mysqli_prepare($mysqli,$query_2);
            
    mysqli_stmt_bind_param($stmt_2,'ss',$url$internal_url);
            
    mysqli_stmt_execute($stmt_2);
            
    //Free Result Set. 
            
    mysqli_stmt_free_result($stmt_2); 
            
    //Close Statement Connection. 
            
    mysqli_stmt_close($stmt_2); 
            
    //Close Database Connection. 
            
    mysqli_close($mysqli);  
        }
    }

    ?>
    I still need an answer to all my questions in my previous post aswell as this one.

IMN logo majestic logo threadwatch logo seochat tools logo