jaxdevil Posted November 3, 2007 Share Posted November 3, 2007 I am trying to insert values into a database table..the script runs but nothing ever is inserted into the database. Here is the code, any ideas? The data being passed to this script is being passed via POST. Any help would be appreciated. Thanks! SK <? $link = mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(xxx_xxx); { $sql="INSERT INTO checkout (bidnum,deposit_amount,deposit_storage,deposit_type,deposit_code) VALUES ('$_POST[bidnumx]', '$_POST[xdeposit_amount]', '1', '$_POST[xdeposit_type]', '$_POST[xdeposit_code]')"; } $result = mysql_query($sql); mysql_close($link); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/ Share on other sites More sharing options...
darkfreaks Posted November 3, 2007 Share Posted November 3, 2007 <?php $link = mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(xxx_xxx); { $sql='INSERT INTO checkout (bidnum,deposit_amount,deposit_storage,deposit_type,deposit_code) VALUES ('.$_POST[bidnumx].', '.$_POST[xdeposit_amount].', '1', '.$_POST[xdeposit_type].', '.$_POST[xdeposit_code].')'; } $result = mysql_query($sql); mysql_close($link); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384022 Share on other sites More sharing options...
jaxdevil Posted November 3, 2007 Author Share Posted November 3, 2007 Thanks for the quick response, but thats not working for me. the screen just all goes blank now. There is some error but I can't find it. Any ideas? SK Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384027 Share on other sites More sharing options...
darkfreaks Posted November 3, 2007 Share Posted November 3, 2007 post the code? Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384028 Share on other sites More sharing options...
jaxdevil Posted November 3, 2007 Author Share Posted November 3, 2007 <?php $link = mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(xxx_xxx); { $sql='INSERT INTO checkout (bidnum,deposit_amount,deposit_storage,deposit_type,deposit_code) VALUES ('.$_POST[bidnumx].', '.$_POST[xdeposit_amount].', '1', '.$_POST[xdeposit_type].', '.$_POST[xdeposit_code].')'; } $result = mysql_query($sql); mysql_close($link); ?> Its the code you pasted above, i just copied it over my old on. Thanks a billion for helping, I am pulling my hair out and I need to get this all done, SK Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384029 Share on other sites More sharing options...
darkfreaks Posted November 3, 2007 Share Posted November 3, 2007 <?php $link = mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(xxx_xxx); { $sql='INSERT INTO checkout (bidnum,deposit_amount,deposit_storage,deposit_type,deposit_code) VALUES ("'.$_POST[bidnumx].'", "'.$_POST[xdeposit_amount].'", '1', "'.$_POST[xdeposit_type].'", "'.$_POST[xdeposit_code].'")'; } $result = mysql_query($sql); mysql_close($link); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384033 Share on other sites More sharing options...
jaxdevil Posted November 3, 2007 Author Share Posted November 3, 2007 This still is not working, there must be some small thing we are both overlooking. Any other method you know of to insert data into a mysql table using post data? Thanks, SK Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384040 Share on other sites More sharing options...
rajivgonsalves Posted November 3, 2007 Share Posted November 3, 2007 can you try <?php $link = mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(xxx_xxx); { $sql='INSERT INTO checkout (bidnum,deposit_amount,deposit_storage,deposit_type,deposit_code) VALUES ("'.$_POST[bidnumx].'", "'.$_POST[xdeposit_amount].'", '1', "'.$_POST[xdeposit_type].'", "'.$_POST[xdeposit_code].'")'; } $result = mysql_query($sql) or die "there was an error".mysql_error(); mysql_close($link); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384042 Share on other sites More sharing options...
jaxdevil Posted November 3, 2007 Author Share Posted November 3, 2007 No, that still doesn't work. Any ideas? SK Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384043 Share on other sites More sharing options...
darkfreaks Posted November 3, 2007 Share Posted November 3, 2007 <?php $link = mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(xxx_xxx); { $sql="INSERT INTO checkout (bidnum,deposit_amount,deposit_storage,deposit_type,deposit_code) VALUES (".$_POST['bidnumx'].", ".$_POST['xdeposit_amount'].", "1", ".$_POST['xdeposit_type'].", ".$_POST['xdeposit_code'].")"; } $result = mysql_query($sql) or die "there was an error".mysql_error(); mysql_close($link); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384047 Share on other sites More sharing options...
~n[EO]n~ Posted November 3, 2007 Share Posted November 3, 2007 I think the third line should be <?php mysql_select_db(xxx_xxx, $link); ?> dunno, other looks fine to me Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384049 Share on other sites More sharing options...
JasonLewis Posted November 3, 2007 Share Posted November 3, 2007 you do not need to specify a link.. but you can... try it like this: <?php $link = mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(xxx_xxx); { //whats this? can you remove it? $sql = "INSERT INTO `checkout` (`bidnum`,`deposit_amount`,`deposit_storage`,`deposit_type`,`deposit_code`) VALUES ('{$_POST['bidnumx']','{$_POST['xdeposit_amount']}','1','{$_POST['xdeposit_type']}','{$_POST['xdeposit_code']}')"; } //and this? part of an if statement? $result = mysql_query($sql) or die("there was an error").mysql_error(); mysql_close($link); ?> i have some comments in there... about the curly brackets.. what are they for? and i just fixed up your query... Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384057 Share on other sites More sharing options...
kevincro Posted November 3, 2007 Share Posted November 3, 2007 Most of the changes are cosmetic, but I'm sure it will work if your database is configured correctly. If it doesn't work, I'm very much inclined to believe that your problems lie elsewhere. <?php mysql_connect(localhost,xxx_xxx,xxxxxx); mysql_select_db(xxx_xxx); $bidnumx=$_POST['bidnumx']; $xdeposit_amount=$_POST['xdeposit_amount']; $xdeposit_type=$_POST['xdeposit_type']; $xdeposit_code=$_POST['xdeposit_code']; mysql_query("INSERT INTO `checkout` VALUES ('$bidnumx', '$xdeposit_amount' , '1', '$xdeposit_type', '$xdeposit_code')") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75874-inserting-into-databse-not-working/#findComment-384059 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.