0

I wrote this function to retrieve the homepage of the website link recorded in stats based on STRPOS but Medoo is throwing an error.

function getSiteAuthor($string) {
if ($string) {
    $result = db::query("SELECT id, http FROM users WHERE (strpos(http, '$string') != false) ");
        foreach ($result as $row) {
            return $row['id'];
        }
}

}

http might be "http://example.com" and $string might be "http://example.com/somePage/". So I am looking for where http is found included in $string

The error is "strpos not found in table".

Can this be done using strpos or should it use LIKE and if so, how to code that.

WilliamK
  • 821
  • 1
  • 13
  • 32

1 Answers1

0

Using LIKE works here and finds "$string" in "http" to produce the "id" of the site owner. Simply replace this line in the code above.

$result = db::query("SELECT id, http FROM users WHERE http LIKE '%$string%' ");
WilliamK
  • 821
  • 1
  • 13
  • 32