XtremeGamer99
08-16-2004, 01:13 AM
Hey. I can't figure out what is wrong with this script. The INSERT dosen't seem to be working.
Note: This is a very basic script, mainly to see if it would work. There are a lot of unnessasary thing like the "\", but I will get to that later.
I have this same script working with other pages (add author, add game), but this one doesn't put it into MySQL.
Can anyone help me?
index.php
<?
$authorID = $_GET['authorID'];
$gameID = $_GET['game'];
echo ('
Search for a Author:
...
...
";
}
if (isset($game))
{
echo "
<form method=\"get\" action=\"addcheat.php\">
Add new cheat to the database.
<input type=\"hidden\" name=\"cheatID\" value=\"NULL\">
<input type=\"hidden\" name=\"author\" value=\"$authorID\">
<input type=\"hidden\" name=\"game\" value=\"$gameID\">
Game: $gameID<br />
Author: $authorID<br />
Cheat Title: <input type=\"text\" name=\"cheattitle\"><br>
Cheat Text:<br /><textarea name=\"cheattext\" rows=\"5\" cols=\"50\"></textarea><br />
<select name=\"db\" size=\"1\">
<option value=\"gamecube\" />GCN
<option value=\"gba\" />GBA
<option value=\"ps2\" />P2
<option value=\"xbox\" />Xbox
<option value=\"pc\" />PC
</select><input type=\"submit\" value=\"Add\" />
</form>
";
}
?>
addcheat.php
<?
$authorID = $_GET['authorID'];
$DBhost = "localhost";
$DBuser = "root";
$DBpass = "DELETED";
$DBName = $_GET['db'];
$cheattitle = $_GET['cheattitle'];
$cheattext = $_GET['cheattext'];
$author = $_GET['author'];
$game = $_GET['game'];
$table = "cheats";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$sqlquery = "INSERT INTO $table VALUES ('$cheatID','$cheattitle',$cheattext', CURDATE( ) ,'$author','$game')";
$results = mysql_query($sqlquery);
mysql_close();
print "<center><table border=\"0\" width=\"500\"><tr><td>";
print "<p><font face=\"verdana\" size=\"+0\"> <center><a href=\"index.php\">You just finished adding a cheat to the database. Click here to add another one.</a></td></tr></table>
</center></BODY></HTML>";
?>
(Note: this line: <input type=\"hidden\" name=\"cheatID\" value=\"NULL\"> is NULL because the MySQL sets it as a auto number.)
Note: This is a very basic script, mainly to see if it would work. There are a lot of unnessasary thing like the "\", but I will get to that later.
I have this same script working with other pages (add author, add game), but this one doesn't put it into MySQL.
Can anyone help me?
index.php
<?
$authorID = $_GET['authorID'];
$gameID = $_GET['game'];
echo ('
Search for a Author:
...
...
";
}
if (isset($game))
{
echo "
<form method=\"get\" action=\"addcheat.php\">
Add new cheat to the database.
<input type=\"hidden\" name=\"cheatID\" value=\"NULL\">
<input type=\"hidden\" name=\"author\" value=\"$authorID\">
<input type=\"hidden\" name=\"game\" value=\"$gameID\">
Game: $gameID<br />
Author: $authorID<br />
Cheat Title: <input type=\"text\" name=\"cheattitle\"><br>
Cheat Text:<br /><textarea name=\"cheattext\" rows=\"5\" cols=\"50\"></textarea><br />
<select name=\"db\" size=\"1\">
<option value=\"gamecube\" />GCN
<option value=\"gba\" />GBA
<option value=\"ps2\" />P2
<option value=\"xbox\" />Xbox
<option value=\"pc\" />PC
</select><input type=\"submit\" value=\"Add\" />
</form>
";
}
?>
addcheat.php
<?
$authorID = $_GET['authorID'];
$DBhost = "localhost";
$DBuser = "root";
$DBpass = "DELETED";
$DBName = $_GET['db'];
$cheattitle = $_GET['cheattitle'];
$cheattext = $_GET['cheattext'];
$author = $_GET['author'];
$game = $_GET['game'];
$table = "cheats";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$sqlquery = "INSERT INTO $table VALUES ('$cheatID','$cheattitle',$cheattext', CURDATE( ) ,'$author','$game')";
$results = mysql_query($sqlquery);
mysql_close();
print "<center><table border=\"0\" width=\"500\"><tr><td>";
print "<p><font face=\"verdana\" size=\"+0\"> <center><a href=\"index.php\">You just finished adding a cheat to the database. Click here to add another one.</a></td></tr></table>
</center></BODY></HTML>";
?>
(Note: this line: <input type=\"hidden\" name=\"cheatID\" value=\"NULL\"> is NULL because the MySQL sets it as a auto number.)