• qim

    (@qim)


    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

    (@qim)

    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

    (@qim)

    Thank you. I solved it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘php simple code’ is closed to new replies.