Page 1 of 1

[fixed]more form troubles :(

Posted: Fri Nov 17, 2006 12:08 pm
by Obadiah
im trying to insert some values into my database and for some reason my code is pooping out on me

here goes...this is the basic html part

Code: Select all

<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="cs.css">
<script language="javascript" src="myForms.js">
</script>
</head>
<body bgcolor="white">
<h3><center>Merchant Services Incorporated</center></h3>
<form action="status_modified.php" method="post" onsubmit="return validate()">
<table width="1187">
<tr>
<td>
<table class="text" width="1174" border="1" bordercolor="green">
<tr>
<td align="center" width="75">Date Received</td>
<td align="center" width="81">Merchant Name</td>
<td align="center" width="40">Bank</td>
<td align="center" width="106">Lease/Conversion/Reprogram</td>
<td align="center" width="106">Date Submitted</td>
<td align="center" width="105">Bank AP Date</td>
<td align="center" width="111">Lease Company</td>
<td align="center" width="99">Lease Discount</td>
<td align="center" width="105">AMEX Date Submit</td>
<td align="center" width="109">AMEX Date APPD</td>
<td align="center" width="75">Shipped</td>
<td align="center" width="97">Merchant Number</td>
</tr>
<tr>
<td><input type="text" name="date_recieved" size="8"></td>
<td><input type="text" name="merchant_name" size="12"></td>
<td><input type="text" name="bank" size="8"></td>
<td>
<select name="purchase_type">
<option>Lease</option>
<option>Conversion</option>
<option>Reprogram</option>
</select>
</td>
<td><input type="text" name="date_submitted" size="13"></td>
<td><input type="text" name="bankap_date" size="13"></td>
<td><input type="text" name="lease_company" size="14"></td>
<td><input type="text" name="lease_discount" size="12"></td>
<td><input type="text" name="amexdate_submit" size="10"></td>
<td><input type="text" name="amexdate_appd" size="10"></td>
<td><input type="text" name="shipped" size="10"></td>
<td><input type="text" name="merchant_num" size="10"></td>
</tr>
<tr>
<td bgcolor="green" colspan="12">&nbsp;</td>
</tr>
<tr>
<td width="45">Terminal:</td><td width="104"><input type="text" name="terminal" size="12"></td>
<td width="73">Serial Number:</td><td width="102"><input type="text" name="serial_num" size="19"></td>
<td width="97">User Name:</td><td width="98"><input type="text" name="user_name" size="13"></td>
<td width="42">App-ID:</td><td width="114"><input type="text" name="app_id" size="12"></td>
<td width="29">NMS:</td><td width="109"><input type="text" name="nms" size="10"></td>
<td width="70">Hypercom TID:</td><td><input type="text" name="hypercom_tid" size="10"></td>
</tr>
<tr>
<td>Comments</td>
<td colspan="11"><textarea name="comments" cols=55 rows=5></textarea></td>
</tr>
</table>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Enter New Merchant">
</form>
</body>
</html>
no biggies there but when i put this alongside to do begin my simple add, set, post

Code: Select all

<?php
error_reporting(E_ALL); 
ini_set('display_errors', 1); 
$conn= mysql_connect("localhost", "####", "########");
mysql_select_db("customerdirectory",$conn);
$sql = "INSERT INTO merchant values('$_POST[merchant_num]',								            '$_POST[date_recieved]',
				'$_POST[merchant_name]',
				'$_POST[bank]',
				'$_POST[purchase_type]',
				'$_POST[date_submitted]',
				'$_POST[bankap_date]',
				'$_POST[lease_company]',
				'$_POST[app_id]',
				'$_POST[hypercom_tid]',
				'$_POST[user_name]',
				'$_POST[lease_discount]',
				'$_POST[amexdate_submit]',
				'$_POST[amexdate_appd]',
				'$_POST[shipped]',
				'$_POST[terminal]',
				'$_POST[serial_num]',
				'$_POST[nms]',
				'$_POST[comments]')";
if(mysql_query($sql, $conn))
{
	echo "record added";
}
else
{
	echo "something went wrong";
}
?>
i get the something went wrong error...but what?!?
[edit]
i fixed it...lol :lol:

Posted: Fri Nov 17, 2006 12:27 pm
by JayBird
You really need to start using mysql_error()

Posted: Fri Nov 17, 2006 12:38 pm
by Obadiah
i know...i was just tryna test this out and got lazy about putting in the errors but im putting them in now

Posted: Fri Nov 17, 2006 12:49 pm
by Obadiah
ok...i just tried running the script again and it crapped out on me...im not getting what the deal is...heres my new code

Code: Select all

<?php
error_reporting(E_ALL); 
ini_set('display_errors', 1); 
$conn = mysql_connect("localhost","####","##########") or die(mysql_error());
mysql_select_db("customerdirectory",$conn) or die(mysql_error());
$sql = "INSERT INTO merchant values ('$_POST[merchant_num]',
										'$_POST[date_recieved]',
										'$_POST[merchant_name]',
										'$_POST[bank]',
										'$_POST[purchase_type]',
										'$_POST[date_submitted]',
										'$_POST[bankap_date]',
										'$_POST[lease_company]',
										'$_POST[app_id]',
										'$_POST[hypercom_tid]',
										'$_POST[user_name]',
										'$_POST[lease_discount]',
										'$_POST[amexdate_submit]',
										'$_POST[amexdate_appd]',
										'$_POST[shipped]',
										'$_POST[terminal]',
										'$_POST[serial_num]',
										'$_POST[nms]',
										'$_POST[comments]')";
if(mysql_query($sql, $conn))
{
	echo "record added";
}
else
{
	echo "something went wrong";
}
?>
the output
something went wrong
but it was just working :?
[edited]
i have the field comments as a tinyblob in my database.....could that be the problem?

Posted: Fri Nov 17, 2006 1:36 pm
by Obadiah
ok...i tried to add on another computer and it worked fine...but then i hit the back butten twice to get the form again to try to enter the database with the same information and i get that error message again....why? i changed all the fields like that needed to be unique....im gonna redirecting the user temporarily to refresh the page....maybe that will work :?

Posted: Fri Nov 17, 2006 4:17 pm
by evilchris2003
what he means by mysql_error() is

Code: Select all

echo 'something went wrong', mysql_error():
[/php}

that way you will actually get the erro printed out

Posted: Fri Nov 17, 2006 4:18 pm
by evilchris2003
lets try that again

Code: Select all

echo 'something went wrong', mysql_error():