The problems!!!
| From: | Maurice Manurung | Date: | Wed, 27 Sep 2000 07:16:12 +0000 |
| Subject: | The problems!!! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-17714@lists.php.net to get a copy of this message | ||
I have a database "data" and table "dbase". "dbase" have a field that
content of "age"
by this scripts I want to find if any age that I entered with $age1 and
$age2 matched with the age in the table "age "
The problem is if I enter only one right age, then it jump into " Cannot
choose database"
can you tell what's wrong w/ these scripts ????
here it is the script of file "formbase.html"
<HTML>
<HEAD>
<TITLE>Formbase</TITLE>
</HEAD>
<BODY>
<FORM method="post" action="insert2.php3">
Enter the age you want to check :
<Input type="text" name="age1" ></Input><BR><BR>
<Input type="text" name="age2" ></Input><BR>
<Input type="submit" name"check" value="check it
!!"></Input>
</FORM>
</BODY>
</HTML>
here it is the scripts of insert2.php3
<HTML>
<HEAD>
<TITLE>insert.php3</TITLE>
</HEAD>
<BODY>
<?
// Connect to the database
$koneksi=mysql_connect("localhost","root","")
or die ("Cannot connect to the database.");
// Choose database
$db=mysql_select_db("data",$koneksi)
or die ("Cannot choose database.");
//Pickthe data that have $age1 dan $age2
$sql=mysql_query("select age from dbase", $koneksi);
//View the result
$row=mysql_num_rows($sql);
$i=0;
while ($i<$row)
{
$hasil=mysql_result($sql,$i,"age");
$i++;
}
if ($hasil==$age1 || $hasil==$age2)
{
echo "The age you have entered matched with database";
}
else
{
echo "The age not matched";
}
?>
</BODY>
</HTML>