![]() | |||||||
2 handy MySQL functions! Functions: set_database_vars($mysql_server, $mysql_username, $mysql_password, $database_name) - Stores the MySQL conenction information. Returns an error message if it fails. sql($query) - Creates a mysql connection, queries the database, and closes the conenction. Returns the results if sucecssful, if it fails, it returns an error message. Code: PHP Code: Handy if you need to do a lot of queries - just include that code in a seperate file and you can query in 1 line of code. |
If I need to use queries extensively, I would create a global connection variable dbconn. Because connecting to a db is always memory consuming. Also, don't close conn. and in your code the close will not be executed because you are doing a return before it. Please send me your comments.... Code:
|
Thanks a lot Saved me a lot of coding |
omg, you all know so much about php.. i wish i had the same knoweledge. |
| All times are GMT -7. The time now is 03:46 AM. |
Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0