Jump to content

insertion problem


lunate

Recommended Posts

hi all ,

i m new to PHP and also in this forum.

please check outthe following code ,specially "query" and point out my errors and also help me to understand and solve it.

i have a table STD in mysql .(rollno int , name char(25) )

 

i create a simple HTML page.

 

<body><h2 align="center" > Student Entry </h2>

<form action="test_insertion.php" method="post">

<table border="2" align="center">

<tr>

<td>Roll No :</td>

<td><input type="text" name="rn" />

</td></tr>

<tr>

<td>Student Name :</td>

<td>

<input type="text" name="sn" /></td>

</tr>

 

</table>

<br />

<center>

<input type="submit" value="Submit" />

</center>

</form>

</body>

 

 

then i write a small PHP script as.

 

<body><?php

$rn=$_POST['rn'];

$sn=$_POST['sn'];

echo $rn ;

echo $sn;

$conn=mysql_connect("localhost","sec","sec");

$db=mysql_select_db("mysql",$conn);

 

$query=mysql_query("insert into std (rollno , name) values ($rn , $nm )" , $conn);

while ($res=mysql_fetch_row($query))

echo $res[0] ." " .$res[1] ."<br>";

 

?></body>

 

please help me .

Link to comment
https://forums.phpfreaks.com/topic/48914-insertion-problem/
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.