Contridentuallity

Not a fact, a theory!?

Subscribe to RSS feed

Posts tagged with "mysql"

Tribulant.com - PHP, MySQL, JavaScript, Flash, etc... Scripts

, , , ...

My new website design :



http://www.tribulant.com

Feel free to test out the site, scripts and other resources and post your comments here.
All comments will be greatly appreciated, since the site is still under fast development.

Tribulant.com

, , , ...

I've always had the bad habit of revamping my sites way too often.
I used to have a site at http://www.tribulant.com but there is nothing there now except for a "Coming Soon..." page.
I recently decided that I needed to get the site up and running again, so I've been spending some time on doing just that.

Screenshot :


This is what I have now.
It's not up yet, since I'm still working on the backend programming.

Let me know what you think of the design so far. wink

MySQL Last Inserted ID

, , , ...

In some cases, you will need to retrieve the last inserted ID which was inserted into your database using PHP specifically when you are using an 'auto_increment' parameter for that field. Obviously there is a common way of doing this, but there is also a built in function which will help you to achieve the same result with less code.

The common way :
$query = "INSERT INTO table (id, value) VALUES ('', 'value')";
mysql_query($query) or die(mysql_error());

$id = mysql_result((mysql_query("SELECT * FROM table WHERE value = 'value'")), 0, 'id');

echo "The last inserted ID was :" . $id;


The easy way :
$query = "INSERT INTO table (id, value) VALUES ('', 'value')";
mysql_query($query) or die(mysql_error());

echo "The last inserted ID was :" . mysql_insert_id();


A useful snippet if you aren't familiar with the 'mysql_insert_id()' function. This will save you some coding and time if you've been using other common, longer ways in the past.
February 2012
S M T W T F S
January 2012March 2012
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29