 <p>Create a class for all your mysql functions.</p> <p>Something like this: Mysql.php file</p> <pre><code>&lt;?php class Mysql { //class variables protected $_connection, $_result, $_numRows; function __construct($server, $dbuser, $dbpass, $dbselect) { $this-&gt;_connection = mysql_connect($server, $dbuser, $dbpass); mysql_select_db($dbselect, $this-&gt;_connection); mysql_set_charset('utf8',$this-&gt;_connection); } /* * @desc Close MySQL connection */ public function dbclose() { mysql_close($this-&gt;_connection); } /* * @desc Write custom queries * * @param string $sql sql query */ public function query($sql) { $this-&gt;_result = mysql_query($sql, $this-&gt;_connection); $this-&gt;_numRows = mysql_num_rows($this-&gt;_result); } /* * @desc get result af query * * @returns string $result */ public function getresult() { return $this-&gt;_result; } /* * @desc get connection af query * * @returns string $sql sql query */ public function getconnection() { return $this-&gt;_connection; } /* * @desc Count rows * @returns int $_numRows */ public function numRows() { return $this-&gt;_numRows; } /* * @desc Count rows and fetch assoc array * @return string $rows array */ public function rows() { $rows =array(); for ($x=0; $x &lt; $this-&gt;numRows(); $x++) { $rows[] = mysql_fetch_assoc($this-&gt;_result); } return $rows; } public function retrieveInfo($companyPassword) { $result=$this-&gt;query("SELECT * FROM company WHERE password='$companyPassword'"); if ($this-&gt;numRows() == 0) { //if there is no result echo "Nothing to retrieve"; } else { //sort your data here or make the SELECT statement more specific, for now we return everything. return $result; } } ?&gt; </code></pre> <p>Now use the class to retrieve your data in your original file:</p> <pre><code> &lt;?php include 'Mysql.php'; $mysql = new Mysql('localhost', 'root', '', 'careers'); $result = $mysql-&gt;retrieveInfo($companypassword); //display the results print_r($results); ?&gt; </code></pre> <p>You can now add functions to the Mysql.php class and use them the same way or directly use the </p> <blockquote> <p>$mysql->query("Your MYSQL QUERY HERE");</p> </blockquote> <p>function to do your calls.</p> <p>You can also use the other methods I already put in Mysql.php for you.</p>