Why does my php code does not update my MySQL database?
Here is my code
<?php
if ($HTTP_POST_VARS["name"] == "" || $HTTP_POST_VARS["course"] == "NONE" ||
$HTTP_POST_VARS["year"] == "NONE" || $HTTP_POST_VARS["idnumber"] == "")
{
echo "<h3> Error! You have not entered all required details. Pleaes try again. </h3>";
echo "<a href=' /new/csitorg.html'> Go back to Main page</a>";
}
else
{
echo "<p> Payment is made by <br>";
echo $HTTP_POST_VARS["idnumber"]. '<br>';
echo $HTTP_POST_VARS["name"]. '<br>';
echo $HTTP_POST_VARS["course"].' ';
echo $HTTP_POST_VARS["year"]. '<br>';
$idnumber = addslashes($HTTP_POST_VARS["idnumber"]);
$name = addslashes($HTTP_POST_VARS["name"]);
$course = addslashes($HTTP_POST_VARS["course"]);
$yearr = addslashes($HTTP_POST_VARS["year"]);
$firstsemfee = 0;
$secondsemfee = 0;
$shirtfee = 0;
$acqfee = 0;
@ $db = mysql_pconnect("localhost","root",...
..."mysql");
echo $db;
if(!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("csitorg");
$query = "insert into students values ('".$idnumber."', '".$name."','".$course."','".year."','"....
$result = mysql_query($query);
echo $query;
echo $result;
?>
all of the other things are already checked. May asked is there something that i need to do? Something to add in my code? I used XAMPP as a server and MySQL 5.
This is my table in MySQL Database
-------------- ------------ ------ ----- --------- -------
| Field | Type | Null | Key | Default | Extra |
-------------- ------------ ------ ----- --------- -------
| idnumber | char(6) | NO | PRI | NULL | |
| name | char(30) | NO | | NULL | |
| course | char(6) | NO | | NULL | |
| year | int(1) | NO | | NULL | |
| firstsemfee | tinyint(1) | NO | | NULL | |
| secondsemfee | tinyint(1) | NO | | NULL | |
| shirtfee | tinyint(1) | NO | | NULL | |
| acqfee | tinyint(1) | NO | | NULL | |
-------------- ------------ ------ ----- --------- -------
THANK YOU VERY MUCH!
Tags: