Problem submiting to msql with html form $_POST.[solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Mirux
Forum Commoner
Posts: 29
Joined: Sun May 13, 2007 7:11 pm

Post by Mirux »

Code: Select all

$insert = "INSERT INTO members ('loginid', 'password', 'firstname', 'surname', 'email', 'trade', 'address1', 'address2', 'address3', 'address4', 'postzip', 'country', 'yearsexp', 'about') VALUES ...
Somehow, when I use '' for the table fields, like 'loginid', 'password', etc. it gave me error once. If the code doesn't work for you, just delete the single quotes. Just use them for the VALUES.
toby_c500
Forum Commoner
Posts: 50
Joined: Fri May 11, 2007 11:29 am
Location: Leeds, England

Post by toby_c500 »

Awesome. That has help Ole. Worked a treat. An oversight on my part.

Thank you all for you help.

The form works PHP-wise but the data does not enter into my database. The next issue to sort out.
I'm slowly learning.

Thanks again. I'm off to read up on phpmyadmin.

Toby
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

DO NOT DO THIS:
Mirux wrote:

Code: Select all

$insert = "INSERT INTO members ('loginid', 'password', 'firstname', 'surname', 'email', 'trade', 'address1', 'address2', 'address3', 'address4', 'postzip', 'country', 'yearsexp', 'about') VALUES ...
Use backticks instead for field names, database names and table names.

Code: Select all

<?php
$sql = "INSERT INTO `tableName` (`field1`, `field2`) VALUES ($unquotedIntVal, '$quotedStringVal')";
?>
toby_c500
Forum Commoner
Posts: 50
Joined: Fri May 11, 2007 11:29 am
Location: Leeds, England

Post by toby_c500 »

Thanks Everah.

I will give that a go.
Post Reply