views:

18

answers:

1

So I am working on a site for work that I "inherited" when I started here, and I am having to swim through a lot of code that i am unfamiliar with, namely soap services. The website has a feature that lets you write some things to the db using this createURL service:

$res = $db->Exec('INSERT INTO private_urls (UID, psswrd, profile_id, show_profile, show_portfolio, show_resume, show_message, show_email, show_phone, show_eportfolioaddress, show_major, show_minor, show_academic_interests, show_research_interests, show_career_interests, show_job_interests, created, modified, urlName) VALUES ( ? , ? , ? , ? , ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW(), ?)', 'sssssssssssssssss', $uid, $password, $profile_id, $profile, $portfolio, $resume, $messages, $email, $phone, $eportAddress, $major, $minor, $academicInterests, $careerInterests, $researchInterests, $jobInterests, $urlName); 

Now, my job is to make it so that I can edit that db entry, and not have a duplicate entry (which is the problem I am experiencing). I made new forms, and associated php files that link to an editURL service I made similar to the create one.

MY QUESTION: Regards the syntax of editing this sql statement so that it updates the db with all of these values it is being passed WHERE private_urls.uid=?. I can't figure out how the syntax is supposed to go with the WHERE clause. This is what I have:

$res = $db->Exec('UPDATE private_urls (UID, psswrd, profile_id, show_profile, show_portfolio, show_resume, show_message, show_email, show_phone, show_eportfolioaddress, show_major, show_minor, show_academic_interests, show_research_interests, show_career_interests, show_job_interests, created, modified, urlName) WHERE private_urls.UID = ? VALUES ( ? , ? , ? , ? , ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW(), ?)', 'ssssssssssssssssss', $uid, $uid, $password, $profile_id, $profile, $portfolio, $resume, $messages, $email, $phone, $eportAddress, $major, $minor, $academicInterests, $careerInterests, $researchInterests, $jobInterests, $urlName); 

It obviously isn't working correctly, and I am wondering if my ? following the WHERE clause isn't correctly being associated with the first of the duplicated $uid variables...

Any thoughts?

A: 

Your UPDATE syntax isn't right, you want something like this (simplifed for brevity)

$res = $db->Exec('UPDATE private_urls '.
    'SET psswrd=?, profile_id=?,modified=NOW() '.
    'WHERE UID=?', 
    $password, $profile_id, $uid);
Paul Dixon
Hey thanks for your help! It worked!!
Jeff