MySQL Data Insert
Posted: Fri Oct 05, 2007 10:17 pm
scottayy | Please use
Here is the table:
The data does not appear to be in the table. I cannot quite find what the problem is because this code seems to work fine:
scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am trying to make it so if a name does not exist, it puts it in the table.
Here is my code:Code: Select all
//Look for Username in CS
$CSuser = mysql_query("SELECT * FROM CS WHERE Name='{$_SESSION['username']}'");
$CSname = mysql_fetch_array($CSuser);
//Check if New User CS
If ($CSname==NULL)
{
mysql_query("INSERT INTO CS (Name, Class, Level, EXP, Gold, HP, MP, MeleeAttack, MeleeDefence, RangedAttack, RangedDefence, MagicAttack, MagicDefence, Strength, Endurance, Vitality, Dexterity, Accuracy, Speed, Casting, Mana, Negate, Charisma, Alchemy, Faith)
VALUES ('{$_SESSION['username']}', 'None', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')");
}Code: Select all
$result = mysql_query("SELECT * FROM CS");
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Class</th>
<th>Level</th>
<th>EXP</th>
<th>Gold</th>
<th>HP</th>
<th>MP</th>
<th>MeleeAttack</th>
<th>MeleeDefence</th>
<th>RangedAttack</th>
<th>RangedDefence</th>
<th>MagicAttack</th>
<th>MagicDefence</th>
<th>Strength</th>
<th>Endurance</th>
<th>Vitality</th>
<th>Dexterity</th>
<th>Accuracy</th>
<th>Speed</th>
<th>Casting</th>
<th>Mana</th>
<th>Negate</th>
<th>Charisma</th>
<th>Alchemy</th>
<th>Faith</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Class'] . "</td>";
echo "<td>" . $row['Level'] . "</td>";
echo "<td>" . $row['EXP'] . "</td>";
echo "<td>" . $row['Gold'] . "</td>";
echo "<td>" . $row['HP'] . "</td>";
echo "<td>" . $row['MP'] . "</td>";
echo "<td>" . $row['MeleeAttack'] . "</td>";
echo "<td>" . $row['MeleeDefence'] . "</td>";
echo "<td>" . $row['RangedAttack'] . "</td>";
echo "<td>" . $row['RangedDefence'] . "</td>";
echo "<td>" . $row['MagicAttack'] . "</td>";
echo "<td>" . $row['MagicDefence'] . "</td>";
echo "<td>" . $row['Strength'] . "</td>";
echo "<td>" . $row['Endurance'] . "</td>";
echo "<td>" . $row['Vitality'] . "</td>";
echo "<td>" . $row['Dexterity'] . "</td>";
echo "<td>" . $row['Accuracy'] . "</td>";
echo "<td>" . $row['Speed'] . "</td>";
echo "<td>" . $row['Casting'] . "</td>";
echo "<td>" . $row['Mana'] . "</td>";
echo "<td>" . $row['Negate'] . "</td>";
echo "<td>" . $row['Charisma'] . "</td>";
echo "<td>" . $row['Alchemy'] . "</td>";
echo "<td>" . $row['Faith'] . "</td>";
echo "</tr>";
}
echo "</table>";Code: Select all
//Look for Username in CE
$CEuser = mysql_query("SELECT * FROM CE WHERE Name='{$_SESSION['username']}'");
$CEname = mysql_fetch_array($CEuser);
//Check if New User CE
If ($CEname==NULL)
{
mysql_query("INSERT INTO CE (Name, Weapon, Shield, Body, Helmet, Legs, Necklace, Gloves, Boots, Ring, Earring, Cape, Symbol, Bangle, Mount, Wings)
VALUES ('{$_SESSION['username']}', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')");
}scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]