Skip to content
Advertisement

Tag: exists

How to Check if value exists in a MySQL database

Suppose I have this table: I want to check if the value c7 exists under the variable city or not. If it does, I will do something. If it doesn’t, I will do something else. Answer preferred way, using MySQLi extension (supported from PHP 5 onwards): deprecated and not supported in PHP 7 or newer:

is_file or file_exists in PHP

I need to check if a file is on HDD at a specified location ($path.$file_name). Which is the difference between is_file() and file_exists() functions and which is better/faster to use in PHP? Answer is_file() will return false if the given path points to a directory. file_exists() will return true if the given path points to a valid file or directory.

Advertisement