Click here to Skip to main content
15,891,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m making one webiste named online admission,
bt am uable to insert data there is no error in code bt dont know whtsa goig on with my code.
here is my code plz help me out


connection code is written in same file above the if condition !!

PHP
if(isset($_POST["submit"]))
{
$clgnm=$_POST['clgnm'];
$clgaddr=$_POST['clgaddr'];
$cid=$_POST['cid'];
$sid=$_POST['sid'];
$seat=$_POST['seat'];

$sql="Insert into college(ClgName,ClgAddrs,CourseId,SeatId,Seats) values
('$clgnm','$clgaddr',$cid,$sid,$seat)";

echo $sql;
$result=mysql_query($sql);
or die(mysql_error());
echo $result;
echo "inserted ";


}
Posted
Updated 25-Jul-15 7:43am
v3
Comments
Mohibur Rashid 25-Jul-15 13:03pm    
you are missing a ' in your sql statement.
look up mysql_real_escape_string as well as sql injection
Member 10011989 25-Jul-15 13:49pm    
thnks for pointing me out

1 solution

remove '' if cid insert numbers

PHP
$sql="Insert into college(ClgName,ClgAddrs,CourseId,SeatId,Seats) values
('$clgnm','$clgaddr',$cid,$sid,'$seat)";

and use or die(mysql_error()); to show error
like this

$result=mysql_query($sql)or die(mysql_error());
 
Share this answer
 
v2
Comments
Member 10011989 25-Jul-15 13:45pm    
its still not working!! yes i hve removed the quotes then also not inserted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900