Sending info to a mysql database.

  • 43 favourites

Stats

2,820 visits, 4,446 views

Translations

This tutorial hasn't been translated.

Tools

After going crosseyed looking for info for newbies I decided to do the ole trial and error to link up to a mysql database. So far what I can do is send info to the database. This tutorial assumes you can create the mysql database already.

1: Populate the mysql database with the following fields

-playerid(varchar(30)

-timestamp(timesent) set this to autoincrement

-text(varchar(255)

2: Here is the PHP file

<?php

$username = $_GET['fname'];

$score = $_GET['testy'];

$con = mysql_connect("localhost","userid","password");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("name of database", $con);

mysql_query("INSERT INTO nameoftable (playerid, text) VALUES ($username, $score)");

mysql_close($con);

?>

3: Now in your layout create a text box called "chatinput" as well as a button called "chatinputsend"

4: In the event sheet create an event

chatinputsend - onclick - AJAX - Request - "phpfiledirectorylisting?fname='lance'&testy='" & chatinput.Text & "'"

The above code sends the text box information into the appropriate fields within the mysql database. Hope that helps. Now to just figure out how to pull the information down from the database to populate a text window. Any ideas?

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!