search
top
Currently Browsing: MySQL

Database Connections Outside of Webroot

For extra security many often store their database connection credentials outside of the web root. This is fairly easy to achieve without to much work. For those of you who are unsure how to store database connection credentials in a separate file please refer to my article on Connecting to MySQL with PHP Once you have your connections in a php file (this is also relevant to other languages such as asp... read more

Getting The Last Auto Increment Field With PHP

On many occasions you need to find the value of the last auto increment field inserted into a MySQL table. For example within my Content Management System if someone creates a new web page and saves it the user is taken back to edit this new page. In order to do this I must retrieve the value of the last auto increment field inserted into the database. To do this I use the php mysql_insert_id();... read more

Resetting MySQL Auto Increment Field

After developing a number of systems in the past it is of course essential to completely test any piece of software. This of course means that any tables that use an auto_increment field will not start from 1 when the system goes live. Not a massive problem but it is nice sometimes to reset the value to 1. After searching around the web what seemed like an age I finally found the SQL that carry s out just... read more

Connecting to MySQL with PHP

Connecting to a mysql database is pretty easy using php as it gives you all the commands you need in order to do it. This example is a basic way to do, there are other methods but I found this way useful when I was just starting out! Here is an example of connecting and quering a mysql... read more
top