Jump to content

Archived

This topic is now archived and is closed to further replies.

shams

code to insert values in mysql table?

Recommended Posts

hi,
This is the code to insert the valuse to mysql but doesn't work:
<html>
<body>
<?php
$db = mysql_connect("localhost", "root", "******");
mysql_select_db("mydb",$db);
$query="INSERT INTO student4 VALUES (NULL, "zubair", "second", 500)";
$rt=mysql_query($query);
echo mysql_error();

if($rt){echo " Command is successful ";}
else {echo " Command is not successful ";}
?>
</html>
</body>
and this is the student4 table:
| id | name | class | mark |
+----+---------+-------+------+
| 1 | shakeel | first | 500 |
+----+---------+-------+------+
1 row in set (0.05 sec)
any help please?

Share this post


Link to post
Share on other sites
try this
[code]
$query="INSERT INTO student4(id,name,class,mark)VALUES ('NULL', 'zubair', 'second', '500')";
$rt=mysql_query($query);
[/code]

Share this post


Link to post
Share on other sites
hi shortj75,
thanks for your hint, your posted code works, then i tried this one, this was also successfull:
$query="INSERT INTO student4 VALUES ('NULL', 'nabeel', 'fifth', '900'),('NULL', 'khalid', 'sixth', '1000')";

Share this post


Link to post
Share on other sites

×

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.