Web Analytics Made Easy -
StatCounter Find a string called "Shiv" in whole the data base tables problem - CodingForum

Announcement

Collapse
No announcement yet.

Find a string called "Shiv" in whole the data base tables problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Find a string called "Shiv" in whole the data base tables problem

    Hi i need to find a string "Shiv" in the whole data base tables

    what i need to do in the finally is get the table name and field which include "Shiv"

    Then i need to update with "Hero"

    i have wrote a code for that

    $xx='TABLES';

    $sql1="SELECT * FROM INFORMATION_SCHEMA.$xx WHERE TABLE_SCHEMA='firefoxbd' AND TABLE_TYPE='BASE TABLE' ";
    $result1=mysql_query($sql1);
    while($data=mysql_fetch_array($result1))
    {




    $tname=$data['TABLE_NAME'];

    $sql2="SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='firefoxbd' AND TABLE_NAME='$tname' ";
    $result2=mysql_query($sql2);
    while($data2=mysql_fetch_array($result2))
    {

    $columname=$data2['COLUMN_NAME'];
    $tablename=$data2['TABLE_NAME'];

    $sql3=mysql_query("SELECT * FROM firefoxbd.$tablename WHERE firefoxbd.$columname LIKE 'Shiv'");
    echo $sql3;
    echo "<br>";
    //$result3=mysql_query($sql3);
    //$data3=mysql_fetch_array($result3);
    $norowss=mysql_num_rows($sql3); /// This is the line 47

    if($sql3 > 0)
    {

    $tablename1=$tablename;
    $fieldname1=$columname;

    $xx=$tablename1."-".$fieldname1;

    echo $xx;
    echo "<br>";

    }
    else
    {



    }


    }

    //echo $tname;
    //echo "<br>";


    }


    ?>

    when i run this

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/Test/searchvari.php on line 47

    please help me to improve this code

  • #2
    you never check, if your query succeeds. besides that the mysql_* functions are outdated, deprecated, and removed from the current PHP. use PDO or mysqli instead.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

    Comment

    Working...
    X