Sign in to follow this  

PHP,SQL Question!!!

Recommended Posts

supertab    104
I really need a script for my browser game. i need a php script the will exacute a sql script that scripts to a mysql database and changed a variable to +1

Share this post

Link to post
Share on other sites
JasRonq    156
You need a basic tutorial or book on how to write PHP code and manipulate SQL databases then. This is a game forum, and your question is not really related to that subject. Not only that, but there are sections of this forum related to coding that would be more applicable than this section.

So, go buy, or download, a book about PHP and SQL, and teach yourself some basic skills. Incrementing a variable by one is probably a pretty basic starting point for learning PHP/SQL interactions so go learn those basic coding skills before you come here as this is a forum for questions about designing games.

Share this post

Link to post
Share on other sites
Hodgman    51234

Which part are you having a problem with?

Connecting to your DB and issuing queries from PHP?
Writing SQL queries to perform the increment?
Setting up MySQL tables?

[Edited by - Hodgman on November 8, 2009 12:30:50 AM]

Share this post

Link to post
Share on other sites
ToohrVyk    1595
Assuming that you already have PHP and MySQL servers running, and you know how to identify what row you wish to change (say, by id):

// Connect to database
$db = new mysqli();

// Prepare an SQL statement
$statement = $db -> prepare('UPDATE myTable SET myValue = myvalue + 1 WHERE id = ?');
$statement -> bind_param('i', $id);

// Run the statement
$statement -> execute();

// Clean up
$statement -> close();
$db -> close();

The actual details of the code will of course depend on your code and database structure.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this