Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old July 30th, 2010, 05:07 PM   #1
New Member
 

Join Date: Oct 2008
Location: florida
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ckdoublenecks is on a distinguished road
need help with database insert

Will someone tell me why the below does not add a record to my database. It just displays the source code?

<form action="waitinsert.php" method="post> is from my form

waitinsert.php is the name of the program

<?
$username="root";
$password="";
$database="hoappsdb";
$entrytype=$_POST['entrytype'];
$appl=$_POST['appl'];
$date=$_POST['date'];
$time=$_POST['time'];
$name=$_POST['name'];
$racegend=$_POST['racegend'];
$ethnicity=$_POST['ethnicity'];
$laborhsg=$_POST['laborhsg'];
$displ=$_POST['displ'];
$incomelevel=$_POST['incomelevel'];
$brneeded=$_POST['brneeded'];
$moveindate=$_POST['moveindate'];
$removaldate=$_POST['removaldate'];
$code=$_POST['code'];
$comments=$_POST['comments'];
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO waitlist VALUES ('$entrytype','$appl','$date','$time','$name','$re cegend','$ethnicity','$laborhsg','$displ','$income level','$brneeded','$moveindate','$removaldate','$ code','$comments')";
mysql_query($query);
mysql_close();
?>
ckdoublenecks is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old August 3rd, 2010, 07:33 AM   #2
New Member
 

Join Date: Aug 2010
Location: Earth
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 bigmax is on a distinguished road
Re: need help with database insert

Try

Code:
<?php
extract($_POST,EXTR_OVERWRITE);
mysql_connect("localhost","root","");
mysql_select_db("hoappsdb") or die( "Unable to select database");
mysql_query("INSERT INTO waitlist VALUES '$entrytype','$appl','$date','$time','$name','$re cegend','$ethnicity','$laborhsg','$displ','$income level','$brneeded','$moveindate','$removaldate','$code','$comments'"); or die(mysql_error());
mysql_close();
?>
instead. Make sure you use proper php indicators (<?php instead of just <?)

Last edited by bigmax; August 3rd, 2010 at 07:35 AM.. Reason: sp
bigmax is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old August 3rd, 2010, 08:51 AM   #3
New Member
 

Join Date: Nov 2009
Location: India
Age: 25
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 katierosy is on a distinguished road
Smile Re: need help with database insert

If PHP5 is installed properly , this code should works fine.
<?php
$username="root";
$password="";
$database="hoappsdb";
$entrytype=$_POST['entrytype'];
$appl=$_POST['appl'];
$date=$_POST['date'];
$time=$_POST['time'];
$name=$_POST['name'];
$racegend=$_POST['racegend'];
$ethnicity=$_POST['ethnicity'];
$laborhsg=$_POST['laborhsg'];
$displ=$_POST['displ'];
$incomelevel=$_POST['incomelevel'];
$brneeded=$_POST['brneeded'];
$moveindate=$_POST['moveindate'];
$removaldate=$_POST['removaldate'];
$code=$_POST['code'];
$comments=$_POST['comments'];
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO waitlist VALUES ('$entrytype','$appl','$date','$time','$name','$re cegend','$ethnicity','$laborhsg','$displ','$income level','$brneeded','$moveindate','$removaldate','$ code','$comments')";
mysql_query($query);
mysql_close();
?>
katierosy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


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

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Code insert into database problem longstand PHP 7 October 13th, 2007 06:03 PM
Problem with insert into the database kool77 PHP 3 June 4th, 2007 03:21 PM
XML Code for transfering data from one SQL Server Database to another database plolla Other Languages 1 August 3rd, 2006 02:37 PM
SQL Insert help air duster Classic ASP 13 January 12th, 2006 04:38 AM
insert form to database Monie Databases 1 August 24th, 2004 10:59 PM


Search Engine Optimization by vBSEO 3.2.0 RC8