shams Posted April 16, 2006 Share Posted April 16, 2006 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? Quote Link to comment Share on other sites More sharing options...
shortj75 Posted April 16, 2006 Share Posted April 16, 2006 try this [code]$query="INSERT INTO student4(id,name,class,mark)VALUES ('NULL', 'zubair', 'second', '500')";$rt=mysql_query($query);[/code] Quote Link to comment Share on other sites More sharing options...
shams Posted April 16, 2006 Author Share Posted April 16, 2006 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')"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.