0

The Data is being correctly displayed so there is no issue with passing of data from the form hence there is an error i am unable to find.

<?php

$connect = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("property", $connect);

/* if(isset($_POST['name'],$_POST['email'],$_POST['comments'])){ */
$rs = $_POST['rs'];
$cr = $_POST['cr'];
$locality = $_POST['locality'];
$br = $_POST['br'];
$bth = $_POST['bth'];
$fr = $_POST['fr'];
$flr = $_POST['flr'];
$tflr = $_POST['tflr'];
$bu = $_POST['bu'];
$park = $_POST['park'];
$af = $_POST['af'];
$comment = $_POST['comment'];

$query = "INSERT INTO property(id,sale/rent,com/res,locality,bedroom,bathroom,furnished_status,
            floor,total floors,builtup/superbuiltup,includes_park,available_from,details) 
          VALUES('','$rs','$cr','$locality','$br','$bth','$fr','$flr','$tflr','$bu','$park','$af','$comment')";

mysql_query($query, $connect);

echo $rs;
echo "<br>";
echo $cr;
echo "<br>";
echo $locality;
echo "<br>";
echo $br;
echo "<br>";
echo $bth;
echo "<br>";
echo $fr;
echo "<br>";
echo $flr;
echo "<br>";
echo $tflr;
echo "<br>";
echo $bu;
echo "<br>";
echo $af;
echo "<br>";
echo $comment;
echo "<br>";


/*
  header('location:submitted.html');
  } */
?>
4
  • 1
    that's some bizarre looking code but nothing to help anyone identify the issue. Commented Aug 12, 2016 at 8:15
  • Take a look on php_errors.log or /var/log/mysql/error.log. I guess you miss some fields Commented Aug 12, 2016 at 8:20
  • What is the error? Commented Aug 12, 2016 at 8:33
  • @user3529096: Atleast respond to the answer given below. Commented Aug 16, 2016 at 8:26

3 Answers 3

1

You have an error on your sql syntax..

$query="INSERT INTO property(id,sale/rent,
                                        com/res,
                                        locality,
                                        bedroom,
                                        bathroom,
                                        furnished_status,
                                        floor,
                                        total floors,
                                        builtup/superbuiltup,
                                        includes_park,
                                        available_from,
                                        details) VALUES('',                                                                          '$rs',
                                                                        '$cr',
                                                                        '$locality',
                                                                        '$br',
                                                                        '$bth',
                                                                        '$fr',
                                                                        '$flr',
                                                                        '$tflr',
                                                                        '$bu',
                                                                        '$park',
                                                                        '$af',
                                                                        '$comment')";

Try this..

$query="INSERT INTO property(id,sale/rent,
                                        com/res,
                                        locality,
                                        bedroom,
                                        bathroom,
                                        furnished_status,
                                        floor,
                                        total floors,
                                        builtup/superbuiltup,
                                        includes_park,
                                        available_from,
                                        details) VALUES('',
                                                                        '".$rs."',
                                                                        '".$cr."',
                                                                        '".$locality."',
                                                                        '".$br."',
                                                                        '".$bth."',
                                                                        '".$fr."',
                                                                        '".$flr."',
                                                                        '".$tflr."',
                                                                        '".$bu."',
                                                                        '".$park."',
                                                                        '".$af."',
                                                                        '".$comment."')";
Sign up to request clarification or add additional context in comments.

2 Comments

This should work and it is the proper formatting technique.
Hey @BlakeConnally : Explain How It is in proper formatting technique.
0

to see the error use mysql_error():

 mysql_query($query) or die(mysql_error();

You code needs to be secured it's open to SQL injection, also mysql functions are obsolete you should move to either mysqli or pdo and then use prepared statements it's much safer.

If you have your id is set to auto increment you don't need to add it to your insert query.

Comments

0

INSERT QUERY having column name total floors.

May be column name are allowed having spaces while creating table. But, While inserting it will show error.

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'total floors' at line 1

So, while inserting please enclose with backtick.

INSERT INTO property(... `total floors` ... ) VALUES ('',''....);

Backtick

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.