Trying to make pet registration form. When i choose color/gender/name than click register it sends the pet information to the table. But for the second part i cant figure out why it comes up with error fetch_aray is a invalid argument.
confirm.php has my connecting information and its all correct.
The table the userpet information gets sent to is "pets."
Than im trying to take the base stats of the pet and send it to the users table "pets" when clicking register. The base stats of the pet are located in the table "pettable".
Code:<?php include('confirm.php'); //test to see if username is alphanumeric $test=$_POST[pet_name]; if(!eregi(("[^A-Za-z0-9]"),$test)){ //test for duplicate names $query="SELECT * FROM pets WHERE pet_name ='$_POST[pet_name]'"; $result=mysql_query($query); $num=mysql_num_rows($result); if ($num == 0){ //get rid of all html from hackers $name=strip_tags($_POST['pet_name']); $color=$_POST['pet_color']; $gender=$_POST['pet_gender']; $species=$_POST['pet_species']; //insert data into database $sql="INSERT INTO pets SET pet_name='$name',pet_color='$color',pet_gender='$gender', species_id='$species'"; $result=mysql_query($sql); } //select stats from pet table $query2 = "SELECT * FROM pettable petatk ='$pet_atk',petdef='$pet_def' WHERE petname='$species' "; $result2 = mysql_query($query2); $row = mysql_fetch_array($result2); //if pet stats are in table update players pet table when registering if($row == 1){ $sql3="UPDATE * FROM pets SET pet_atk='$pet_atk',petdef='$pet_def' WHERE petname='$species'"; $result3=mysql_query($sql3); //take them to page for having succesfully created pet header("Location:newpet.php"); }else{ echo "Not found in our database"; } }else{ header("Location:usernametaken.html"); } ?>


LinkBack URL
About LinkBacks
Reply With Quote

