Hi All,
I'm trying to insert a record into a MYSQL table and I keep getting a File Download window comes up and asks me if I want to open the file or save it. I opened it once to see what its trying to download and its just the PHP file with the code in it. I researched the internet and found that the code is the same as everyone elses and I even tried rewriting it using another example and I still get the same thing. I'm starting to feel like it may not be the code but a setting I'm not familair with enough to fix myself. Any help will be appreciated.
***********************************************
My PHP Code:
<?php
mysql_connect('127.0.0.1','root','') or die('Could not connect to localhost');
mysql_select_db('VMMT204mc') or die('Could not select to Database');
echo "1 record added";
If(array_key_exists('type_submit', $_POST))
{
$query="SELECT MAX(TypeID) FROM tblType";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$TypeID = $row['MAX(TypeID)'] +1;
}
mysql_query("INSERT INTO tblType(TypeId, TypeName,StateAbbr) VALUES($TypeID,'$_POST[TypeName]')");
echo "1 record added";
}
If(array_key_exists('shop_submit', $_POST))
{
$query="SELECT MAX(ShopID) FROM tblShop";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$ShopID = $row['MAX(ShopID)'] +1;
}
mysql_query("INSERT INTO tblShop(ShopId, ShopName,ShopNumber) VALUES($ShopID,'$_POST[ShopName]','$_POST[ShopNumber]')");
echo "1 record added";
}
If(array_key_exists('make_submit', $_POST))
{
$query="SELECT MAX(MakeID) FROM tblMake";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$MakeID = $row['MAX(MakeID)'] +1;
}
mysql_query("INSERT INTO tblMake(MakeId, MakeName) VALUES($MakeID,'$_POST[MakeName]')");
echo "1 record added";
}
If(array_key_exists('model_submit', $_POST))
{
$query="SELECT MAX(ModelID) FROM tblModel";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$ModelID = $row['MAX(ModelID)'] +1;
}
mysql_query("INSERT INTO tblModel(ModelId,MakeId, ModelName) VALUES($ModelID,'$_POST [MakeId]','$_POST[ModelName]')");
echo "1 record added";
}
If(array_key_exists('Noticetype_submit', $_POST))
{
$query="SELECT MAX(NoticetypeID) FROM tblNoticetype";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$NoticetypeID = $row['MAX(NoticetypeID)']+1;
}
mysql_query("INSERT INTO tblNoticetype(NoticetypeId,NoticetypeName) VALUES($NoticetypeID,'$_POST [NoticetypeName]')");
echo "1 record added";
}
If(array_key_exists('Base_submit', $_POST))
{
$query="SELECT MAX(BaseID) FROM tblBase";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$BaseID = $row['MAX(BaseID)'] +1;
}
mysql_query("INSERT INTO tblBase(BaseId,BaseName,BaseAbbr) VALUES($BaseID,'$_POST [BaseName]','$_POST[BaseAbbr]')");
echo "1 record added";
}
If(array_key_exists('rank_submit', $_POST))
{
$query="SELECT MAX(RankID) FROM tblRank";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$RankID = $row['MAX(RankID)'] +1;
}
mysql_query("INSERT INTO tblRank(RankId,RankName, RankAbbr) VALUES($RankID,'$_POST [RankName]','$_POST[RankAbbr]')");
echo "1 record added";
}
?>
*************************************************
HTML Form code:
<html>
<body>
<form action="insert.php" method="post">
<B><Font size =5>New Vehicle Type</Font></B><BR><BR>
Enter vehicle type: <input type="text" name="TypeName" />
<input type= "submit" name = "Type_submit" value = "Save"
<BR>
<BR>
<BR>
<B><Font size =5>New Shop</Font></B><BR><BR>
Enter shop: <input type="text" name="ShopName" />
<input type= "submit" name = "Shop_submit" value = "Save"
<BR>
<BR>
<BR>
<B><Font size =5>New Make</Font></B><BR><BR>
Enter vehicle make: <input type="text" name="MakeName" />
<input type= "submit" name = "Make_submit" value = "Save"
<BR>
<BR>
<BR>
<B><Font size =5>New Model</Font></B><BR><BR>
<?php
mysql_connect('127.0.0.1','root','') or die('Could not connect to localhost');
mysql_select_db('VMMT204mc') or die('Could not select to Database');
$result = mysql_query("SELECT * FROM tblMake");
Select Vehicle Make:<select name='Name'>
while($row=mysql_fetch_array($result,MYSQL_ASSOC))
{
echo '<option value="'.$row['MakeId'].'"'.'>'.$row['Makename'].'</Option>';
}
?>
</select>
Enter vehicle Model: <input type="text" name="ModelName" />
<input type= "submit" name = "Model_submit" value = "Save"
</form>
</body>
</html>
I'm trying to insert a record into a MYSQL table and I keep getting a File Download window comes up and asks me if I want to open the file or save it. I opened it once to see what its trying to download and its just the PHP file with the code in it. I researched the internet and found that the code is the same as everyone elses and I even tried rewriting it using another example and I still get the same thing. I'm starting to feel like it may not be the code but a setting I'm not familair with enough to fix myself. Any help will be appreciated.
***********************************************
My PHP Code:
<?php
mysql_connect('127.0.0.1','root','') or die('Could not connect to localhost');
mysql_select_db('VMMT204mc') or die('Could not select to Database');
echo "1 record added";
If(array_key_exists('type_submit', $_POST))
{
$query="SELECT MAX(TypeID) FROM tblType";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$TypeID = $row['MAX(TypeID)'] +1;
}
mysql_query("INSERT INTO tblType(TypeId, TypeName,StateAbbr) VALUES($TypeID,'$_POST[TypeName]')");
echo "1 record added";
}
If(array_key_exists('shop_submit', $_POST))
{
$query="SELECT MAX(ShopID) FROM tblShop";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$ShopID = $row['MAX(ShopID)'] +1;
}
mysql_query("INSERT INTO tblShop(ShopId, ShopName,ShopNumber) VALUES($ShopID,'$_POST[ShopName]','$_POST[ShopNumber]')");
echo "1 record added";
}
If(array_key_exists('make_submit', $_POST))
{
$query="SELECT MAX(MakeID) FROM tblMake";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$MakeID = $row['MAX(MakeID)'] +1;
}
mysql_query("INSERT INTO tblMake(MakeId, MakeName) VALUES($MakeID,'$_POST[MakeName]')");
echo "1 record added";
}
If(array_key_exists('model_submit', $_POST))
{
$query="SELECT MAX(ModelID) FROM tblModel";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$ModelID = $row['MAX(ModelID)'] +1;
}
mysql_query("INSERT INTO tblModel(ModelId,MakeId, ModelName) VALUES($ModelID,'$_POST [MakeId]','$_POST[ModelName]')");
echo "1 record added";
}
If(array_key_exists('Noticetype_submit', $_POST))
{
$query="SELECT MAX(NoticetypeID) FROM tblNoticetype";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$NoticetypeID = $row['MAX(NoticetypeID)']+1;
}
mysql_query("INSERT INTO tblNoticetype(NoticetypeId,NoticetypeName) VALUES($NoticetypeID,'$_POST [NoticetypeName]')");
echo "1 record added";
}
If(array_key_exists('Base_submit', $_POST))
{
$query="SELECT MAX(BaseID) FROM tblBase";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$BaseID = $row['MAX(BaseID)'] +1;
}
mysql_query("INSERT INTO tblBase(BaseId,BaseName,BaseAbbr) VALUES($BaseID,'$_POST [BaseName]','$_POST[BaseAbbr]')");
echo "1 record added";
}
If(array_key_exists('rank_submit', $_POST))
{
$query="SELECT MAX(RankID) FROM tblRank";
$result = mysql_query($query);
while ($row=mysql_fetch_assoc($result))
{
$RankID = $row['MAX(RankID)'] +1;
}
mysql_query("INSERT INTO tblRank(RankId,RankName, RankAbbr) VALUES($RankID,'$_POST [RankName]','$_POST[RankAbbr]')");
echo "1 record added";
}
?>
*************************************************
HTML Form code:
<html>
<body>
<form action="insert.php" method="post">
<B><Font size =5>New Vehicle Type</Font></B><BR><BR>
Enter vehicle type: <input type="text" name="TypeName" />
<input type= "submit" name = "Type_submit" value = "Save"
<BR>
<BR>
<BR>
<B><Font size =5>New Shop</Font></B><BR><BR>
Enter shop: <input type="text" name="ShopName" />
<input type= "submit" name = "Shop_submit" value = "Save"
<BR>
<BR>
<BR>
<B><Font size =5>New Make</Font></B><BR><BR>
Enter vehicle make: <input type="text" name="MakeName" />
<input type= "submit" name = "Make_submit" value = "Save"
<BR>
<BR>
<BR>
<B><Font size =5>New Model</Font></B><BR><BR>
<?php
mysql_connect('127.0.0.1','root','') or die('Could not connect to localhost');
mysql_select_db('VMMT204mc') or die('Could not select to Database');
$result = mysql_query("SELECT * FROM tblMake");
Select Vehicle Make:<select name='Name'>
while($row=mysql_fetch_array($result,MYSQL_ASSOC))
{
echo '<option value="'.$row['MakeId'].'"'.'>'.$row['Makename'].'</Option>';
}
?>
</select>
Enter vehicle Model: <input type="text" name="ModelName" />
<input type= "submit" name = "Model_submit" value = "Save"
</form>
</body>
</html>