Jump to content

php problems


Renlok

Recommended Posts

ive made a character creation page for a thing im "tying to create" but i doesnt insert the id of the charater type.

heres the codes
members.php part:
[code]
<form name="pets" method="post" action="http://www.we-link.co.uk/roe/adopt.php">';
$roequery = mysql_query("SELECT * FROM roetypes");
$roetypeheader = "<table width=\"250\" border=\"0\">";
while($roetype = mysql_fetch_array($roequery))
{
$image = $roetype['image'];
$name = $roetype['name'];
$roetypemain .=<<<EOD
  <tr>
    <td><img src="http://we-link.co.uk/roe/images/$image" alt="$name"></td>
    <td><label>
    <input type="radio" name="RadioGroup1" value="$name">
  $name</label>
</td>
  </tr>
EOD;
}
$roetypefooter = "</table>";
$roetypetable =<<<ROE
$roetypeheader
$roetypemain
$roetypefooter
ROE;
echo $roetypetable;
echo '<input type="submit" name="Submit" value="Adopt"></form>';
[/code]

adopt.php
[code]
$pet = $_POST['RadioGroup1'];
echo '<center>You have chosen '.$pet;
$petquery = mysql_query("SELECT * FROM roetypes WHERE name='$pet'");
$petdata = mysql_fetch_array($petquery);
$image = $petdata['image'];
echo "<br><img src=\"http://we-link.co.uk/roe/images/$image\" alt=\"$pet\"><p>";
$naming =<<<EOD
<form name="adoptpet1" method="post" action="http://www.we-link.co.uk/roe/adopt2.php">
  <p>
  <input type="hidden" name="pettype" value="$pet">
    <label>
    <input type="text" name="petname">
    </label>
  </p>
  <input type="submit" name="Submit" value="Accept Name">
</form>
EOD;
echo "<p>Name your new $pet<br>$naming </center>";
[/code]

adopt2.php
[code]
$pettype = $_POST['pettype'];
$petname = $_POST['petname'];
$idquery = mysql_query("SELECT * FROM roetypes WHERE name='$pettype'");
$idresult = mysql_fetch_array($idquery);
echo "<center>Congratulations you now have you very own $pet named $petname<br><a href=\"http://www.we-link.co.uk/roe/members.php\">continue to your roe page.</a></center>";
$petquery = mysql_query("INSERT into roe (roename, userid, type) values ('$petname', '$username', '$idresult')");
[/code]

thanks for any help, and merry christmas.
Link to comment
https://forums.phpfreaks.com/topic/31786-php-problems/
Share on other sites

Merry Christmas
Dont work too hard on this today, afterall, it is Christmas Day (I am in the UK)

But anyway

Try using a Manual Debug System

First of all, at the top of your script add this line of code

error_reporting(2047);

then thoughout your script
echo little notes to yourself

For Example

echo "ID is ".$id."<br />\n";

And find out when the $id value is empty

When you find out where it is empty, it is easier to find out why

Also
With using the error_reporting(2047) it will say
"Undified variable"
If you have that, then you might have a typo somewhere, which is storing the variable value else where.
Link to comment
https://forums.phpfreaks.com/topic/31786-php-problems/#findComment-147489
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.