Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] MySQL Question


[SOLVED] MySQL Question

Reply
  #1 (permalink)  
Old 05-05-09, 02:34 PM
Dillon Dillon is offline
Newbie Coder
 
Join Date: Feb 2009
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation [SOLVED] MySQL Question

Hello on my website, I have a page which allows the users to update their information. I am not sure how to write out the MySQL Query after they click the update button, I keep getting an error with this one, does anyknow whats wrong with it? Is that how you do a UPDATE (stuffhere) SET (stuff) WHERE (stuffhere) VALUES (stuffhere), I know thats not what I have now, but it didnt work either way...

Here is my query...

PHP Code:

$result mysql_query(UPDATE testtable SET (FirstName='Dillon'LastName='Test',Street='123 Mine St',Town='LA',Zip='12323',State='LA',Email='a@a.com',PhoneHome='111-1111',Attending='No'WHERE (inte='388'FirstName='Dillon'LastName='Test',Street='123 Mine St',Town='tPWN',Zip='12323',State='AL',Email='a@a.com',PhoneHome='111-1111',Attending='Yes')); 

Thanks Alot!

-Dillon
Reply With Quote
  #2 (permalink)  
Old 05-05-09, 05:22 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
$result = mysql_query(UPDATE testtable SET FirstName='Dillon', LastName='Test', Street='123 Mine St', Town='LA', Zip='12323', State='LA', Email='a@a.com', PhoneHome='111-1111', Attending='No' WHERE identifier = 'identifier');

What is the error you are getting? And how are you passing the new data to this query?
Reply With Quote
  #3 (permalink)  
Old 05-05-09, 07:56 PM
Dillon Dillon is offline
Newbie Coder
 
Join Date: Feb 2009
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
It just dosent do doing anything I tried running it via a php webpage, the code is below, and I tried manually typing it into my MySQL manager, and I got an error which said: Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

PHP Code:

//This tells to connect to the MySQL Database, via the provided information above

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

//The query is to insert data into the "Info" table
$query "UPDATE users SET (FirstName='$firstName', LastName='$lastName',Street='$userStre',Town='$userTown',Zip='$userZip',State='$userState',Email='$userEmail',PhoneHome='$userPhone',Attending='$userAttending')  WHERE (inte='$inte', FirstName='$firstNameold', LastName='$lastNameold',Street='$userStreold',Town='$userTownold',Zip='$userZipold',State='$userStateold',Email='$userEmailold',PhoneHome='$userPhoneold',Attending='$userAttendingold')";
$result=mysql_query($query);

echo 
$query;

echo (
"Your changes have been saved!");

mysql_close(); 
Thanks for the reply
-Dillon
Reply With Quote
  #4 (permalink)  
Old 05-06-09, 12:49 AM
dreamluverz's Avatar
dreamluverz dreamluverz is offline
Newbie Coder
 
Join Date: Apr 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
on your query put this to check for mysql error

ex: mysql_error($sql_here) or die(mysql_error())
And upon checking your sql the WHERE must be like AND and not ,

ex: WHERE a='1' AND b='1' AND c='1'
Reply With Quote
  #5 (permalink)  
Old 05-06-09, 09:17 AM
Dillon Dillon is offline
Newbie Coder
 
Join Date: Feb 2009
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, I figured it out, I had the syntax of my query all wrong, I managed to get it working, thanks for replying tho!

-Dillon
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
[SOLVED] Mysql question dkamenov Database 2 02-13-08 12:04 PM
php mysql question jonnekke PHP 1 10-12-07 07:01 AM
Question about MySQL. drewhiggins Database 2 01-25-07 10:14 PM
question about updating a page or database for an, php and mysql updating mikewooten PHP 1 02-12-04 12:11 AM
PHP to MySQL script question...(using a field to update info in MySQL) DisneyFan25863 PHP 4 11-02-03 03:31 AM


All times are GMT -5. The time now is 08:35 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.