Query insert database

After we create database reseller, we can insert data to database.

For insert data at php we must query insert

mysql_query( ”
insert into database_name
set query that will execute
“) or error( mysql_error() );

dont forget “” inside ( )

Example at php

mysql_query( ”
insert into reseller set
username = ‘$_POST[username]‘,
passwd = ‘$_POST[passwd]‘,
name = ‘$_POST[name]‘,
email = ‘$_POST[email]‘”) or error( mysql_error() );

$_POST[username] is form input text with name username with method=”post

Example 2

mysql_query( ”
insert into reseller set
username = ‘johnson’,
passwd = ‘johnson$32#’,
name = ‘Johnson Gunawan’,
email = ‘Johnson@yahoo.com’
“) or error( mysql_error() );

, used at first and one before last query that will execute
At last query that will execute not use ,

Example 2 result :
It will insert database reseller :

  • field username with value johnson
  • field passwd with value johnson$32#
  • field name with value Johnson Gunawan
  • field email with value Johnson@yahoo.com
Leave a comment

1 Comments.

  1. Thanks your message has very much helped me:)

Leave a Reply


[ Ctrl + Enter ]