updating database

This is a discussion on "updating database" within the PHP Forum section. This forum, and the thread "updating database are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 7th, 2006, 03:04
Junior Member
Join Date: Jun 2006
Location: usa
Age: 29
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation updating database

i want to update a databse using a password and a username in the row i am just having some trouble here is my code

PHP: Select all

<?
 
 $host 
"localhost";
$username "localhost";
$password "abc123";
$database "contacts";
$db mysql_connect($host$username$password);
mysql_select_db($database);
$BusinessName = (isset($_POST['BusinessName']) ? $_POST['BusinessName'] : ""); 
 
$Slogan = (isset($_POST['Slogan']));
 
$Business_Address = (isset($_POST['Business_Address']));
 
$Tel = (isset($_POST['Tel']));
 
$Website = (isset($_POST['Website']));
 
$Email = (isset($_POST['Email']));
 
$Member_Status = (isset($_POST['Member_Status']));
 
$Fax =(isset($_POST['Fax']));
 
$type = (isset($_POST['type']));
 
$make = (isset($_POST['make']));
 
$Categories = (isset($_POST['Categories']));
 
$Keyword = (isset($_POST['Keyword']));
 
$Picture1 =  (isset($_POST['Picture1']));
 
$Headline =  (isset($_POST['Headline']));
 
$Slogan2 = (isset($_POST['Slogan2']));
 
$Description1 = (isset($_POST['Description1']));
 
$Description2 = (isset($_POST['Description2']));
 
$Description3= (isset($_POST['Description3']));
 
$Contact2 = (isset($_POST['Contact2']));
 
$Picture2 =  (isset($_POST['Picture2']));
 
$Picture3 = (isset($_POST['Picture3']));
 
$Picture4 =  (isset($_POST['Picture4']));
 
$User_Name = (isset($_POST['User_Name']));
 
$Password = (isset($_POST['Password']));
 
 
$User_Name mysql_query("SELECT `Password` FROM `Business_Info` WHERE `User_Name` = '$User_Name'"); 
 
if(
$Password == $Password
 
 

$query "UPDATE `Business_Info` SET `BusinessName`= '$BusinessName', `Slogan`='$Slogan', 
 `Business_Address`='$Business_Address', 
`Tel`='$Tel', `Website`='$Website', `Email`='$Email', `Member_Status`='$Member_Status', 
`Fax`='$Fax', `type`='$type', `make`='$make', `Categories`='$Categories', `Keyword`='$Keyword', 
`picture1`='$Picture1', `Headline`='$Headline', `Slogan2`='$Slogan2', `Description1`='$Description1', 
`Description2`='$Description2', `Description3`= '$Description3', `Contact2`='$Contact2', `Picture2`='$Picture2',
 `Picture3`='$Picture3', `Password`='$Password' WHERE `User_Name`='$User_Name'"
;
$result mysql_query($query) or die(mysql_error()); 
 
  } 
 
    else 
    { 
 
  echo 
"Incorrect Password or User Name Try again "
  exit; 

echo 
"$query" ;
 
?>

this is what i am displaying

PHP: Select all

 
UPDATE 
`Business_InfoSET `BusinessName`= '', `Slogan`='', `Business_Address`='', `Tel`='', `Website`='', `Email`='', `Member_Status`='', `Fax`='', `type`='', `make`='', `Categories`='', `Keyword`='', `picture1`='', `Headline`='', `Slogan2`='', `Description1`='', `Description2`='', `Description3`= '', `Contact2`='', `Picture2`='', `Picture3`='', `Password`='1' WHERE `User_Name`='Resource id #3' 
Reply With Quote

  #2 (permalink)  
Old Oct 7th, 2006, 16:42
Junior Member
Join Date: Jun 2006
Location: Wisconsin
Age: 30
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating database

is there an error?
Reply With Quote
  #3 (permalink)  
Old Oct 7th, 2006, 17:15
Junior Member
Join Date: Jun 2006
Location: usa
Age: 29
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating database

Quote:
Originally Posted by flann View Post
is there an error?

it is no lettting me update all i am getting is the samething is on the update query
Reply With Quote
  #4 (permalink)  
Old Oct 7th, 2006, 22:25
Reputable Member
Join Date: Nov 2005
Posts: 127
Thanks: 0
Thanked 0 Times in 0 Posts
Re: updating database

I think it will work if you take the `s out like below, ive never used those for this but they may not make a difference. The only other reason I can see is if you have some of your fields wrongly labelled (you do have picture1 and the others as Picture2 and Picture3).

PHP: Select all

$query "UPDATE Business_Info SET BusinessName='$BusinessName', Slogan='$Slogan', 
 Business_Address='$Business_Address', 
Tel='$Tel', Website='$Website', Email='$Email', Member_Status='$Member_Status', 
Fax='$Fax', type='$type', make='$make', Categories='$Categories', Keyword='$Keyword', 
picture1='$Picture1', Headline='$Headline', Slogan2='$Slogan2', Description1='$Description1', 
Description2='$Description2', Description3= '$Description3', Contact2='$Contact2', Picture2='$Picture2',
 Picture3='$Picture3', Password='$Password' WHERE User_Name='$User_Name'"
;
$result mysql_query($query) or die(mysql_error()); 
Reply With Quote
  #5 (permalink)  
Old Oct 8th, 2006, 20:32
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: updating database

All you are actually doing is setting all your variables, $slogan, etc, to 'true' or 'false'. The result of your test - isset($_POST['slogan']);, etc.

What you should be doing is something like:
Code: Select all
if(isset($_POST['slogan'])){
  $slogan = $_POST['slogan'];
}
Reply With Quote
Reply

Tags
update database

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
updating database with password franknu PHP Forum 1 Oct 23rd, 2006 23:30
XML Code for transfering data from one SQL Server Database to another database plolla Other Programming Languages 1 Aug 3rd, 2006 18:37
updating a database using a drop down barnet Classic ASP 4 Jan 18th, 2006 01:28
Updating Database Using ASP and XML cmomah Classic ASP 0 Oct 12th, 2005 20:22
Updating Database Through XML cmomah Other Programming Languages 0 Oct 12th, 2005 20:21


All times are GMT. The time now is 08:14.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43