unusual behavior, and that's just me...

Ok I got a question. I realize it’s probably not even worthy of the lower echelon in scripting but then again i’m no master. So I make a simple script that posts information into my online database from an html form. It worked beautifully. I made another script using the exact same formatting (although it has more entries than the first) and it acts like it runs perfectly but when i check the database nothing is posted, just blanks. I welcome suggestions and appreciate your consideration. I iwll post the code below. first the smaller one that worked:
[php]

<?php define('DB_NAME', 'blackmail'); define('DB_USER', 'blackmail'); //I left out the password below define('DB_PASSWORD', '*****'); define('DB_HOST', 'blackmail.db.8631036.hostedresource.com'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('could not connect: ' . mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected) { die('Can\'t use ' . DB_NAME . ' : ' . mysql_error()); } $value1 = $_POST['first_name']; $value2 = $_POST['last_name']; $value3 = $_POST['email']; $value4 = $_POST['comments']; $sql = "INSERT INTO memberlist (first_name, last_name, email, comments) VALUES ('$value1', '$value2', '$value3', '$value4')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close(); ?>[/php]

and the one that doesn’t work:
[php]<?php

define(‘DB_NAME’, ‘black44users’);
define(‘DB_USER’, ‘black44users’);
define(‘DB_PASSWORD’, ‘*****’);
define(‘DB_HOST’, ‘black44users.db.8631036.hostedresource.com’);

$link = mysql_connect(DB_HOST, DB_USER,DB_PASSWORD);

if (!$link) {
die('could not connect: ’ . mysql_error());

}
$db_selected = mysql_select_db(DB_NAME, $link);

if (!$db_selected) {
die('Can’t use ’ . DB_NAME . ’ : ’ . mysql_error());
}

$value1 = $_POST[‘first_name’];
$value2 = $_POST[‘last_name’];
$value3 = $_POST[‘address1’];
$value4 = $_POST[‘address2’];
$value5 = $_POST[‘city’];
$value6 = $_POST[‘state’];
$value7 = $_POST[‘zip’];
$value8 = $_POST[‘phone’];
$value9 = $_POST[‘email’];
$value10 = $_POST[‘email2’];
$value11 = $_POST[‘shippingfirst’];
$value12 = $_POST[‘shippinglast’];
$value13 = $_POST[‘shippingaddress1’];
$value14 = $_POST[‘shippingaddress2’];
$value15 = $_POST[‘shippingcity’];
$value16 = $_POST[‘shippingstate’];
$value17 = $_POST[‘shippingzip’];
$value18 = $_POST[‘cctype’];
$value19 = $_POST[‘ccnumber’];
$value20 = $_POST[‘ccexpiration’];
$value21 = $_POST[‘cccvv’];

$sql = “INSERT INTO customers (first_name, last_name, address1, address2, city, state, zip, phone, email, email2, shippingfirst, shippinglast, shippingaddress1, shippingaddress2, shippingcity, shippingstate, shippingzip, cctype, ccnumber, ccexpiration, cccvv) VALUES (’$VALUE1’, ‘$VALUE2’, ‘$VALUE3’, ‘$VALUE4’, ‘$VALUE5’,’$VALUE6’, ‘$VALUE7’, ‘$VALUE8’, ‘$VALUE9’, ‘$VALUE10’, ‘$VALUE11’, ‘$VALUE12’, ‘$VALUE13’, ‘$VALUE14’, ‘$VALUE15’, ‘$VALUE16’, ‘$VALUE17’, ‘$VALUE18’, ‘$VALUE19’, ‘$VALUE20’, ‘$VALUE20’)”;

if (!mysql_query($sql)) {
die('Error: ’ . mysql_error());
}
mysql_close();

?>
[/php]

hi i have checked your code your doing following mistake you are using $VALUE1, $VALUE2, $VALUE3 ... etc in your sql which is not define by you. you have to use $value1,$value2, $value3 ... etc in your sql.

use below code
[php]
$sql = “INSERT INTO customers (first_name, last_name, address1, address2, city, state, zip, phone, email, email2, shippingfirst, shippinglast, shippingaddress1, shippingaddress2, shippingcity, shippingstate, shippingzip, cctype, ccnumber, ccexpiration, cccvv) valueS (’$value1’, ‘$value2’, ‘$value3’, ‘$value4’, ‘$value5’,’$value6’, ‘$value7’, ‘$value8’, ‘$value9’, ‘$value10’, ‘$value11’, ‘$value12’, ‘$value13’, ‘$value14’, ‘$value15’, ‘$value16’, ‘$value17’, ‘$value18’, ‘$value19’, ‘$value20’, ‘$value20’)”;

[/php]
Instead of below code
[php]
$sql = “INSERT INTO customers (first_name, last_name, address1, address2, city, state, zip, phone, email, email2, shippingfirst, shippinglast, shippingaddress1, shippingaddress2, shippingcity, shippingstate, shippingzip, cctype, ccnumber, ccexpiration, cccvv) VALUES (’$VALUE1’, ‘$VALUE2’, ‘$VALUE3’, ‘$VALUE4’, ‘$VALUE5’,’$VALUE6’, ‘$VALUE7’, ‘$VALUE8’, ‘$VALUE9’, ‘$VALUE10’, ‘$VALUE11’, ‘$VALUE12’, ‘$VALUE13’, ‘$VALUE14’, ‘$VALUE15’, ‘$VALUE16’, ‘$VALUE17’, ‘$VALUE18’, ‘$VALUE19’, ‘$VALUE20’, ‘$VALUE20’)”;
[/php]

I hope this will helpful for you…
Reply your feedback.
SR~

lol wow, what sophomoric error. That was it, works like a charm. I really appreciate your time. I think i’m going to enroll in a web development course at the community college. PhP is an incredible language and i want to learn more. Again thanks for looking it over. you da man

Sponsor our Newsletter | Privacy Policy | Terms of Service