PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
<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>";
}
?>
<?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>';
}
}
}
?>
silverDragonTears
Dragon Code Clicks
aA7V
PHP Error Message
Warning: Invalid argument supplied for foreach() in /home/a9634375/public_html/ScrollRead.php on line 46
Free Web Hosting
hjkP
PHP Error Message
Warning: Invalid argument supplied for foreach() in /home/a9634375/public_html/ScrollRead.php on line 46
Free Web Hosting
B2Z7
PHP Error Message
Warning: Invalid argument supplied for foreach() in /home/a9634375/public_html/ScrollRead.php on line 46
Free Web Hosting
2gPZ
PHP Error Message
Warning: Invalid argument supplied for foreach() in /home/a9634375/public_html/ScrollRead.php on line 46
Free Web Hosting
G57h
PHP Error Message
Warning: Invalid argument supplied for foreach() in /home/a9634375/public_html/ScrollRead.php on line 46
Free Web Hosting
GsW6
PHP Error Message
Warning: Invalid argument supplied for foreach() in /home/a9634375/public_html/ScrollRead.php on line 46
Free Web Hosting
Check all/Uncheck all
So it lists all the dragon codes on my scroll with a check box to add them to the db, but under each code it has the warning. Then I click all checkboxes to add the codes to the db and it says Error on line 30: Query execution was interrupted
I did it again and it said this
Notice: Undefined index: dragons in /home/a9634375/public_html/ScrollReadGet.php on line 38