I need to be able to check and see in a certain string is anywhere within my SQL table. The table I am using only has one column of char's. Right now it is saying that everything entered is already within the table, even when it actually is not.
Within SQL I am getting the rows that have the word using this:
SELECT * FROM ADDRESSES WHERE STREET LIKE '%streeetName%';
However, in PHP the word is being entered by the user, and then I am storing it as a variable, and then trying to figure out a way to see if that variable is somewhere within the table.
$duplicate = mysql_query("SELECT * FROM ADDRESSES WHERE STREET_NAME LIKE '%$streetName%'", $connect);
if(!empty($duplicate))
{
echo "Sorry, only one of each address allowed.<br /><hr>";
}
mysql_*functions, they are officially deprecated, no longer maintained and removed in PHP 7.0.0. You should update your code with PDO or MySQLi to ensure the functionality of your project in the future.mysql_*function, instead usemysqli_*functions. use checkmysql_num_rows() > 0means some rows return from the querymysqland go for the PDO or Improved standards (mysqli) with PHP,mysqlis depreciated as of the last few builds of PHP. "The original MySQL extension is now deprecated, and will generate E_DEPRECATED errors when connecting to a database. Instead, use the MySQLi or PDO_MySQL extensions." PHP 5.5+ Depreciated Features