Database Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesDatabase Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old January 7th, 2004, 03:09 PM
tsclan tsclan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 tsclan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
inserting into database

I have this php news system with MYSQL and I am finding the simple task annoyingly hard. I have a form where you fill in detail and pess submit and the details go into the database. I have done this before using two seperate pages one with the form in it and the other with the action but now i am wanting to expand my knowledge and wanting the action on the same page so far I have made this

----------------------------------------
<? if($HTTP_POST_VARS['submit']) {

$by=$HTTP_POST_VARS['by'];
$snews=$HTTP_POST_VARS['snews'];
$fnews=$HTTP_POST_VARS['fnews'];
$pass=$HTTP_POST_VARS['pass'];

include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="INSERT INTO webnews (
by,
snews,
fnews)
VALUES(
'".$by."',
'".$snews."',
'".$fnews."')";

mysql_query($query);
echo "Record Updated";
mysql_close();
}
?>



<strong>Insert news
</strong>
<form name="insert" method="post" action="<?=$PHP_SELF?>">
<p>By</p>
<p> <input name="by" type="text" >
</p>
<p>Short News </p>
<p>
<textarea name="snews" cols="50" rows="2" wrap="VIRTUAL"></textarea>
</p>
<p>Full news</p>
<p>
<textarea name="fnews" cols="50" rows="10"></textarea>
</p>
<p>Password </p>
<p>
<input name="pass" type="password" value="">
</p>
<p>
<input type="submit" name="Submit" value="Insert">
</p>
</form>
--------------------------------------

Thank you

Reply With Quote
  #2  
Old January 7th, 2004, 04:03 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
And the problem is...

Reply With Quote
  #3  
Old January 7th, 2004, 04:19 PM
tsclan tsclan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 tsclan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It wont put any of the data into the databse when I press submit

Reply With Quote
  #4  
Old January 7th, 2004, 10:36 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
try outputting the SQL statement... i've found that generally leads me to the solution when i have a problem...

it may help to output the variables as well, to make sure they're getting passed properly...

Reply With Quote
  #5  
Old January 8th, 2004, 03:12 PM
tsclan tsclan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 tsclan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well I have updated it and I can now get the values to be outputed but not get into the databse and if anyone can see what is wrong please tell me

PHP Code:
<?  if($HTTP_POST_VARS['submit']) { 
$auther=$HTTP_POST_VARS['auther']; 
$snews=$HTTP_POST_VARS['snews']; 
$fnews=$HTTP_POST_VARS['fnews']; 


echo 
"$fnews";
echo 
"$snews";
include(
"dbinfo.inc.php");

$connection=mysql_connect("localhost",$username$password) or die("Unable to connect!");

print 
" it does not out put it here";
print 
" $auther<br>";
print 
" $fnews<br>";
print 
" $snews<br>";


mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database"); 

$query="INSERT INTO webnews ( 
            auther, 
            snews, 
            fnews) 
        VALUES( 
            '"
.$auther."', 
            '"
.$snews."', 
            '"
.$fnews."')"
            
$result2=mysql_query($query) or die("Error in query:".mysql_error());

 }
 
if (
$result2) {
echo 
mysql_affected_rows()." row inserted into the database effectively."
mysql_close($connection);
      } 


print 
" here is where it out puts the data";
print 
" $auther<br>";
print 
" $fnews<br>";
print 
" $snews<br>";
?>

Reply With Quote
  #6  
Old January 21st, 2004, 09:48 PM
cbunting cbunting is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 19 cbunting User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Did you ever figure this out? By looking at your provided code, you have "by" as the text box for the Author but you have "auther" in your code. So change "by" to "auther" in your form and it should work.

Chris

Reply With Quote
  #7  
Old January 22nd, 2004, 12:01 PM
tsclan tsclan is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 tsclan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
yes i did get this working thanks for all the help guys

Reply With Quote
  #8  
Old February 22nd, 2004, 02:25 PM
kamat kamat is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 kamat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Enter data to the database through tabular page

I want to make a table containing some fields like date
,customer_name etc. using this table i want to enter the
data to the database But i wont know how to edit the
table through html/php page. Please help

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesDatabase Development > inserting into database


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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