Code not adding to database
Posted: Wed Oct 06, 2010 11:43 am
I run a fansite and I am trying to add users dragon codes to the database (kinda like an adoptable site). Here is the form to add ur dragon's.... I can pull up the user's scroll and it appears that they add but when i look in the db there is nothing, nor on my view page.
Here is ScrollRead.php
And here is ScrollReadGet.php which adds the dragon codes to the db
Any help is appreciated.
Thanks
Code: Select all
<center><form name="input" action="ScrollRead.php" method="post">
Scroll Name:
<input type="text" name="user" maxlength="50" size="15"/>
<input type="submit" value="Read Scroll" />
</form></center>
<?php
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("a9634375_dragons") or die(mysql_error());
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM egg ORDER by rand() LIMIT 100")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
// Print out the contents of the entry
echo "<a href=\"http://dragcave.net/view/".$row['code'] . " \" target=\"view\"><img src=\"http://dragcave.net/image/".$row['code'] . " .gif\"></a>";
}
?>Code: Select all
<script type='text/javascript'>
checked=false;
function checkAll () {
var aa= document.getElementById('lomp');
if (checked == false)
{
checked = true
}
else
{
checked = false
}
for (var i =0; i < aa.elements.length; i++)
{
aa.elements[i].checked = checked;
}
}
</script>
<form name="form1" id="lomp" method="get" action="ScrollReadGet.php">
<?php
ini_set("display_errors",true);
$fdd = $_POST['user'];
$user = str_replace(" ","%20","$fdd");
echo ''.$fdd.'';
echo '<input type=hidden value="'.$user.'" name=user>';
$young = unserialize(file_get_contents('http://www.dragcave.net/api/samantha8/serialize/user_young/'.$user.''));
foreach($young['errors'] as $error) {
if($error[0] == 3) {echo '<center>Sorry, we were unable to locate that scroll.</center>'; return;}
}
foreach($young['errors'] as $error) {
if($error[0] == 4) {echo '<center>Sorry, this user has no dragons.</center>'; return;}
}
echo '<table border="0"><tr><td></td><td>Dragon</td><td>Code</td><td>Clicks</td></tr>';
foreach ($young['dragons'] as $key => $value) {
$data = unserialize(file_get_contents('http://www.dragcave.net/api/samantha8/serialize/view/'.$key));
echo '<tr><td><center><br><input type="checkbox" name="checkboxes[]" value="'.$key.'" border="0"></a></center></td>';
echo '<td><center><a href="http://www.dragcave.net/view/'.$key.'"><img src="http://www.dragcave.net/image/'.$key.gif.'" border="0"></a></center></td>';
echo '<td><center>'.$key.'</center></td>';
foreach ($data['clicks'] as $help => $me) {
echo '<td><center>'.$help.'</center></td></tr>';
}
}
?>
</table>
<table border="0"><tr><td><input type='checkbox' name='checkz' onClick='checkAll();'>Check all/Uncheck all</td></tr></table>
<br><br><input type="submit" name="Submit" value="Add Dragons">Code: Select all
<?php
ini_set("display_errors",true);
$link = mysql_connect('', '', '', true); if (!$link) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("a9634375_dragons") or die(mysql_error());
$ids=$_GET['checkboxes'];
$user = $_GET['user'];
$young = unserialize(file_get_contents('http://www.dragcave.net/api/samantha8/serialize/user/'.$user.''));
foreach ($young['dragons'] as $key => $value) {
$querya = "DELETE FROM hatch WHERE code='$key'" or die(mysql_error());
$queryb = "DELETE FROM er WHERE code='$key'" or die(mysql_error());
$queryc = "DELETE FROM egg WHERE code='$key'" or die(mysql_error());
mysql_query($querya);
mysql_query($queryb);
mysql_query($queryc);
}
echo '<br>Dragons updated.<br>';
echo 'Dragons now entered:<br>';
foreach ($ids as $hey) {
echo '<br><a href="http://www.dragcave.net/view/'.$hey.'" target="frame1"><img src="http://www.dragcave.net/image/'.$hey.'.gif" border="0"></a> ';
$data = unserialize(file_get_contents('http://www.dragcave.net/api/samantha8/serialize/'.$hey.''));
$hrsleft = $data['dragons'][$hey]['hoursleft'];
$hatch = $data['dragons'][$hey]['hatch'];
if ($hrsleft < 96) {
$query3 = "INSERT INTO er(code) VALUES('$hey')" or die(mysql_error());
mysql_query($query3);
echo 'Dragon has been entered into the ER.<br>';
}
else
{
if (! $hatch) {
$query4 = "INSERT INTO egg(code) VALUES('$hey')" or die(mysql_error());
mysql_query($query4);
echo 'Egg has been entered into the Nest.<br>';
}
else
{
$query2 = "INSERT INTO hatch(code) VALUES('$hey')" or die(mysql_error());
mysql_query($query2);
echo 'Hatchling has been entered into the Nursery.<br>';
}
}
}
?>Thanks