Click here to Skip to main content
15,885,720 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
<?php

    //connecting to database

    $db = mysql_connect("localhost","root","youmint") or die(mysql_error());



    //selecting our database

    $db_select = mysql_select_db("Nikhil", $db) or die(mysql_error());



    //Retrieving data from html form

    $firstname = $_POST['firstname'];

    $lastname = $_POST['lastname'];

    $mobilenumber = $_POST['mobilenumber'];

    $age = $_POST['age'];

    $gender = $_POST['gender'];

    $address = $_POST['address'];

    $city = $_POST['city'];

    $pin = $_POST['pin'];



    //for mysql injection (security reasons)

    $firstname1 = mysql_real_escape_string($firstname1);

    $lastname1 = mysql_real_escape_string($lastname1);

    $mobilenumber1 = mysql_real_escape_string($mobilenumber1);

    $age1 = mysql_real_escape_string($age1);

    $gender1 = mysql_real_escape_string($gender1);

    $address1 = mysql_real_escape_string($address1);

    $city1 = mysql_real_escape_string($city1);

    $pin1 = mysql_real_escape_string($pin1);





    // inserting data into database

    $register = mysql_query( "INSERT INTO Registration ( firstname , lastname , mobilenumber , age , gender , address , city , pin ) VALUES ( '$firstname' , '$lastname', '$mobilenumber' , '$age' , '$gender' , '$address' , '$city' , '$pin' ");

    if($register) {

    echo "Registration Successfull";

    }

    else {

    echo "There was an error";

    }

    ?>




it is displaying there was an error again and again ! Help guys!
Posted
Comments
Graham Breach 27-Jun-13 8:07am    
You should try using mysql_error() again to find out what the error is. From a quick glance at your query, it looks like you are missing a closing ")" at the end of the list of values.
nkhldhar 27-Jun-13 8:25am    
can u tell me how to link a corresponding html form to this php file

1 solution

C#
$register = mysql_query( "INSERT INTO Registration ( firstname , lastname , mobilenumber , age , gender , address , city , pin ) VALUES ( '$firstname' , '$lastname', '$mobilenumber' , '$age' , '$gender' , '$address' , '$city' , '$pin') ");



Corrected. You missed a ')' as the error clearly says.....
 
Share this answer
 
Comments
nkhldhar 27-Jun-13 8:30am    
as i said i have an html form wid this for getting the deatails how do i connect these with each other in order to save data into db
bbirajdar 27-Jun-13 8:37am    
http://php.about.com/od/learnphp/qt/php_with_html.htm

http://www.w3schools.com/php/php_mysql_connect.asp

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900