/    Sign up×
Community /Pin to ProfileBookmark

what’s wrong with this code [ urgent ]

[COLOR=Navy] if(isset($_POST[‘BtnUpdate’])) {

$id = $_POST[‘pid’]; // form textfield
$pqty = $_POST[‘pqty’]; // form textfield
$nqty = $_POST[‘list’]; // form textfield

$cqtys = (is_array($nqty)) ? implode(‘,’, $nqty) : $nqty;
echo ‘changed: ‘.$cqtys;
$ids = (is_array($id)) ? implode(‘,’, $id) : $id;
echo ‘id: ‘.$ids;
$oqty = (is_array($pqty)) ? implode(‘,’, $pqty) : $pqty;
echo ‘Original: ‘.$oqty;

$obj_db->query(“update basket set b_quantity IN($cqty) where session=’$code’ and p_id IN($ids) and b_quantity IN($oqty)”);
} [/COLOR]

it returns an error message in query

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 15.2006 — I suspect it should be:
<i>
</i>$obj_db-&gt;query("update basket set b_quantity [color=red]= $cqty[/color]
where session='$code' and p_id IN($ids) and b_quantity IN($oqty)");
Copy linkTweet thisAlerts:
@mahfoozauthorNov 15.2006 — ok

that's fine but i want to change multiple quatities at the same time to database therefore i used [COLOR=DarkRed]$cqty[/COLOR] as an array.
Copy linkTweet thisAlerts:
@NogDogNov 15.2006 — Unfortunately, your database engine does not know anything about PHP arrays, so you will have to send it explicit scalar values: probably a separate query for each quantity to be updated.
×

Success!

Help @mahfooz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...