Jump to content

Problem Inserting Data Into MYSQL db


DamienRoche

Recommended Posts

Last question, I won't spam the board.

 

I am having a lot of trouble inserting data in my MYSQL db.

 

Here's my problem:

 

$mysql_query = "INSERT INTO $table (id, First Name, Surname, Position, Phone Number, Email Address, Company/Organization, Reg/VAT Number, Address Line 1, Address Line 2, Address Line 3, City, Country, Post/Zip Code, Qualifying from Where)

VALUES('$unique_id','$fname','$sname','$pos','$pnum','$email','$compname','$regno','$adline1','$adline2',$adline3','$city','$country','$postzip','$qualwho')" or die("unable to insert data into $table");

 

None of the data is submitted. Yet, I can easily submit data using the code below:

 

$mysql_query = "INSERT INTO $table (id, fname, sname)

VALUES('$unique_id','$fname','$sname')" or die("unable to insert data into $table");

 

I have added the relevant fields to the table, there is absolutely no typos. I'm not getting any error messages and the data is definitely being transferred from the form because I've had it splashed out using the same php file.

 

Does anyone have any idea what is going wrong or what i can do to troubleshoot?

 

Thanks,

 

Damien.

Link to comment
https://forums.phpfreaks.com/topic/116964-problem-inserting-data-into-mysql-db/
Share on other sites

i think you have confused variable name with function name...you are not calling the function mysql_query anywhere , how will it insert?

 

try this...

 

$mysql_query = mysql_query("INSERT INTO $table (id, fname, sname)
VALUES('$unique_id','$fname','$sname')") or die("unable to insert data into $table");

Hey thanks a lot! It helped me get closer to the broken cogs.

 

Here's what MYSQL says:

 

check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name, Surname, Position, Phone Number, Email Address, Company/Organization, Reg/' at line 1

 

Any insights?

 

Thanks for the help.

Second time I've done this...sussed it out, thanks to the handy tips above.

 

Turns out I'm not allowed to use spaces or other special characters in the field names.

 

Thanks for all your help guys!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.