Jump to content

[SOLVED] Not Writing to Database?


Warptweet

Recommended Posts

For the below code, it says it's successful, but when I check my phpmyadmin for the database, it does not show any rows entered. So basically, it's not writing anything to the database! Does anyone know whats wrong with this code...?

 

if ($_GET['cmd'] == 'submit'){
if ($_GET['step'] == 'four'){

$creationname = $_POST['creationname'];
$creationdescription = $_POST['creationdescription'];
$iconlink = $_POST['iconlink'];
$uploadlink = $_POST['uploadlink'];
$uploadrand = $_POST['uploadrand'];
$uploadtype = $_POST['uploadtype'];
$uploadgenre = $_POST['uploadgenre'];
$uploadstyle = $_POST['uploadstyle'];

$con = mysql_connect("localhost","warp_gm","Forest77");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("warp_gm", $con);mysql_query("INSERT INTO pending_uploads (uploadname, uploaddescription, uploadicon, uploadlink, uploadtype, uploadgenre, uploadstyle) 
VALUES ('$creationname', '$creationdescription', '$iconlink', '$uploadlink$uploadrand', '$uploadtype', '$uploadgenre', '$uploadstyle')");

echo "Thank you for uploading your GM Content!</br><b>Your Submission will be reviewed within the next 24 hours.</b></br>If your submission does not appear to be accepted within 24 hours, either it may be denied as a faulty program, or our line of submissions are to great, which is not in compliance with letting each submission have a spot on the front page for approximately 1-3 days depending on traffic.</br>If you are positive your submission is virus free, then allow a maximum of 3 days to be accepted, if not, go to the \"contact\" page, and contact our services email.</br></br>Again, thank you for submitting!</br>-Warptweet";
}
}

 

In case you need to know what the previous page was for the $_POST stuff, here is the previous page...

 

if ($_GET['cmd'] == 'submit'){
if ($_GET['step'] == 'three'){
function generate_rand($l){
$c= "WARPTWEETwarptweet179SCscONon";
srand((double)microtime()*1000000);
for($i=0; $i<$l; $i++)
{
$rand.= $c[rand()%strlen($c)];
}
return $rand;
}

$uploaddir = "pending/";
$maxfilesize = 52428800; //1 megabyte
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$filetmpname = $_FILES['file']['tmp_name'];
$valid = array (".gm6",".gmd",".gmk",".gm5",".exe");
if ($filename) {
$error = "";
if ($filesize == 0) {
$error .= "You must select a file!.<br />";
}
$type = strtolower(strstr($filename, '.'));
if (!in_array($type, $valid)) {
$error .= "The submitted file may only be a .gm6, .gmd, .gmk, .gm5, or a .exe file.<br />";
}
if ($filesize>$maxfilesize) {
$error .= "The submitted file may not be larger than 50 Megabytes.<br />";
}
$randnum = generate_rand(10);
$randnum .= $type;
$file_exists = true;
while ($file_exists) {
if (file_exists("$uploaddir$randnum")) {
$randnum = generate_rand(10);
$randnum .= $type;
}else{
$file_exists = false;
}
}
if ($error == "") {
if (move_uploaded_file($filetmpname, "$uploaddir$randnum")) {
chmod("$uploaddir$randnum", 0644);
$creationname = $_POST['creationname'];
$creationdescription = $_POST['creationdescription'];

echo "Thank you! Please finish the last step to complete the upload!</br></br>

<form enctype=\"multipart/form-data\" action=\"?cmd=submit&step=four\" method=\"POST\">
              
Select which suits your Creation best: <select size=\"1\" name=\"uploadtype\">
<option selected>Playable/Game</option>
<option>Program/Tool</option>
</select>
<input type='hidden' name='creationname' value='$creationname'> 
<input type='hidden' name='creationdescription' value='$creationdescription'> 
<input type='hidden' name='iconlink' value='$iconlink'> 
<input type='hidden' name='uploadlink' value='$uploaddir'> 
<input type='hidden' name='uploadrand' value='$randnum'> 
<br>
      Select which genre suits your Creation best:
<select size=\"1\" name=\"uploadgenre\">
<option selected>Role Playing Game</option>
<option>Classical Game</option>
<option>Fan Game</option>
<option>Arcade Game</option>
<option>Multiple Minigames</option>
<option>Minigame</option>
<option>Puzzle Game</option>
<option>Sports Game</option>
<option>Computer Tool</option>
<option>Real Time Strategy</option>
<option>Online Multiplayer</option>
<option>Adventure Game</option>
<option>Mystery Game</option>
<option>Action Game</option>
<option>Other Genre</option>
<option>First Person Shooter</option>
</select><br>
       Select which idea suits your Creation best:
<select size=\"1\" name=\"uploadstyle\">
<option>Platform</option>
<option>Mech</option>
<option>Futuristic Gameplay</option>
<option>Computer Help</option>
<option>Drawing Program</option>
<option>Computer Program</option>
<option>Advanced Computering</option>
<option>Classic BoardGame</option>
<option>Classic Wormz</option>
<option>Classical Game</option>
<option>Classical Collection</option>
<option>Watching Simulation</option>
<option>Massively Multiplayer</option>
<option>Simply Online</option>
<option>Team Online</option>
<option>Online Roleplaying</option>
<option>FanGame</option>
<option>Metroid FanGame</option>
<option>Halo FanGame</option>
<option>3D Shooter</option>
<option>3D Simulation</option>
<option>3D Action</option>
<option>3D Game</option>
<option>Pick and Watch</option>
<option>God Power</option>
<option>Vehicular Game</option>
<option>Vehicular Combat</option>
<option>Racing Game</option>
<option>Interative Show</option>
<option>Maze Game</option>
<option>Vertical Scrolling Shooter</option>
<option>Horizontal Scrolling Shooter</option>
<option>Vertical Scrolling</option>
<option>Horizontal Scrolling</option>
<option>Traditional</option>
<option>Time Waster</option>
<option>Artillery</option>
<option>Educational</option>
<option>Soccer</option>
<option>Football</option>
<option>Baseball</option>
<option>Running</option>
<option>Cross Country</option>
<option>Music Based</option>
<option>Party Games</option>
<option>Mario FanGame</option>
<option>Zelda FanGame</option>
<option>Kirby FanGame</option>
<option>Stealth Tactics</option>
<option>Text Adventure</option>
<option>Pixel Style</option>
<option>Strategy WarGame</option>
<option>Turn-Based</option>
<option>Real-Time Tactical</option>
<option>Logical Solution Finding</option>
<option>Hack n Slash</option>
<option>Beat em Up</option>
<option>Competitive Fighting</option>
<option>Simulations</option>
<option>Economic Simulation</option>
<option>Government Simulation</option>
<option>City Building</option>
</select><br>
                                        
<input type=\"submit\" value=\"Continue to Step 4\" />
";
}
else
{
echo "Sorry, your submitted file could not be uploaded!";
} 
}else{
echo $error;
}
}else{
echo "No file was uploaded!";
}
}
}

Link to comment
Share on other sites

Change your mysql section to this:

 

con = mysql_connect("localhost","warp_gm","Forest77");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("warp_gm", $con) or die('Could not select db');
mysql_query("INSERT INTO pending_uploads (uploadname, uploaddescription, uploadicon, uploadlink, uploadtype, uploadgenre, uploadstyle) 
VALUES ('$creationname', '$creationdescription', '$iconlink', '$uploadlink$uploadrand', '$uploadtype', '$uploadgenre', '$uploadstyle')") or die ("Insert failed: " . mysql_error());

 

And make sure you change that password before going live :)

Link to comment
Share on other sites

Lol, thats a fake password I use for all of my testings. Forest77 you will see I use whenever displaying a password, I"m not that foolish! My real password is at least 10x that long (over 100 character on control panels) It's because I like forests, and 7 is my favorite number, so it's an obvious, easy to remember testing password.

 

Although, I please implore you to take Forest77 out anyways, please edit your post :)

 

Meh, I found the problem anyways :)

It was my database permissions not letting me write to the database.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.