Here is my code for entering data into the database
<?php
ini_set("display_errors",false);
$link = mysql_connect('mysql5.000webhost.com', 'a9634375_dragons', 'samantha8',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'";
$queryb = "DELETE FROM er WHERE code='$key'";
$queryc = "DELETE FROM eggs WHERE code='$key'";
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/view/'.$hey.''));
$hrsleft = $data['dragons'][$hey]['hoursleft'];
$hatch = $data['dragons'][$hey]['hatch'];
if ($hrsleft < 96) {
$query3 = "INSERT INTO er(code) VALUES('$hey')";
mysql_query($query3);
echo 'Dragon has been entered into the ER.<br>';
}
else
{
if (! $hatch) {
$query4 = "INSERT INTO eggs(code) VALUES('$hey')";
mysql_query($query4);
echo 'Egg has been entered into the Nest.<br>';
}
else
{
$query2 = "INSERT INTO hatch(code) VALUES('$hey')";
mysql_query($query2);
echo 'Hatchling has been entered into the Nursery.<br>';
}
}
}
?>
My table is simply set up with three fields
er
egg
hatch
What am I doing wrong?
Thank you in advance!