LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-16-2006, 03:36 AM   #1
jayakrishnan
Member
 
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992

Rep: Reputation: 30
Whats wrong with this PHP code


Quote:
$rS = $db_conn->execute("update member_details set member_details.uno1='$uno1' &member_details.v_rcpt_no='$v_rcpt_no' & member_details.uno2='$uno2' & member_details.vno='$vno' & member_details.rcpt_no='$rcpt_no' & member_details.vdate='$v_date' & member_details.name='$name' & age=$age & member_details.fhname='$fhname' & member_details.edu='$edu' & member_details.address='$address' & member_details.job='$job' & member_details.phone='$phone'& member_details.caste='$caste' & member_details.district='$district' & member_details.taluk='$slave' & member_details.blocks='$blocks' & member_details.anusal='$anusal' where member_details.mem_id='$mem_id';");
I have a php program which is used to update a MS Access database thru DSN-Less

The above code is the one which does the updation, but somehow it doesnt work , nothing happens , but when i change the update code to

Quote:
$rS = $db_conn->execute("update member_details set member_details.anusal='$anusal' where member_details.mem_id='$mem_id';");
it works fine.

All the variables are initialized properly and aren't set to null

Any suggestions , comments?


Thanks

Regards
JayaKrishnan

Last edited by jayakrishnan; 12-16-2006 at 03:37 AM.
 
Old 12-16-2006, 04:27 AM   #2
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 33
i believe you want a comma (,) instead of an ampersand (&) in your sql statement

another way of doing this would be
UPDATE blah SET (field1, field2, field3) VALUES(value1, value2, value3) WHERE 1=1

ps: i hope you do some escaping on those variables
 
Old 12-16-2006, 05:16 AM   #3
jayakrishnan
Member
 
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992

Original Poster
Rep: Reputation: 30
Hey , i got it working , yes it was the comma issue , thanks for the reply Nathanael

Regards
JayaKrishnan
 
Old 12-19-2006, 02:47 AM   #4
jayakrishnan
Member
 
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992

Original Poster
Rep: Reputation: 30
Question

Can i pass multiple field name in the where clause like this

Quote:
$rS = $db_conn->execute("update member_details set member_details.mem_id='$mem_id',member_details.mem_name='$mem_name' ,member_details.rname='$rname',member_details.relationship='$rel' ,member_details.gender='$gender',member_details.age='$age' ,member_details.education='$edu',member_details.work='$work' where member_details.mem_id='$mem_id',member_details.rname='$rname' , member_details.relationship='$rel' , member_details.gender='$gender' , member_details.age='$age';");
Thanks
Jay
 
Old 12-19-2006, 02:52 AM   #5
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 33
in the where, order by clauses you will want to use AND or OR

how about taking a stroll through www.w3schools.com
they have a great sql tutorial.
 
Old 12-19-2006, 03:02 AM   #6
jayakrishnan
Member
 
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992

Original Poster
Rep: Reputation: 30
Thanks for the quick reply Nathanael .
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP something wrong with the code :( Alexander.s Programming 2 04-22-2005 04:27 AM
whats wrong with this code in grub? HmmLinux Linux - General 2 11-12-2004 03:50 AM
Whats wrong with this simple code Boffy Programming 6 10-31-2004 01:16 PM
whats wrong with this simple code?? laclac01 Programming 3 08-23-2004 03:52 PM
php session array : What's wrong in this code vikaspa Programming 2 03-30-2004 08:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration