unable to insert value into table

Status
Not open for further replies.

jweavers

New Member
Messages
11
Reaction score
0
Points
1
This is my sample code to check, whether database inserted into table or not.

Code:
<?php include('db.php');
if ($bd) {


  $SQL = "INSERT INTO test(name) VALUES('ravi')";


     $result = mysql_query($SQL,$bd);


     mysql_close($bd);
     print "Records added to the database";
     print $result;
    }
    else 
      {
        print "Database NOT Found ";
     mysql_close($bd);
     }
     ?>

Above code prints Records added to the database but, when I'm verifying those value in phpMyAdmin, then table always shows 0 rows selected. I don't know, where those values got inserted. It's not even showing any error. Please help me.
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
I'm not sure why phpMyAdmin would be doing what it -sounds- like it's doing, but it seems like it might be caching the results and not actually re-running the query. I checked on the server itself, and it definitely shows 3 rows added to the table:

mysql> select * from test;
+----+------+
| id | name |
+----+------+
| 1 | ravi |
| 2 | ravi |
| 3 | ravi |
+----+------+
3 rows in set (0.00 sec)

Not sure why phpmyadmin isn't showing these, but it is definitely working at least.
 

jweavers

New Member
Messages
11
Reaction score
0
Points
1
I'm not sure why phpMyAdmin would be doing what it -sounds- like it's doing, but it seems like it might be caching the results and not actually re-running the query. I checked on the server itself, and it definitely shows 3 rows added to the table:



Not sure why phpmyadmin isn't showing these, but it is definitely working at least.


Thanks for your reply, Later I used mysql_error() function to figure out, what's going on. Then, it raise error that, database not selected. Then, I included small code, which something like mysql_db_select('dbname'). And, then it start showing value into table. Nevertheless, thanks for your reply !!
 
Status
Not open for further replies.
Top