Title: php simple code
Last modified: August 20, 2016

---

# php simple code

 *  [qim](https://wordpress.org/support/users/qim/)
 * (@qim)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/php-simple-code/)
 * I’m trying to learn about php and copied the following from the net:
 *     ```
       <?php
        // Connects to your Database
        mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()); mysql_select_db("Database_Name") or die(mysql_error());
        mysql_query("INSERT INTO tablename VALUES ( 'Bill', 29, 'Ford' ), ( 'Mike', 16, 'Beetle' ), ( 'Alisa', 36, 'Van' )");  Print "Your table has been populated";
        ?>
       ```
   
 * I have asimple table called ‘user’ with 2 fields called also ‘user’ and ‘password’
 * when I run the code it does not add new record to the table, even though the 
   connection is fine as I have another php code to see the table. Can you help 
   me find the mistake, please?
 *     ```
       <?php
   
        mysql_connect("localhost", "pintotou_camilo", "+++++++") or die(mysql_error());
        mysql_select_db("pintotou_agents") or die(mysql_error()); 
   
        mysql_query("INSERT INTO user VALUES ( 'Fernando','Ford' ), ( 'Mike' ,Beetle' )" );
   
        Print "Your table has been populated"; 
   
       ?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [qim](https://wordpress.org/support/users/qim/)
 * (@qim)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/php-simple-code/#post-3601380)
 * I’ve changed the line below but it still does not work:
 *     ```
       mysql_query("INSERT INTO user ('user', 'password') VALUES( 'Fernando','Ford' ), ( 'Mike' ,Beetle' )" );
       ```
   
 *  Thread Starter [qim](https://wordpress.org/support/users/qim/)
 * (@qim)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/php-simple-code/#post-3601386)
 * Thank you. I solved it!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘php simple code’ is closed to new replies.

 * 2 replies
 * 1 participant
 * Last reply from: [qim](https://wordpress.org/support/users/qim/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/php-simple-code/#post-3601386)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
