Current location: Hot Scripts Forums » Programming Languages » PHP » Beginner: "UPDATE"-Command in PHP


Beginner: "UPDATE"-Command in PHP

Reply
  #1 (permalink)  
Old 10-09-03, 08:45 AM
bmueller77 bmueller77 is offline
New Member
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Beginner: "UPDATE"-Command in PHP

Hi altogether,

I want to run SQL-Commands like "UPDATE" in a PHP-Script.
Can anyone please tell me the syntax?

I need two ways to update fields in my MySQL-Database:

- increase a number in a field by pressing a form-button
- run an UPDATE-Command when loading the PHP-File

Thanks

Bjoern
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-09-03, 06:41 PM
ermau's Avatar
ermau ermau is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Florida, USA
Posts: 240
Thanks: 0
Thanked 0 Times in 0 Posts
Try researching before you ask, this took me all of 5 seconds (literally) to find.

http://www.mysql.com/doc/en/UPDATE.html
MySQL -> Search -> Update
__________________
PHP / mySQL Developer
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-10-03, 04:57 AM
bmueller77 bmueller77 is offline
New Member
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
I don't need the syntax of the SQL-Commands.

I need help to integrate it in PHP.

Like this (doesn't work at all)

if ($Submit == "count03")
{$sql = "UPDATE DB3 SET VAR1 = VAR1+1 Where User = 'User01";}
else ?>
<form method="post" action="<?php echo $PHP_SELF?>">
<input type="Submit" name="count3" value>
</form>
<?php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-10-03, 05:04 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
it doesn't work because you didn't send the query to database ???
you need to use mysql_query(); to send your query ..
in your post you only defined the query but didn't send it ..
it should be something like this :
PHP Code:

if ($Submit == "count03"
{
$sql "UPDATE DB3 SET VAR1 = VAR1+1 Where User = 'User01";
$update=mysql_query($sql)or Die(mysql_error());
$check=mysql_affetced_rows();

if ( 
$check == ) {
echo
'Database was updated succesfully ..';
} else {
echo
'database wasn\'t updated !! please try again later ..';
} else { 
try it and see
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]

Last edited by NeverMind; 10-10-03 at 05:08 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
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
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 03:22 AM
PHP Dudes - Hi All stuart New Members & Introductions 4 05-03-04 02:22 PM
Custom PHP Scripts BdSBB Job Offers & Assistance 3 12-07-03 10:49 AM
PHP Triad/Upload form eddyvlad PHP 6 10-07-03 12:17 AM
Ad management and optimisation using php surebetdmg PHP 0 08-28-03 07:45 PM


All times are GMT -5. The time now is 01:03 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.