Data wont push

I have a form when I enter the information it wont post to the database.

[php]

<?php $hostname="myelstonfamily.db.#######.hostedresource.com"; $dbuser="myelstonfamily"; $pass="password"; $username =$_POST['username']; $adultfees =$_POST['adultfees']; $youthfees =$_POST['youthfees']; $childrenfees =$_POST['childrenfees']; $tyouthsmall =$_POST['tyouthsmall']; $tyouthmedium =$_POST['tyouthmedium']; $tyouthlarge =$_POST['tyouthlarge']; $tadultsmall =$_POST['tadultsmall']; $tadultmedium =$_POST['tadultmedium']; $tadultlarge =$_POST['tadultlarge']; $tadultxl =$_POST['tadultxl']; $tadult2xl =$_POST['tadult2xl']; $tadult3xl =$_POST['tadult3xl']; $link = mysql_connect($hostname,$dbuser, $pass); $db_selected = mysql_select_db('myelstonfamily', $link); if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); } else { mysql_query ("INSERT INTO 2012 (username, adultfees, youthfees, childrenfees, tyouthsmall, tyouthmedium, tyouthlarge, tadultsmall, tadultmedium, tadultlarge, tadultxl, tadult2xl, tadult3xl) VALUES('$adultfees','$youthfees','$childrenfees','$tyouthsmall','$tyouthmedium','$tyouthlarge','$tadultsmall','$tadultmedium','$tadultlarge','$tadultxl','$tadult2xl','$tadult3xl')"); } mysql_close($link); ?>

[/php]

you should always post your error message, someone can help you.

I see a problem with your insert structure:

[php] else
{
mysql_query (“INSERT INTO 2012 (username, adultfees, youthfees, childrenfees, tyouthsmall, tyouthmedium, tyouthlarge, tadultsmall, tadultmedium, tadultlarge, tadultxl, tadult2xl, tadult3xl) VALUES(’$adultfees’,’$youthfees’,’$childrenfees’,’$tyouthsmall’,’$tyouthmedium’,’$tyouthlarge’,’$tadultsmall’,’$tadultmedium’,’$tadultlarge’,’$tadultxl’,’$tadult2xl’,’$tadult3xl’)”);
}
mysql_close($link);
?>
[/php]

The correct structure is
[php]INSERT INTO 212 VALUES (value1, value2, value3,…) [/php]

But a more comprehensive way would be something like this:

[php]$query = mysql_query("INSERT INTO content SET id = null, title=’$postTitle’, author =’$postAuthor’, body_text =’$postContent’, linklabel = ‘$postLinkLabel’ ") or die (mysql_error());[/php]

This latter example is more human friendly to read. I think you main issue has to do with the use of parenthesis inside parenthesis. This example avoids that.

The structure of your query is fine in terms of specifying the fields you are inserting into, you are simply missing the $username value. Add that and you should be fine, if not change your code to this, and post the result.

[php]$result = mysql_query(“INSERT INTO 2012 (username,adultfees,youthfees…”);//etc
if($result === false) echo 'Mysql Error: '.mysql_error();[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service