hello all!
I am new to the forums here and also to the world of PHP SQL coding. I have been working on a script for a gaming server that i have and would like some information or feedback on how to fix a problem i am having.
I wrote a script to allow users to create a character using a php form and to place it into the game. the problem is that i get an "Error: Colum count dosent match value at row 1" message and I'm not entirely sure why that is.
I also need help getting information from a single colum in one database over to another database.
here is the code i'm using. its VERY simplistic as far as posting the data goes:
<?php
$con = mysql_connect("localhost","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("characters", $con);
$sql="INSERT INTO characters (guid, account, data, name, race, calss, position_x, position_y, position_z, map)
VALUES
('$_POST[guid]','$_POST[acctnum]','$_POST[name]','$_POST[race]','$_POST[class]','$_POST[posx]','$_POST[posy]','$_POST[posz]','$_POST[map]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
My form code is this:
<table align=left>
<form action="insert.php" method="post">
<tr><td>Character Info<tr><td>Your Account Number:<br> <input type="text" name="acctnum" /><tr>
<td>Character GUID:<br> <input type="text" name="guid" /><br><font size=2 color=red>This is a random number.<tr>
<td>Character Name:<br> <input type="text" name="name" /><br><font size=2 color=red>Give your character a name.<tr>
<td>Character Race:<br> <input type="text" name="race" /><br><font size=2 color=red>Select a number from the Table.<tr>
<td>Character Class:<br> <input type="text" name="class" /><br><font size=2 color=red>Select a number from the Table.<tr><td>Starting Position
<tr><td>Map ID:<br> <input type="text" name="map" /><tr>
<td>Position X:<br> <input type="text" name="posx" /><tr>
<td>Position Y:<br> <input type="text" name="posy" /><tr>
<td>Position Z:<br> <input type="text" name="posz" /><tr><td>
<input type="submit" name="Create Character"/>
</form>
</table>
Now as i said, i need to find out how to:
1. Automatically insert a sequnetial number into the field GUID
2. Take the ACCOUNT ID from one table and place it into the ACCOUNT ID field of another table