chizu
01-03-2006, 08:09 PM
I have this script that is supossed to change the pet image to $image and the growth to '2' but for some reason it sets the image to '0' and doesn't do anything to the growth. I have rewriten the script 3 times and I just can't see what is wrong. Please tell me what I'm missing. Thanks in advance!
<?
//connection information
$db_name = "DBNAME";
$connection = mysql_connect('SERVER', 'NAME', 'PASS') or die($connection);
$db = mysql_select_db($db_name, $connection) or die("Couldn't select Database1.");
$connection2 = $connection;
//sets the growday
$growday = date("M d Y");
//selects pets that are ready to grow
$pet_sql = "SELECT * FROM starbits WHERE growday = '$growday' AND growth = '1'";
$pet_result = mysql_query($pet_sql);
if (mysql_num_rows($pet_result)) {
while ($pet = mysql_fetch_array($pet_result)) {
//set some variables so table can be updated
$petID = $pet['monopetID'];
$petimage = $pet['image'];
//set $image value
if ($petimage == 'baby_chari') {
$petimage = "chari";
}
if ($petimage == 'baby_flif') {
$petimage = "flif";
}
if ($petimage == 'baby_fool') {
$petimage = "fool";
}
if ($petimage == 'baby_kakineko') {
$petimage = "kakineko";
}
if ($petimage == 'baby_kijuu') {
$petimage = "kijuu";
}
if ($petimage == 'baby_swimo') {
$petimage = "swimo";
}
if ($petimage == 'baby_ghostling') {
$petimage = "ghostling";
}
if ($petimage == 'baby_tsuki') {
$petimage = "tsuki";
}
//start updating
$grow_sql = "UPDATE starbits SET image = '$petimage' AND growth = '2' WHERE monopetID = '$petID'";
$grow_result = mysql_query($grow_sql) or die("Error:" .mysql_error());
echo "Script Ran.";
}
}
//to make sure I didnt leave out any } or anything,
// and to double check the date
echo "<p>$growday";
?>
<?
//connection information
$db_name = "DBNAME";
$connection = mysql_connect('SERVER', 'NAME', 'PASS') or die($connection);
$db = mysql_select_db($db_name, $connection) or die("Couldn't select Database1.");
$connection2 = $connection;
//sets the growday
$growday = date("M d Y");
//selects pets that are ready to grow
$pet_sql = "SELECT * FROM starbits WHERE growday = '$growday' AND growth = '1'";
$pet_result = mysql_query($pet_sql);
if (mysql_num_rows($pet_result)) {
while ($pet = mysql_fetch_array($pet_result)) {
//set some variables so table can be updated
$petID = $pet['monopetID'];
$petimage = $pet['image'];
//set $image value
if ($petimage == 'baby_chari') {
$petimage = "chari";
}
if ($petimage == 'baby_flif') {
$petimage = "flif";
}
if ($petimage == 'baby_fool') {
$petimage = "fool";
}
if ($petimage == 'baby_kakineko') {
$petimage = "kakineko";
}
if ($petimage == 'baby_kijuu') {
$petimage = "kijuu";
}
if ($petimage == 'baby_swimo') {
$petimage = "swimo";
}
if ($petimage == 'baby_ghostling') {
$petimage = "ghostling";
}
if ($petimage == 'baby_tsuki') {
$petimage = "tsuki";
}
//start updating
$grow_sql = "UPDATE starbits SET image = '$petimage' AND growth = '2' WHERE monopetID = '$petID'";
$grow_result = mysql_query($grow_sql) or die("Error:" .mysql_error());
echo "Script Ran.";
}
}
//to make sure I didnt leave out any } or anything,
// and to double check the date
echo "<p>$growday";
?>