Jump to content

toonz

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by toonz

  1. I got it! Here is the code that I got to work <?php //Include Common Files @1-8E58AE89 define("RelativePath", ".."); include(RelativePath . "/Common.php"); include(RelativePath . "/Template.php"); include(RelativePath . "/Sorter.php"); include(RelativePath . "/Navigator.php"); //End Include Common Files error_reporting(E_ALL); ini_set('display_errors', 1); //echo var_dump($_POST); // foreach ($_POST as $key => $value) { // echo '<p>'.$key.'</p>'; // foreach($value as $k => $v) // { // echo '<p>'.$k.'</p>'; // echo '<p>'.$v.'</p>'; // echo '<hr />'; // } //} $con = mysqli_connect("localhost",yada yada yada) or die ("could not connect to mysql"); if ($sPOST= $_POST['retired']) { $aFromPOST = explode (',',$sPOST); //echo var_dump($aFromPOST) .'is retired'; global $show_id, $con; $show_id = trim($aFromPOST[1]); //header( "Refresh:3; url=books.php?show_id=".$show_id, true, 303); mysqli_query($con,"UPDATE ttb_books SET status_id = '2' WHERE show_id='".$show_id."'"); mysqli_close($con); header("Location:books.php?show_id=".$show_id); die(); } elseif ($sPOST= $_POST['upcoming']){ $aFromPOST = explode (',',$sPOST); //echo var_dump($aFromPOST) .'is upcoming'; global $show_id; $show_id = trim($aFromPOST[1]); //header( "Refresh:3; url=books.php?show_id=".$show_id, true, 303); mysqli_query($con,"UPDATE ttb_books SET status_id = '37' WHERE show_id='".$show_id."'"); mysqli_close($con); header("Location:books.php?show_id=".$show_id); die(); } elseif ($sPOST= $_POST['current']){ $aFromPOST = explode (',',$sPOST); //echo var_dump($aFromPOST) .'is current'; global $show_id; $show_id = trim($aFromPOST[1]); //header( "Refresh:3; url=books.php?show_id=".$show_id, true, 303); mysqli_query($con,"UPDATE ttb_books SET status_id = '1' WHERE show_id='".$show_id."'"); mysqli_close($con); header("Location:books.php?show_id=".$show_id); die(); } ?>
  2. I changed the 'retired' part of the IF statement to if ($sPOST= $_POST['retired']) { $aFromPOST = explode (',',$sPOST); //echo var_dump($aFromPOST) .'is retired'; //echo '<p>'. $aFromPOST[0]; //echo '<p>'. $aFromPOST[1]; global $show_id, $con; $show_id = trim($aFromPOST[1]); //header( "Refresh:3; url=books.php?show_id=".$show_id, true, 303); $sql = "UPDATE ttb_books SET status_id = '2' WHERE show_id='".$show_id."'"; //the code is dying here if (!mysqli_query($sql,$con)) { die('<p>Error: ' . mysqli_error()); } $db = new database(); $db->mysqli_query($sql, $con); header("Location:books.php?show_id=".$show_id); die(); } to test the connection and it's not spitting out any errors in the output. It shows "Error:" with nothing after it, so I can't tell if it's a connection issue or a sql issue
  3. Ok, I completely changed the layout and it seems to be dying at the $sql line. Below is the updated code. The echo outputs are showing the exact values I need based on the button being clicked, and the $show_id is capturing the correct value. The form on the html page: <center><table width=25%> <tr><td valign="top" align="center"> <!-- ---- retired --- --> <form method="post" action="updatethis.php" name="form1"> <input type="image" src="../images/icon-Red_Light.png" width="20" name="retired" alt="Set status to Out of Print" title="Set status to Out of Print" onclick="return confirm('Set ALL status to Out of Print?')"> <input name="retired" type="hidden" value="retired,{show_id}"> </form> </td><td valign="top" align="center"> <!-- --- upcoming --- --> <form method="post" action="updatethis.php" name="form2"> <input type="image" src="../images/icon-Yellow_Light.png" width="20" name="upcoming" alt="Set status to Upcoming Release" title="Set status to Upcoming Release" onclick="return confirm('Set ALL status to Upcoming Release?')"> <input name="upcoming" type="hidden" value="upcoming,{show_id}"> </form> </td><td valign="top" align="center"> <!-- --- current --- --> <form method="post" action="updatethis.php" name="form3"> <input type="image" src="../images/icon-Green_Light.png" width="20" name="current" alt="Set status to In Print" title="Set status to In Print" onclick="return confirm('Set ALL status to In Print?')"> <input name="current" type="hidden" value="current,{show_id}" > </form> </td></tr> </table></center> updatethis.php <?php //Include Common Files @1-8E58AE89 define("RelativePath", ".."); include(RelativePath . "/Common.php"); include(RelativePath . "/Template.php"); include(RelativePath . "/Sorter.php"); include(RelativePath . "/Navigator.php"); //End Include Common Files if ($sPOST= $_POST['retired']) { $aFromPOST = explode (',',$sPOST); //echo var_dump($aFromPOST) .'is retired'; echo '<p>'. $aFromPOST[0]; echo '<p>'. $aFromPOST[1]; global $show_id; $show_id = trim($aFromPOST[1]); header( "Refresh:3; url=books.php?show_id=".$show_id, true, 303); $sql = "UPDATE ttb_books SET status_id = '2' WHERE show_id='".$show_id."'"; //the code is dying here $db = new database(); $db->myquery($sql, 1); //header("Location:books.php?show_id=".$show_id); die(); } elseif ($sPOST= $_POST['upcoming']){ $aFromPOST = explode (',',$sPOST); //echo var_dump($aFromPOST) .'is upcoming'; echo '<p>'. $aFromPOST[0]; echo '<p>'. $aFromPOST[1]; global $show_id; $show_id = trim($aFromPOST[1]); header( "Refresh:3; url=books.php?show_id=".$show_id, true, 303); $sql = "UPDATE ttb_books SET status_id = '37' WHERE show_id='".$show_id."'"; $db = new database(); $db->myquery($sql, 1); //header("Location:books.php?show_id=".$show_id); die(); } elseif ($sPOST= $_POST['current']){ $aFromPOST = explode (',',$sPOST); //echo var_dump($aFromPOST) .'is current'; echo '<p>'. $aFromPOST[0]; echo '<p>'. $aFromPOST[1]; global $show_id; $show_id = trim($aFromPOST[1]); header( "Refresh:3; url=books.php?show_id=".$show_id, true, 303); $sql = "UPDATE ttb_books SET status_id = '1' WHERE show_id='".$show_id."'"; $db = new database(); $db->myquery($sql, 1); //header("Location:books.php?show_id=".$show_id); die(); } ?> I only have the header above the sql as a test, to redirect after I see the echo output to verify it sees which of the 3 form buttons I am clicking. They will be commented back out after I get this operational. In the current code, it loads fine, displays the output, then sends me back to where I was after a few seconds. When I comment the first header and echos out and open up the bottom headers, the page won't load and gives a 500 error. So something about the $sql line it crashing it, but I can't see why. I've compared it to tons of other similar statements online and it looks the same. Can someone spot something I am missing? Thank you again for the help.
  4. This is what it looks like now function UpdateAllShowBooks() { echo "<pre>"; print_r($_POST); echo "</pre>"; if(strlen(($_POST['retired'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '2' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } if(strlen(($_POST['upcoming'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '37' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } if(strlen(($_POST['current'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '1' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } }
  5. Just tried putting it in the function, but not in one of the IF statements. Page doesnt load now; HTTP ERROR 500 EDIT: I got the page to load with it in the function now, but there is no output displayed after I click on a POST image
  6. The php function already doesnt recognize the form POST, so if I don't use the <?php ?> in the HTML file itself, nothing would even register and display
  7. I tried using this above the form in the html file <?php echo "<pre>"; print_r($_POST); echo "</pre>"; ?> but it displays on the page like this on reload, so it isnt recognizing it as php code "; print_r($_POST); echo ""; ?> what changes do I need to make to my original code in order for it to be posting properly to the underlying function?
  8. I tried using echo before in the html file but it wasnt loading anything. How do I display the POST value so I can actually see it when I reload the html file in the browser? Thank you
  9. I am trying to have an UPDATE query run when I click an image on a web page. I just need to have the image call the function to run the mysql from the corresponding php file. The image is a form object, which I need the php function to recognize when it is clicked, and then run the query(ies) within. I don't really know much php, so the php code is based on a snippet I have from one of my other sites, which works fine over there, but I am missing something here that is keeping it from doing the same here. The page already loads and displays all values in a list associated with $show_id, so that variable is already being pulled from the web page in to the php code. I'm not going to paste the entire books.php file here as there are too many things it does which doesnt have anything to do with this little add-on I am making. I just need to be able to pull that variable in to the query below and have it run when I click on the icon associated with it. The php file also already has the proper config and settings files linked to it that connect to the database, so I do not need to set that up here. It is just a form, calling a function, and running the query. It is also not visible to the user side. It is in an admin page, only visible and accessible to me. This is code I have in the php file: function UpdateAllShowBooks() { if(strlen(($_POST['retired'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '2' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } if(strlen(($_POST['upcoming'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '37' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } if(strlen(($_POST['current'])) > 0){ $sql = "UPDATE ttb_books SET status_id = '1' WHERE show_id='$show_id'"; $db = new database(); $db->myquery($sql, 1); header('Location:books.php?show_id=$show_id'); die(); } } This is the current image/form html: <center><table width=25%> <tr><td valign="top" align="center"> <!--<form method="post" action="books.php?show_id={show_id}">--> <form method="post" action="books.php" name="retired"> <input type="image" src="../images/icon-Red_Light.png" width="20" name="retired" alt="Set status to Out of Print" title="Set status to Out of Print" onclick="return confirm('Set ALL status to Out of Print?')"> <input name="shid1" type="hidden" id="shid1" value="{show_id}" /> </form> </td><td valign="top" align="center"> <form method="post" action="books.php" name="upcoming"> <input type="image" src="../images/icon-Yellow_Light.png" width="20" name="upcoming" alt="Set status to Upcoming Release" title="Set status to Upcoming Release" onclick="return confirm('Set ALL status to Upcoming Release?')"> <input name="shid2" type="hidden" id="shid2" value="{show_id}" /> </form> </td><td valign="top" align="center"> <form method="post" action="books.php" name="current"> <input type="image" src="../images/icon-Green_Light.png" width="20" name="current" alt="Set status to In Print" title="Set status to In Print" onclick="return confirm('Set ALL status to In Print?')"> <input name="shid3" type="hidden" id="shid3" value="{show_id}" /> </form> </td></tr> </table></center> So clicking on the form image would call the function with that mysql string and update all items in the list accordingly. At this time, when I click the image, it reloads the page fine, but it is not activating the sql in the function and making the Update occur. Thank you for any help you can provide. I really appreciate it.
  10. ok, I plugged in the code that darkfreaks posted. it doesnt give any errors on the page, but it doesnt appear to be working. it reloads the page after clicking the button that is tied to the code as it should, but it doesnt delete the record from tbl_trade nor update the records in tbl_users_ctoons. below is the code that is currently attached to the button in it's simplest form (removing my lines that were commented out). it deletes the record from tbl_trade, but doesnt yet have any of the code that would update the other table records first before doing the deletion. $delid = $_GET['del_id']; if($delid > 0) { $del = new database(); $del->where("trade_id={$delid}"); $del->delete("tbl_trade"); header("Location:manage_tradeboard.php"); exit(); } I dont know why the code posted by darkfreaks wasnt working since it looks like it should, but there is something its lacking. it wouldnt even delete the record from tbl_trade.
  11. I am trying to update a piece of code, using and editing something similar from another page. What it needs to do is update the ctoon location to 1 when, on the admin control panel, we close a listing on the site's trade board. At this time it has only been deleting the trade record but I am trying to have it update the ctoon record in tbl_users_ctoons first, then delete the trade record. Below is the work in progress, with the lines not yet working commented out and the current lines uncommented. Any help you can give with this would be a HUGE help. Thanks in advance up until now it has only deleted the associated record in tbl_trade based on the del_id. it should also be looking in tbl_trade.trade_toonid (which is a comma delimited field), use the IN function and find all matching values in tbl_users_ctoons.usrctoon_id, and update the location field value to 1 in only those matching records. $delid = $_GET['del_id']; //if($delid > 0 && ( is_array($trade_toonid) && sizeof($trade_toonid) > 0)) { if($delid > 0) { //$user_toons = implode(",", $trade_toonid); //$update_ctoons = "update tbl_users_ctoons set location=1 where ("trade_id={$delid}") and usrctoon_id in ($user_toons)"; //$del = new database(); //$del->myquery($update_ctoons,1); //$del_trade = "delete from tbl_trade where ("trade_id={$delid}")"; //$del = new database(); //$del->myquery($del_trade,1); $del = new database(); $del->where("trade_id={$delid}"); $del->delete("tbl_trade"); header("Location:manage_tradeboard.php"); exit(); }
  12. yes, the query Im trying to add will pull a static value from that field to the 2 separate files. the second file will use the value which will be a point value (donation_pts). it awards that value to the player sending the donation. the 2nd file will use the other field (arcade_multiplier) to multiply against the amount of points they receive from playing an arcade game. I see from my post that my paste for the first file was before I had changed the SELECT query to the proper "donation_pts" value. Even after changing, it wasnt working so there is something I didn't do right in both files
  13. would that work, even if the SELECT query I had added was pulling that field from a different table?
  14. Can anyone help with this? I can even pay a little for the assistance. I just want to get this done soon. Thanks
  15. Im not much of a coder, and I obviously did this wrong since it is not working. Im trying to bring a new field value in to an existing php file. I created a new table, and an admin page to control that field. I cant, however, figure out how to use that value in a different php file. Actually, there are 2 files. Each using a different field from that new table. I will post what my current code is below with the additions I tried to add. I bolded the lines that contain the tags Im trying to use. Any and help you can give in fixing this to make it work is greatly appreciated. <?php # INCLUDE ALL NECESSARY FILES. include_once("Constants.php"); include_once("Database.php"); include_once("SiteSetting.php"); [b]$query = "SELECT arcade_multiplier FROM tbl_point_rewards"; mysql_query($query) or die("Invalid query". mysql_error() ); $result = mysql_fetch_array($result); $arcade_multiplier = $result["arcade_multiplier"];[/b] $dbObj = new database(); # SAVE ARCADE GAME POINTS INTO THE DATABASE function saveGamePoints( $game_id, $user_id, $game_score, $calculate_score_flag, $play_date ){ global $dbObj; $user_max_plays = getUserMaxPlaysLimit( $user_id, $game_id ); //$_SESSION["arcade_game"]["save_score"] = ($user_max_plays < $_SESSION["arcade_game"]["max_plays"]) ? "yes" : "no" ; if($user_max_plays < $_SESSION["arcade_game"][$_SESSION["url_gameid"]]["max_plays"]){ $total_points = calculatePointRatio($game_id, $game_score); //$total_points = $game_score; $x_gameid = md5($game_id); if($_SESSION["arcade_game"][$x_gameid]["play_time"] > 0){ $playTime['start'] = $_SESSION["arcade_game"][$x_gameid]["play_time"]; $playTime['end'] = time(); $playTime = ($playTime['end'] - $playTime['start']); } else { $playTime = 0; } # update total points into main score [b] $update_sql = "update tbl_users set points_gained = (points_gained+(".ceil($total_points)." * $arcade_multiplier)) where usrid={$user_id}";[/b] $rs = mysql_query($update_sql) or die("Invalid query: {$update_sql} - ". mysql_error()); $table = "tbl_arcade_game_score"; $fields = array("game_id", "user_id", "game_score", "calculate_score_flag", "play_date", "game_time"); $values = array($game_id, $user_id, $game_score, $calculate_score_flag, $play_date, $playTime); // return $dbObj->cgi( $table, $fields, $values, 1 ); $insertid = $dbObj->cgi( $table, $fields, $values, "" ); $ceiling_point = getCeiling($game_id); if($game_score >= $ceiling_point) { $chk_authourity = isAlreadyTrophyOwner($user_id, $game_id); //if($chk_authority < 1) if($chk_authourity < 1) { # store award details into the database (tbl_trophy_award) //$trophy_id = getTrophy( $game_id ); $trophy = getTrophyDetails($game_id); $trophy_id = $trophy['ctoon_id']; $tbl_fields = array('userid', 'game_id', 'award_date', 'trophy' ); $tbl_values = array($user_id, $game_id, $play_date, $trophy_id ); $insert_tbl_trophy_award_id = $dbObj->cgi('tbl_trophy_award', $tbl_fields, $tbl_values , "" ); # award trophy to user (tbl_users_ctoons) $table = "tbl_users_ctoons"; $fl = array("usrid", "ctoon_id", "del_status", "ctoons_auction", "auction_id", "location", "batpts"); $vl = array($user_id, $trophy_id, '0', '', 0, 1, 0); $dbObj->cgi($table, $fl, $vl , "" ); # send a pm to the user about the trophy include_once("send_pm_message.php"); $game = getGameDetails($game_id); $msgSub = "Grats! You just got a trophy!"; $message = "Grats! You got the ".$trophy["toon_name"]." trophy for the ".$game["game_name"]." game!<br> <img src=\"{$game['path']}\">"; //echo $message; //echo "<br><hr><br>"; sendMessage($user_id, 0, 0, $msgSub, $message, 1); sendMessage(2034, $user_id, 0, $msgSub, $message, 1); } } return $insertid; } }//end function function getCeiling($game_id) { $sql = "SELECT ceiling FROM tbl_game WHERE game_id = '".$game_id."'"; $rs = mysql_query($sql); $result = mysql_fetch_assoc($rs); return $result['ceiling']; } function isAlreadyTrophyOwner($user_id, $game_id) { $sql = "SELECT * FROM tbl_trophy_award WHERE game_id = {$game_id} and userid = {$user_id}"; $rs = mysql_query($sql); $num_rows = 0; $num_rows = mysql_num_rows($rs); if($num_rows > 0) { return $num_rows; } else { return $num_rows; } } # calculate game ratio function calculatePointRatio($game_id, $game_score){ //return $game_score; $sql = "select gs.* from arcade_game_setting as gs where gs.game_id={$game_id}"; $rs = mysql_query($sql) or die( "Invalid query". mysql_error() ); if($rs){ $row = mysql_fetch_array($rs); switch($row["calculation_type"]){ case "divide": $x_score = round($game_score / $row["r_no"]); break; case "multiply": $x_score = round($game_score * $row["r_no"]); break; default : $x_score = ceil($game_score); break; }//switch $row["r_no"]; if($row["game_cap"] > 0){ if($x_score > $row["game_cap"]){ $x_score = $row["game_cap"]; } } return $x_score; }//if }// end function # get user total plays function getUserMaxPlaysLimit($user_id, $game_id){ global $d_start_time, $d_end_time; $sql = "select * from tbl_arcade_game_score where user_id={$user_id} and game_id={$game_id} and play_date between {$d_start_time} and {$d_end_time}"; $rs = mysql_query($sql) or die("Invalid query :". mysql_error() ); if($rs){ return mysql_num_rows($rs); }//if } # get game details function getGameDetails($game_id){ $sql = "select g.game_id, g.game_name, g.award_ctoonid, c.toon_name, c.toon_cat, c.toon_subcat, c.toon_small_img from tbl_game as g, tbl_ctoon as c where g.game_id = {$game_id} and g.award_ctoonid=c.ctoon_id"; $rs = mysql_query($sql); if($rs){ $row = mysql_fetch_array($rs); if($row['toon_cat']!="" && $row['toon_subcat']!=0) $tpth="imgtoon/".$row['toon_cat']."/".$row['toon_subcat']."/thumb"; elseif($row['toon_cat']!="" && $row['toon_subcat']==0) $tpth="imgtoon/".$row['toon_cat']."/thumb"; $game["game_name"] = $row["game_name"]; $game["award_ctoon_id"] = $row["award_ctoonid"]; $game["toon_name"] = $row["toon_name"]; $game["path"] = SITEROOT ."/" . $tpth ."/" . $row["toon_small_img"]; return $game; } else { return false; } } # send pm message to winner function sendPMToWinner($user_id, $game_id, $game_score){ include_once("send_pm_message.php"); $g = $game_id; //$point_prize = calculatePointRatio($game_id, $game_score); $point_prize = $game_score; $game = getGameDetails($game_id); //# select ctoon //$sql = "select award_ctoonid from tbl_game where game_id=".$g; //$rsctoon = mysql_query($sql) or die("Invalid query: {$sql} - ". mysql_error()); //$row_ctoon = mysql_fetch_array($rsctoon); //$ctoon_id = $row_ctoon["award_ctoonid"]; //# award ctoon //$insert_user_ctoon = "insert into tbl_users_ctoons (usrid, ctoon_id, del_status, ctoons_auction, auction_id, location, batpts) //values('{$user_id}', '{$ctoon_id}', '0', '', '', '1', '0')"; //mysql_query($insert_user_ctoon) or die("Invalid insert query:".mysql_error() ); //# update points $update_points_sql = "update tbl_users set points_gained = (points_gained+1500) where usrid={$user_id}"; mysql_query($update_points_sql) or die("Invalid updates points query". mysql_error() ); $dbObj = new database(); $msgSub = "Grats! You got a Top Score for ".$game["game_name"]." !"; $message = "Grats! You had one of the Top 10 scores in the ".$game["game_name"]." game last month, and got a 1500 point bonus!<br>"; //<img src=\"{$game['path']}\">"; // echo $message; // echo "<br><hr><br>"; sendMessage($user_id, 0, 0, $msgSub, $message, 1); } /** * function getTrophy( $game_id ) * @param $game_id */ function getTrophy( $game_id ){ $sql = "select award_ctoonid from tbl_game where game_id=".$game_id; $rs = mysql_query( $sql ) or die( mysql_error() ); if( $rs ){ $row = mysql_fetch_assoc( $rs ); } return $row["award_ctoonid"]; } // Updated function from above // Will get more information about the trophy function getTrophyDetails($game_id) { $sql = "select b.ctoon_id,b.toon_name,b.toon_small_img from tbl_game as a,tbl_ctoon as b where a.game_id = '$game_id' and b.ctoon_id = a.award_ctoonid LIMIT 1"; $rs = mysql_query( $sql ) or die( mysql_error() ); if( $rs ){ $row = mysql_fetch_assoc( $rs ); } return $row; } ?> <?php include_once("Constants.php"); include_once("Database.php"); include_once("SiteSetting.php"); /**************************************************/ # SAVE DONETION IN DATABASE # @param $uid # @param $donation_amt /**************************************************/ function saveDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type){ if($transaction_id != "") { $flag = checkExist($uid); if($flag > 0){ updateDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type); }else{ addDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type); } } } /**************************************************/ /**************************************************/ # CHECK IS RECORD EXITS IN DONETION TABLE # @param $uid /**************************************************/ function checkExist($uid){ $dbObj = new database(); $sql = "select user_id from tbl_donation where user_id={$uid}"; $dbObj->myquery($sql); if($dbObj->row_count > 0){ return $dbObj->f_user_id; }else{ return 0; } } /**************************************************/ /**************************************************/ # INSERT DONETION RECORD IN tbl_donation # @param $uid # @param $donation_amt /**************************************************/ [b]$query = "SELECT arcade_multiplier FROM tbl_point_rewards"; mysql_query($query) or die("Invalid query". mysql_error() ); $result = mysql_fetch_array($result); $arcade_multiplier = $result["arcade_multiplier"];[/b] function addDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type){ $dbObj = new database(); $months = floor($donation_amt / 5); $exp_time = mktime(date("H"),date("i"),date("s"),date("m") + $months,date("d"),date("Y")); $fields = array("transaction_id", "subscr_id", "user_id", "donation_amt", "donation_date", "exp_date", "donation_type", "transaction_details"); $values = array($transaction_id, $subscr_id, $uid, $donation_amt, time(), $exp_time, $type, serialize($_SESSION["recurring_td"])); # update points [b]$update_points_sql = "update tbl_users set points_gained = (points_gained+(($donation_amt / 5) * $donation_pts)) where usrid={$uid}";/[b] mysql_query($update_points_sql) or die("Invalid updates points query". mysql_error() ); if($donation_amt < 5){ // The user donated less than $5 }else{ upgradeAccount($uid); } return $dbObj->cgi("tbl_donation", $fields, $values, false); } /**************************************************/ /**************************************************/ # UPDATE EXISTING DONETION RECORD # @param $uid # @param $donation_amt /**************************************************/ function updateDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type){ if(strlen($subscr_id) > 0){ $cd = " AND subscr_id='".$subscr_id."'"; } $sql_select = "select exp_date, donation_amt from tbl_donation where user_id=".$uid; //$sql_select = "select exp_date, donation_amt from tbl_donation where user_id=".$uid." and donation_type like '%recurring%'"; $rs_select = mysql_query($sql_select) or die("Invalid query".mysql_error()); if($rs_select){ $row = mysql_fetch_array($rs_select); $expdt = $row["exp_date"]; $damt = ($row["donation_amt"] + $donation_amt); $months = floor($donation_amt / 5); $exp_time = mktime(23, 59, 59, date("m",$row["exp_date"]) + $months, date("d", $row["exp_date"]), date("Y", $row["exp_date"])); } $dbObj = new database(); $sql = "update tbl_donation set transaction_id='".$transaction_id."', donation_amt=(donation_amt + {$donation_amt}), donation_date = ".time().", exp_date=".$exp_time.", donation_type='".$type."', transaction_details='".serialize($_SESSION["recurring_td"])."' where user_id={$uid}"; # update points [b]$update_points_sql = "update tbl_users set points_gained = (points_gained+(($donation_amt / 5) * $donation_pts)) where usrid={$uid}";[/b] mysql_query($update_points_sql) or die("Invalid updates points query". mysql_error() ); $dbObj->myquery($sql, 1); if($donation_amt < 5){ // The user donated less than $5 }else{ upgradeAccount($uid); } } /**************************************************/ /**************************************************/ # UPDATE EXISTING RECURRING DONETION RECORD # @param $uid # @param $donation_amt /**************************************************/ function updateRecurringDonetion($subscr_id, $transaction_amt){ $sql_subscr = "select donation_id, transaction_id, user_id from tbl_donation where subscr_id = '".$subscr_id."'"; $rs_subscr = mysql_query($sql_subscr) or die("Invalid query".mysql_error()); if(strlen($rs_subscr) > 0){ $row_subscr = mysql_fetch_assoc($rs_subscr); $uid = $row_subscr["user_id"]; $donation_amt = $transaction_amt; $transaction_id = $row_subscr["transaction_id"]; $subscr_id = $subscr_id; $type = "Recurring"; updateDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type); } } /**************************************************/ /**************************************************/ # UPDATE USER STATUS FROM STANDERED TO PREMIUM # @param $uid /**************************************************/ function upgradeAccount($uid){ $dbObj = new database(); $sql = "UPDATE tbl_users SET acc_type = 'P' WHERE usrid={$uid} LIMIT 1 "; # update points $update_points_sql = "update tbl_users set points_gained = (points_gained+0) where usrid={$uid}"; mysql_query($update_points_sql) or die("Invalid updates points query". mysql_error() ); $dbObj->myquery($sql, 1); }//function upgradeDonation($uid) ?>
  16. I currently have a php file that runs when users submit text in certain fields around my site. Right now, the file only looks for specifics words I enter into a table, and it only finds exact words. What I want to do is have the sql tring be able to use wildcard values around the {invalid_word} tag so it can find and prevent a user from submitting text if a long word contains the text on my banned list. Like, if I banned the word hair, and someone tried using the word hairball, it would let them. This is what the current php file code is <?php # **** FIND BAD WORDS INTO THE ENTERED STRING **** # # @param $str - takes an argument as an string # match with database keywords # return true if bad word found # return false if bad word not found function findBadWords( $str ){ $return = false; if( strlen( $str ) > 0 ) { $sql = "SELECT * FROM tbl_invalidunm WHERE MATCH (invalid_word) AGAINST (LCASE('".$str."') IN BOOLEAN MODE)"; $rs = mysql_query( $sql ) or die( "Invalid query - ". mysql_error() ); if($rs){ $row_count = mysql_num_rows($rs); if( $row_count > 0 ) { $return = true; } } // if } // if return $return; } // end function ?> Thanks in advance for your help
  17. I currently have a php file that runs when users submit text in certain fields around my site. Right now, the file only looks for specifics words I enter into a table, and it only finds exact words. What I want to do is have the sql tring be able to use wildcard values around the {invalid_word} tag so it can find and prevent a user from submitting text if a long word contains the text on my banned list. Like, if I banned the word hair, and someone tried using the word hairball, it would let them. This is what the current php file code is Code: <?php # **** FIND BAD WORDS INTO THE ENTERED STRING **** # # @param $str - takes an argument as an string # match with database keywords # return true if bad word found # return false if bad word not found function findBadWords( $str ){ $return = false; if( strlen( $str ) > 0 ) { $sql = "SELECT * FROM tbl_invalidunm WHERE MATCH (invalid_word) AGAINST (LCASE('".$str."') IN BOOLEAN MODE)"; $rs = mysql_query( $sql ) or die( "Invalid query - ". mysql_error() ); if($rs){ $row_count = mysql_num_rows($rs); if( $row_count > 0 ) { $return = true; } } // if } // if return $return; } // end function ?>
  18. Mchl, youre brilliant! worked like a charm. thanks
  19. yes, from the looks of the code there is smarty. I see a row like $smarty->assign("toon_path",$tpth); so how do have the tpl pull the newly formatted date into the actual template to display on the web page? thanks
  20. ok, say I add this line towards the top of the php file $str_sql = "select DATE_FORMAT(FROM_UNIXTIME(release_date), '%m/%d/%Y')"; in the tpl file, I changed the target from {$ctoninfo.release_date} to {$release_date} now instead of pulling up a datetime string of numbers, it gives a blank space. how do I make it so that template knows to pull the newly converted timestamp from the php file? thanks again
  21. ah, well since I have 0 experience coding php, I dont think I will be altering the php file. I have only been working on the ptl files to change layouts and formatting
  22. so how/where do I insert it into the string {$ctoninfo.release_date} thanks
  23. I have added a line item on one of my .tpl pages to show the date. since it is pulling the datetime stamp from the db, it shows a date like 1226325111 right now. since the info is being pulled from <td><B>{$ctoninfo.release_date}</B> </td> how do I alter the code to only display the date formatted to 'mm-dd-yyyy'? thanks in advance
  24. well, it would most likely be html than, since its a form that is pulling information from a .php file. the 'value' tag is actually the name of the field in the sql database, so I dont want to mess with that or it probably wont pull any information from the database. This was part of a script that was made for me awhile ago, and now I need to make some small changes which is where Im getting stuck. Thanks for your reply
  25. Good morning. I have a quick question on how to create and display a default form field value in an html document I have. The current line looks like this <input class="Input" value="{opt1}" name="{opt1_Name}" style="WIDTH: 336px" size="50" > What is the tag I need to add in order to create a default value that will display in the field, but can be written over if I need to change it to something else? Your help is greatly appreciated. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.