Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 17th, 2002, 10:41 PM
rfigley rfigley is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 rfigley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Script won't insert data to table

I submit the form to insert the data into the table, when I submit the form for this script to process, The "if" statement is true because the "echo" statement in the else says so, but the else is what the script is doing. Can't figure out why.
What am I missing here?



<html><body>

<?php
include ("dbconnect_test.php");

if ($submit == "Submitted")
{
echo ("Submit ='Submitted'");
$query = "insert into tbl_members
(name,chapter,position,category,business_name,addr ess1,address2,city,state,zip,phone,fax,e-mail,web_address) values
('$name','$chapter','$position','$category','$busi ness_name','$address1','$address2','$city','$state ','$zip','$phone','$fax','$e-mail','$web_address')"
;
mssql_query($query)
or die ("unable to Insert Data");

?>

<h2>Thanks!!</h2>
<h2><a href="view.php"> View The List </a></h2>
<?php
}
else
{
echo ("Submit ='Submitted'");
echo "Doing the else";
include("members_test.php");
}
?>
</body></html>

Reply With Quote
  #2  
Old August 18th, 2002, 04:36 AM
rfigley rfigley is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 13 rfigley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Script won't insert data to table

As a followup I've corrected the spelling for the mysql query statement, and streamlined the code partly by removing all the column specs as that is interpreted to insert all columns. I'm still getting the "unable to Insert Data". I'm also using the echo statements to make sure the variables are correct but the script is not inserting them.


<?php
include ("dbconnect_test.php");
echo "<BR>";
echo "Receives ($name)"; echo "Receives ($chapter)";
echo "<BR>";
mysql_query ("INSERT INTO tbl_members",$db)
or die ("unable to Insert Data");


?>

Reply With Quote
  #3  
Old August 18th, 2002, 08:14 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: Script won't insert data to table

You can take out the field names like you said but you still need the VALUES. Like this:
php Code:
Original - php Code
  1. <?
  2. $query = "insert into tbl_members values('$name','$chapter','$position','$category',  '$business_name','$address1','$address2','$city','  $state','$zip','$phone','$fax','$e-mail','$web_address')"
  3. ;?>


HTH

Reply With Quote
  #4  
Old August 20th, 2002, 12:11 AM
bakertrg's Avatar
bakertrg bakertrg is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Scottsdale AZ, US
Posts: 2,253 bakertrg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 48 m 45 sec
Reputation Power: 4
Send a message via Yahoo to bakertrg
RE: Script won't insert data to table

I'm not sure I am following you because it appears you are saying the echo statement in the else is being displayed. If this is the case then your problem is the submit value. Beyond that it's not clear because of the include if you have actually made the connection to the database. Do an !isset check on the db connection. perhaps you should just echo $submit; in both places so you can see what it is as opposed to echoing a line of text. You could also run a foreach to see exactly what you are passing to the page. Lastly you could try and put all the field names in backticks ` this sometimes helps.

B






Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Script won't insert data to table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway