Sending info to a mysql database.

2

Stats

5,694 visits, 8,361 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 18 Apr, 2012. Last updated 19 Feb, 2019

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?

  • 1 Comments

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