PHP wont run multiple queries -
this php script, "virtual companies" on website. made that, when user sends credits/pixels company, should removed user , company's account.
the script not returning errors , sends user "/me" in end, think problem queries not being run.
<?php if (isset($_post['sendmoneyvirk'])) { $credits = mysql_real_escape_string($_post['credits']); $creditsnew = preg_replace("/[^0-9]/","", $credits); $pixels = mysql_real_escape_string($_post['pixels']); $pixelnew = preg_replace("/[^0-9]/","", $pixels); $getuserinfo = mysql_query("select activity_points, username, credits, online users id = ".intval($_session['user']['id'])); while($userinfo = mysql_fetch_array($getuserinfo)) { $pixelsval = $userinfo['activity_points']; $creditsval = $userinfo['credits']; } if ($creditsnew > $creditsval) { header('location: index.php?url=me&error=c1'); exit; } if ($pixelsnew > $pixelsval) { header('location: index.php?url=me&error=p1'); exit; } function strip_tags_content($text, $tags = '', $invert = false) { preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags); $tags = array_unique($tags[1]); if(is_array($tags) , count($tags) > 0) { if($invert == false) { return preg_replace('@<(?!(?:'. implode('|', $tags) .')\b)(\w+)\b.*?>.*?</\1>@si', '', $text); } else { return preg_replace('@<('. implode('|', $tags) .')\b.*?>.*?</\1>@si', '', $text); } } elseif($invert == false) { return preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text); } return $text; } mysql_query("update users set credits = credits - '".strip_tags_content($creditsnew)."' id = '$userid'")or die(mysql_error()); mysql_query("update companies set credits = credits + '".strip_tags_content($creditsnew)."' id = '$virkidnew'")or die(mysql_error()); mysql_query("update users set activity_points = activity_points - '".strip_tags_content($pixelsnew)."' id = '$userid'")or die(mysql_error()); mysql_query("update companies set pixels = pixels + '".strip_tags_content($pixelsnew)."' id = '$virkidnew'")or die(mysql_error()); header('location: me'); exit; } ?>
firstly - should @ using mysql pdo mysql_query 'old , busted' (read here)
seccondly, can take @ happening on mysql_query using mysql_affected_rows() - tell how many rows changed per update - if answer 0 / of queries because have problem query - suggest grabbing query , running in directly against database (using phpmyadmin or similar) debug it.
obviously code snippet, looks $userid empty / not set - worth looking @ that.
Comments
Post a Comment