Problem with code?

PythonPython Forum LeaderThe Royal RAM
Ive got a script which is supposed to insert quite a lot of fields from a form into a database... heres the code:

[PHP] $request = "INSERT INTO `hd_packages` ( `packid` , `active` , `parent` , `premium` , `hostname` , `packname` , `url` , `storage` , `bandwidth` , `ftpaccounts` , `databases` , `subdomains` , `addondomains` , `parkeddomains` , `emailaccounts` , `verphp` , `vermysql` , `vercpanel` , `uptime` , `setupfee` , `monthlyfee` , `annualfee` , `email` , `userid`)
VALUES (
'', '0', '$_POST[category2]', '0', '$_POST[hostname], '$_POST[packname]', '$_POST[url2]', '$_POST[storage]', '$_POST[bandwidth]', '$_POST[ftpaccounts]', '$_POST[databases]', '$_POST[subdomains]', '$_POST[addondomains]', '$_POST[parkeddomains]', '$_POST[emailaccounts]', '$_POST[verphp]', '$_POST[vermysql]', '$_POST[vercpanel]', '$_POST[uptime]', '$_POST[setupfee]', '$_POST[monthlyfee]', '$_POST[annualfee]', '$_POST[email2]', '0');";
$result = mysql_query($request) or die (mysql_error());[/PHP]


It keeps on returning an error. The error however doesnt give any useful information though it just says
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use...

Its probably just an obvious mistake but im too tired at the moment. Can anyone point it out?

Thanks

The Royal Ram

Comments

  • gillygilly Junior Member Shared Hoster
    Try this code
    [PHP]$request = "INSERT INTO `hd_packages` ( `packid` , `active` , `parent` , `premium` , `hostname` , `packname` , `url` , `storage` , `bandwidth` , `ftpaccounts` , `databases` , `subdomains` , `addondomains` , `parkeddomains` , `emailaccounts` , `verphp` , `vermysql` , `vercpanel` , `uptime` , `setupfee` , `monthlyfee` , `annualfee` , `email` , `userid`)
    VALUES (
    '', '0', '$_POST[category2]', '0', '$_POST[hostname]', '$_POST[packname]', '$_POST[url2]', '$_POST[storage]', '$_POST[bandwidth]', '$_POST[ftpaccounts]', '$_POST[databases]', '$_POST[subdomains]', '$_POST[addondomains]', '$_POST[parkeddomains]', '$_POST[emailaccounts]', '$_POST[verphp]', '$_POST[vermysql]', '$_POST[vercpanel]', '$_POST[uptime]', '$_POST[setupfee]', '$_POST[monthlyfee]', '$_POST[annualfee]', '$_POST[email2]', '0');";
    $result = mysql_query($request) or die (mysql_error());
    [/PHP]
    You missed out a ' from the $_POST[hostname]

    If that doesn't work try this one

    [PHP]$request = "INSERT INTO `hd_packages` ( `packid` , `active` , `parent` , `premium` , `hostname` , `packname` , `url` , `storage` , `bandwidth` , `ftpaccounts` , `databases` , `subdomains` , `addondomains` , `parkeddomains` , `emailaccounts` , `verphp` , `vermysql` , `vercpanel` , `uptime` , `setupfee` , `monthlyfee` , `annualfee` , `email` , `userid`)
    VALUES (
    '', '0', '$_POST[category2]', '0', '$_POST[hostname]', '$_POST[packname]', '$_POST[url2]', '$_POST[storage]', '$_POST[bandwidth]', '$_POST[ftpaccounts]', '$_POST[databases]', '$_POST[subdomains]', '$_POST[addondomains]', '$_POST[parkeddomains]', '$_POST[emailaccounts]', '$_POST[verphp]', '$_POST[vermysql]', '$_POST[vercpanel]', '$_POST[uptime]', '$_POST[setupfee]', '$_POST[monthlyfee]', '$_POST[annualfee]', '$_POST[email2]', '0')";
    $result = mysql_query($request) or die (mysql_error());
    [/PHP]
  • PythonPython Forum Leader The Royal RAM
    The first one worked fine...

    See I knew it was a really simple and obvious problem, lol

    Thanks :)

    The Royal Ram

Sign In or Register to comment.