0

Hi All,

If someone can help me with this I would be eternally grateful here.

I have created a form on one page with php validation. Once cleared through the validation I have Sessioned the inputted data to catch them on the "insert data page"

on the "insert data page" I have this bit of coding:

// GET POST DATA AND CREATE VARIABLES

$city = $_SESSION['city'];
$state = $_SESSION['state'];
$zip = $_SESSION['zip'];
$address = $_SESSION['address'];
$unit = $_SESSION['unit'];
$price = $_SESSION['price'];
$beds = $_SESSION['beds'];
$baths = $_SESSION['baths'];
$sqft = $_SESSION['sqft'];
$propType = $_SESSION['proptype'];

echo $id, $city, $state, $zip, $address, $unit, $price, $beds, $baths, $sqft, $propType;

include ('includes/conn.inc.php');

// INSERT DATA FROM FORM ONCE THE FORM HAS BEEN SUBMITTED AND VALIDATED
$sql="INSERT INTO table_name (id, city, state, zip, address_no_street, unit_no, price, beds, baths, sqft, property_type, date) VALUES ('$id', '$city', '$state', '$zip', '$address', '$unit', '$price', '$beds', '$baths', '$sqft', '$propType', NOW())";
mysql_query($sql) or die ('Something went wrong with submitting your information');

All variables are echoing properly so the data gets this far. The INSERT however does not fire. I have checked and rechecked my DB for misspells or errors but see none. Is there something I am missing here.

I tried this and it works perfectly:

$sql="INSERT INTO table_name (id, city, state, zip, address_no_street, unit_no, price, beds, baths, sqft, property_type, date) VALUES ('id', 'city', 'state', 'zip', 'address', 'unit', 'price', 'beds', 'baths', 'sqft', 'propType', NOW())";
mysql_query($sql) or die ('Something went wrong with submitting your information');

the variables are not getting in there for some reason and I can't figure out why.

Really appreciate any help on this.

Edited by phaedrusGhost: n/a

3
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by karthik_ppts
Featured Replies
  • Print your insert query after line no 19. [CODE]echo $sql;[/CODE] Copy and paste it into phpmyadmin(or the query analyser u r using). Execute the query and check out the errors. Also modify [CODE]mysql_query($sql) or die ('Something went wrong with submitting your information <br>'.mysql_error);[/CODE] Read More

1

Print your insert query after line no 19.

echo $sql;

Copy and paste it into phpmyadmin(or the query analyser u r using).
Execute the query and check out the errors.
Also modify

mysql_query($sql) or die ('Something went wrong with submitting your information <br>'.mysql_error);

Edited by divyakrishnan: n/a

Votes + Comments
useful post
0

just echo out your qry

echo $sql="INSERT INTO table_name (id, city, state, zip, address_no_street, unit_no, price, beds, baths, sqft, property_type, date) VALUES ('$id', '$city', '$state', '$zip', '$address', '$unit', '$price', '$beds', '$baths', '$sqft', '$propType', NOW())";

copy this query and execute it in the SQl section of your phpmyadmin and see what happens. It will tell if you have any error in your query.

0

Hi Divyakrishnan,

I did what you suggested and the query is catching the data as well.

Below is what was printed back to me:

INSERT INTO table_name (id, city, state, zip, address_no_street, unit_no, price, beds, baths, sqft, property_type, date) VALUES ('7', 'city', 'Arizona', 'zip', 'address', 'unit', 'price', 'beds', 'baths', 'sqft', 'coop', NOW())Something went wrong with submitting your information 
mysql_error

The last line of code you gave for viewing mysql_errors just gave me an echo of that command.

Any ideas?

Your help is appreciated.

0

Print your insert query after line no 19.

echo $sql;

Copy and paste it into phpmyadmin(or the query analyser u r using).
Execute the query and check out the errors.
Also modify

mysql_query($sql) or die ('Something went wrong with submitting your information <br>'.mysql_error);

Hi divyakrishnan, I didn't see your post when i posted my post..

0

Hi Karthik,

No errors there. It executes properly..

Thanks for the suggestion..

Edited by phaedrusGhost: n/a

0

That worked nicely Karthik, thank you so much man!

I was trying to INSERT while duplicating a primary id. It's all been fixed now.

Much thanks...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.