Jump to content

inserting into databse not working


jaxdevil

Recommended Posts

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);

?>

Link to comment
Share on other sites

<?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);

?>

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

<?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);

?>

Link to comment
Share on other sites

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);

?>

Link to comment
Share on other sites

<?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);

?>

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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());
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.