March 30, 2006 at 12:04 pm
Hi all,
I'm fairly new to MSSQL/PHP and I've been working my way around. I'm
working on adding to an already existing homebrew CMS solution and I'm
having some problems. The site uses ADODB from what I can tell and I
believe I have integrated my page/form properly into it - I can call
the page and fill in the blanks and what not.
However, when I click submit, the following chain of events happen:
function write_form()
{
$editor = $_SESSION['ID'];
$Name = $_POST[Name];
$Number = $_POST[Number];
$Customer = $_POST[Customer];
$Address = $_POST[Address];
$City = $_POST[City];
$State = $_POST[State];
$Zip = $_POST[Zip];
(some other vars)
if ($_POST[Name])
{
/* $rs = us_query("insert into FormDB
(Name,Number,Customer,Address,City,State,Zip,[stuff]) Values
('$Name','$Number','$Customer','$Address','$City','$State','$Zip',[more
stuff])");
*/
$rs = us_query("insert into FormDB Values
('$Name','$Number','$Customer','$Address','$City','$State','$Zip','[more
stuff])");
$rs->close;
print_success_message("Form Submitted!");
echo "Tests is $Name";
}
else
{
print_error_message("Some error occured");
}
}
When I submit (on the original form), the page refreshes and says Form
Submitted! and lower on the page it in fact does say 'Tests is (name
submitted on form)'
If i do form action get instead of form action post, I can see the data
being passed along so we can be sure the variables are getting passed properly.
However, if I load up SQL Server Enterprise Manager, and look at the
table in question, I do not see the record. The only record that is
there is the sole record I added by hand when I made the table.
The table has all the columns plus another one 'ID' as a primary key,
ascending.
I'm not sure what I am doing wrong, especially since the PHP doesn't
error on me. Do I have to do something additional to input the form
data into SQL and have it automatically generate a new ID?
Thanks for your help!
Using SQL Standard 8.0
April 4, 2006 at 5:54 am
Shouldn't your insert be
$rs = us_query("insert into FormDB Values
('".$Name."','".$Number."','".$Customer."','".$Address'".,'."$City."','".$State."','".$Zip."','"[more stuff]);
(omitting the apostrophes for numeric fields)
--
Scott
April 4, 2006 at 5:56 am
If that doesn't work, try echoing your $rs string to the screen and then copy and paste it into Query Analyzer. If you get an error message in QA it might point you in the right direction.
--
Scott
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply