INSERT INTO

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ShaunFL
Forum Newbie
Posts: 1
Joined: Tue Aug 25, 2009 3:36 am

INSERT INTO

Post by ShaunFL »

I've been staring at this for a few hours now and I can't seem to figure out what the problem is. Usually I manage to figure out some stupid mistake I've made but this one has me stumped.

Please excuse the bad code:

Code: Select all

mysql_query("INSERT INTO invoice_child (interest, parent, item, unitprice, qty, author) VALUES ('". $_POST['vat'.$i.''] ."', '". $_POST['invoiceid'] ."', '". $_POST['item'.$i.''] ."', '". $_POST['unitprice'.$i.''] ."', '". $_POST['qty'.$i.''] ."', '". $_POST['author'] ."')")or die(mysql_error()); }
Essentially I'm creating an entry in the database for each item of an invoice.

At the moment everything is working except the 'interest'. Nothing gets inserted into that field but there's no error. At first I thought maybe the $_POST wasn't sending but by changing it to a string I've realised that's not getting inserted either.

Thanks in advance :)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: INSERT INTO

Post by Eran »

how do you know there's no error? did you run mysql_error() afterwards?
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: INSERT INTO

Post by susrisha »

@pyrtin
there is a die statement if the query doesnt execute.
@ShaunFL
Try printing the query statement each time you are querying. My wild guesses
1. Either the sql data type is different (might be string)
2. the post data is not showing up properly
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: INSERT INTO

Post by jackpf »

You're vulnerable to SQL injection as well.
Post Reply