mysql - Perform multiple SQL queries with PHP -
i have web form should store info 2 different tables in database. in includes, have php file performs necessary queries. web form should store 2 pieces of information: xp value beingness submitted form users table, , article id completed_quests table. individually, queries work should. however, if seek perform both queries together, first query performed , sec 1 ignored. how create both queries run 1 time user hits submit button?
(edit) have updated code. clarify, there other code in php file defines variables used in these queries. these 2 queries trying run , needed know how run both queries seemed ignoring sec 1 (the update). working, running issue of insert query creating duplicate entries.
(edit) have updated code again. used on duplicate key update avoid duplicate entries in table. made sure user id primary key in table , functioning perfectly.
mysql_select_db("questroot_joomla", $con); mysql_query("insert arp2i_completed_quests (user_id, content_id) values ($userid, $currentarticle) on duplicate key update content_id=$currentarticle"); mysql_query( "update arp2i_users" . " set userxp= $userxp" . " id = $userid"); mysql_close($con);
$sql = "insert `arp2i_completed_quests` (`user_id`, `content_id`) values ('$_post[current_user]', '$_post[current_article]')"; /* it's not in $sql ->> */ "update `arp2i_users` set `userxp`= '$_post[xpvalue]' `id` = '$_post[current_user]'";
try this:
$sql = "insert `arp2i_completed_quests` (`user_id`, `content_id`) values ('$_post[current_user]', '$_post[current_article]'); update `arp2i_users` set `userxp`= '$_post[xpvalue]' `id` = '$_post[current_user]'";
php mysql sql sql-server joomla
No comments:
Post a Comment