MySQL Forums
Forum List  »  Newbie

(Inconsistent?) problems inserting into a table
Posted by: Sam Williams
Date: June 03, 2009 02:18PM

Hi all,

Just a quick note to ask for some advise as regards to my problem;

I have a table setup - microBsettings, that has these fields,

pin, activitybanner, microblogbanner, microblogcolour`, articlefollowscolour, admincolour, usercolour, keymodule, microblogmodule, activitymodule, microblogorder, activityorder, microblogresults, activityresults.

I am trying to insert into the table with the command...

mysql_query("INSERT INTO '" . $wpdb->prefix."microBsettings" . "'(
pin,
activitybanner,
microblogbanner,
microblogcolour,
articlefollowscolour,
admincolour,
usercolour,
keymodule,
microblogmodule,
activitymodule,
microblogorder,
activityorder,
microblogresults,
activityresults)
VALUES(

`".$_POST['pin']."`,
`".$_POST['activitybanner']."`,
`".$_POST['microblogbanner']."`,
`".$_POST['microblogcolour']."`,
`".$_POST['articlefollowscolour']."`,
`".$_POST['admincolour']."`,
`".$_POST['usercolour']."`,
`".$_POST['keymodule']."`,
`".$_POST['microblogmodule']."`,
`".$_POST['activitymodule']."`,
`".$_POST['microblogorder']."`,
`".$_POST['activityorder']."`,
`".$_POST['microblogresults']."`,
`".$_POST['activityresults']."`
);") or die('Error, insert query failed');



If I echo what the query looks like before the command, it comes out as:

INSERT INTO 'bf_microBsettings' ( pin, activitybanner, microblogbanner, microblogcolour`, articlefollowscolour, admincolour, usercolour, keymodule, microblogmodule, activitymodule, microblogorder, activityorder, microblogresults, activityresults )VALUES ( `1234`, `Microblog`, `Activity`, `#666666`, `#333333`, `#900000`, `#000033`, `TRUE`, `TRUE`, `TRUE`, `2`, `1`, `3`, `3` );

...and doesn't work (error code 1064, near line 1).

The strange thing is however, the phpmyadmin generated code:

INSERT INTO `web225-blog-1`.`bf_microBsettings` (
`pin` ,
`activitybanner` ,
`microblogbanner` ,
`microblogcolour` ,
`articlefollowscolour` ,
`admincolour` ,
`usercolour` ,
`keymodule` ,
`microblogmodule` ,
`activitymodule` ,
`microblogorder` ,
`activityorder` ,
`microblogresults` ,
`activityresults`
)
VALUES (
'1', '2', '3', '4', '5', '6', '7', '8', '9', '8', '7', '6', '5', '4'
);

*does* work.

Also, if I take the values section from the query generated by my code and swap it out with the one above, it works. However if I change the values section from the phpmyadmin code back to the orginal variables, it doesn't work.


I've spent a good 3 hours on this problem, so i'm not posing the question lightly. Also, sorry for having to post such large pieces of code, I didn't want to miss anything out.

Any help would be greatly appreciated thanks,
Sam

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.