Current location: Hot Scripts Forums » Programming Languages » PHP » insert program won't work


insert program won't work

Reply
  #1 (permalink)  
Old 09-11-10, 12:36 PM
ckdoublenecks ckdoublenecks is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 123
Thanks: 11
Thanked 0 Times in 0 Posts
insert program won't work

I have this little insert program, almost identical to other working programs, which doesn't work and I don't know why. Below is the code ?
Code:
<html><BODY>
<b>Misc. Charges insert form<p>
 <form action="mschginsert.php" method="post">
<INPUT TYPE="text" name=dep>Dep#<BR>
<INPUT TYPE="text" name=name>Name<BR>
<INPUT TYPE="text" name=apt>Apt#<BR>
<INPUT TYPE="text" name=amtpaid>Amount Paid<BR>
<INPUT TYPE="text" name=damage>Damage Chg<BR>
<INPUT TYPE="text" name=month>Month Incurred<BR>
<INPUT TYPE="text" name=courtcost>Court Costs<BR>
<INPUT TYPE="text" name=nsf>NSF<BR>
<INPUT TYPE="text" name=latechg>Late Charges<BR>
<INPUT TYPE="text" name=comments>Comments<BR>
<p>
<INPUT type=submit value="submit data"><BR>
</form></body></html>
the below PHP file is mschginsert.php

PHP Code:

<?php

$dep
=$_POST['dep'];
$name=$_POST['name'];
$apt=$_POST['apt'];
$amtpaid=$_POST['amtpaid'];
$damage=$_POST['damage'];
$month=$_POST['month'];
$courtcost=$_POST['courtcost'];
$nsf=$_POST['nsf'];
$latechg=$_POST['latechg'];
$comments=$_POST['comments'];
mysql_connect(localhost,root,"");
mysql_select_db(mschgdb) or die ("Unable to select database");

$query "INSERT INTO miscdata VALUES ('','$dep','$name','$apt','$amtpaid','$damage','$month','$courtcost','$nsf','$latechg','$comments')";
mysql_query($query);

mysql_close();
?>

Last edited by ckdoublenecks; 09-11-10 at 12:39 PM. Reason: clarity
Reply With Quote
  #2 (permalink)  
Old 09-13-10, 09:27 AM
blackhawkso blackhawkso is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 39
Thanks: 3
Thanked 0 Times in 0 Posts
What is happening when you atempt the insert?
__________________
Don't understand science?

Try religion lol
Reply With Quote
  #3 (permalink)  
Old 09-13-10, 09:32 AM
blackhawkso blackhawkso is offline
Newbie Coder
 
Join Date: Mar 2010
Posts: 39
Thanks: 3
Thanked 0 Times in 0 Posts
Just try this to see what error you will get

PHP Code:

$query "INSERT INTO miscdata VALUES ('','$dep','$name','$apt','$amtpaid','$damage','$month','$courtcost','$nsf','$latechg','$comments')";

if (
mysql_query($query))
{
echo 
'Worked';
} else {
die(
'Didnt Work<br />: ' mysql_error());
}; 
__________________
Don't understand science?

Try religion lol
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Friend to Friend Shortest Path sandeep.kumar Database 51 01-15-09 03:12 AM
I'm desperate for work, I'll do any work for cheap [PHP/MySQL] Anastas Job Offers & Assistance 17 02-12-06 11:18 AM
program doesnt work in ie but does in firefox darkcarnival The Lounge 0 12-20-04 10:13 PM
Need an informational database program Silmarillion Script Requests 0 11-29-04 01:20 AM
PHP Programer(s) needed to work on open source project with me blasto333 Job Offers & Assistance 0 11-19-04 06:55 PM


All times are GMT -5. The time now is 08:42 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.