<?php
// A simple transaction example using PHP and mysql_query
//——————————————–
@mysql_connect(“localhost”,”myusername”, “mypassword”) or die(mysql_error());
@mysql_select_db(“mydatabase”) or die(mysql_error());
$query = “INSERT INTO mytable (firstname, lastname) values (‘Fred’,’Bloggs’)”;
begin(); // begin transaction
$result = @mysql_query($query);
if(!$result) {
rollback(); // failed so roll back transaction
echo “Rolled back”;
exit;
}
else
{
commit(); // Committ transaction
echo “Transaction completed”;
}
//——————————————–
//——————————————–
function begin() {
@mysql_query(“BEGIN”);
}
//——————————————–
function commit() {
@mysql_query(“COMMIT”);
}
//——————————————–
function rollback() {
@mysql_query(“ROLLBACK”);
}
?>
The above code illustrates the use of transactions with [...]
Entries from July 2012
Simple transaction example using PHP and mysql_query
July 30th, 2012 · No Comments
Tags: General PHP · SQL databases
SQL Transactions in PHPmyAdmin
July 26th, 2012 · No Comments
A transaction is a collection of SQL statements. So a task may for example, may consist of a number of update statements. If one of these should fail you may end up with some tables correctly updated but others not correctly updated particularly if one update has data from a previous update.
To overcome this you [...]
Tags: SQL databases
Setting up a digtial download store
July 21st, 2012 · No Comments
We have already written a short pdf document at http://www.withinweb.com/global/hints_tips_and_tricks/digital_files.pdf which provides some hints, tips and tricks for selling digital downloads.
Here are a few other issues that you may want to consider when setting up a digital online shopping system
Make sure your system is secure
It probably goes without saying that the shopping system has to [...]
Tags: Shopping carts
Google introduces Adwords Express
July 19th, 2012 · No Comments
Google AdWords Express is a cut down version of Google AdWords system. The express version has fewer options which can be an advantage for those who have small business and don’t want to get into the complexities of setting individual parameters for keywords or get involved in the many other options that are available.
The user [...]
Tags: SOE
Links to your site using Google Webmaster
July 12th, 2012 · No Comments
If you want to find which web site links to your site, one way is to your Google Webmaster. (http://wwwgoogle.com/webmaster)
The site has to be verified in the webmaster site and then :
On the Webmaster Tools Home page, click the site you want.
On the left-hand menu, click Traffic, and then click Links to Your Site.
Tags: SOE
What kind of content are you mainly selling – July 2012
July 11th, 2012 · No Comments
What kind of content are you mainly selling – July 2012
This are the latest results from the on-line poll that is running all the time.
The results still appear to show that selling mp3 audio files is still very popular.
mp3 audio files: 32.7%
e-books: 15%
Video files: 14.1%
Physical CDs / DVDs: 9.7%
Software: [...]
Tags: OnLine Poll Results
About htpasswd – The file to store passwords
July 6th, 2012 · No Comments
The htpasswd file is used when password protecting a website or a directory using HTTP Authentication and Apache’s htaccess files.
The htpasswd file contains username in plain text (unencrypted) and a hashed (encrypted) password.
Each line contains a username and a password separated by a colon “:”. You can not see the actual passwords as they are [...]
Tags: General PHP · PHP-SecureArea
get_magic_quotes_gpc in PHP6
July 3rd, 2012 · No Comments
In PHP6, get_magic_qu0tes_gpc will be depreciated, but you may still want to be able to test for it if you do not know which version of PHP it will be running on.
Here are two possible ways of how this might be done. Both of these create a new function called is_get_magic_quotes_gpc to make it easier [...]
Tags: General PHP