Jump to content

APuppyDog

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

APuppyDog's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i have a piece of code which subtracts credits every time a button is clicked. the original code works fine. I have since added a bonus_credit column, where i want it to function like this. if buy_credit = 0 and bonus_credit>0 then subtract from the bonus credit, but still do everything else its supposed to do.. here is the original code i had $selRes=mysql_query("SELECT buy_credit from user where id='".$hb_id."' and buy_credit>0"); if(mysql_affected_rows()>0) { $b_comm=0; $bc_updqry=mysql_query("UPDATE user set buy_credit=buy_credit-1 where id='".$hb_id."'"); $updqry=mysql_query("UPDATE cars set b_fee_paid_status='1' where id='".$aid."'"); } here is my modified code, but it doesn't seem to subtract from buy_credit if buy_credit is >0.. it should only kick in the bonus_credit usage if buy_credit is 0 $selRes=mysql_query("SELECT buy_credit,bonus_credit from user where id='".$hb_id."' and buy_credit>0 OR bonus_credit>0"); if(mysql_affected_rows()>0) { $b_comm=0; if($selRes['buy_credit']!=0) { $bc_updqry=mysql_query("UPDATE user set buy_credit=buy_credit-1 where id='".$hb_id."'"); } else { $bc_updqry=mysql_query("UPDATE user set bonus_credit=bonus_credit-1 where id='".$hb_id."'"); } $updqry=mysql_query("UPDATE cars set b_fee_paid_status='1' where id='".$aid."'"); } your help is appreciated.
  2. hey gurus, i am a newbie php coder.. i am learning by example. what i am trying to do is write a piece of code which will alter 3 tables (user, bonus_credit, bonus_credit_usage) ---------------------------------------------------------------- the table structure that will be used is as follows: user.bonus_credit user.ID bonus_credit.bonusCode bonus_credit.qty bonus_credit.value bonus_credit_usage.bonusCode bonus_credit_usage.usedBy ---------------------------------------------------------------- so lets say, in bonus_credit i have the following bonusCode = 'facebook' (this is the code they have to type to redeem the bonus qty = '10' ( number of times the bonusCode can be redeemed, but same person can't redeem it more than once) value = '5' (this is the amount of bonus_credit for each qty) Now, I need to write a code that check to see if the code has been redeemed in the bonus_credit_usage table and if the user.ID exists in this table as bonus_code_usage.usedBy, then give an error that its already been used and if it hasn't been used, then subtract 1 from qty, add ID to usedBy and then add the value to the bonus_credit ----------------------- i have started the steps just to create a simple textbox and entering a numeric value to bonus_credit, and that works.. but now i have to use JOIN and IF and ELSE.. which is a little too advanced for me.. so i'd appreciate a guide as i write the code. if(isset($_REQUEST['btnBonus'])) { $bonus_credit = addslashes($_REQUEST['bonusCode']); $query = "update user set bonus_credit=bonus_credit+'".$bonus_credit."' where id='".$_SESSION['SESS_USERID']."'"; echo "<script>window.location='myreferrals.php?msgs=2';</script>"; mysql_query($query) or die(mysql_error()); }
  3. thanks, i had asked but they don't have an example/sample to follow so i was looking for some guidance here from the gurus
  4. hey guys. i am not too familiar with how loop works.. or in my case particularly. Here is the situation. i am trying to pass multiple transactions in a single click using paypal's doDirectPayment nvp api. The credit card number, name, address will be the same but the "invoice number" and "amount" will be different for each transaction. The way i have it now is that if there are multiple transactions, it processes them as a whole so if there are four $25 transactions, it charges one amount, $100 and provides one transaction id. I'd like to be able to set those transactions in a loop, so each transaction is billed individually and have its own transaction id returned from Paypal. an example would be this: item_ID-----amount 1 ----- $25 2 ----- $25 3 ----- $25 4 ----- $25 total ------ $100 the code i have currently is this: <?php /** DoDirectPayment NVP example; last modified 08MAY23. * * Process a credit card payment. */ $environment = 'sandbox'; // or 'beta-sandbox' or 'live' /** * Send HTTP POST Request * * @param string The API method name * @param string The POST Message fields in &name=value pair format * @return array Parsed HTTP Response body */ //function PPHttpPost($methodName_, $nvpStr_) {} $userRes=mysql_query("SELECT * FROM user where id='".$_SESSION['SESS_USERID']."'"); $userRow=mysql_fetch_array($userRes); // Set request-specific fields. $fullname=explode(" ",$userRow['fullname']); $paymentType = urlencode('Sale'); // or 'Authorization' $firstName = urlencode($fullname[0]); $lastName = urlencode($fullname[1]); $creditCardType = urlencode($card_type); $creditCardNumber = urlencode($card_no); // Month must be padded with leading zero $padDateMonth = urlencode(str_pad($exp_month, 2, '0', STR_PAD_LEFT)); $expYr="20".substr($exp_year,-2); $expDateYear = urlencode($expYr); $cvv2Number = urlencode($cvv2); $address1 = urlencode($userRow['address1']); $address2 = urlencode($userRow['address2']); $city = urlencode($userRow['city']); $state = urlencode($userRow['state']); $zip = urlencode($userRow['zip']); $country = urlencode('US'); // US or other valid country code $amount = urlencode($totalamt); $currencyID = urlencode('USD'); // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') // Add request-specific fields to the request string. $nvpStr = "&PAYMENTACTION=$paymentType&AMT=$amount&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber". "&EXPDATE=$padDateMonth$expDateYear&CVV2=$cvv2Number&FIRSTNAME=$firstName&LASTNAME=$lastName". "&STREET=$address1&CITY=$city&STATE=$state&ZIP=$zip&COUNTRYCODE=$country&CURRENCYCODE=$currencyID"; // Execute the API operation; see the PPHttpPost function above. $httpParsedResponseAr = PPHttpPost('DoDirectPayment', $nvpStr); if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { if($s_list!="") { $updRes=mysql_query("UPDATE cars set s_fee_paid_status='1',seller_paid_date=now() where id in (".$s_list.")"); } if($b_list!="") { $updRes=mysql_query("UPDATE cars set b_fee_paid_status='1',buyer_paid_date=now() where id in (".$b_list.")"); } $exp_date=$exp_month."/".$exp_year; $updRes=mysql_query("UPDATE user set nameoncard='".$nameoncard."',card_type='".$card_type."',card_no='".$card_no."',cvv2='".$cvv2."',exp_date='".$exp_date."' where id='".$_SESSION['SESS_USERID']."'"); //$msgs=urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]); echo "<script> window.location='somewebfile.php?msgs=1'; </script>"; exit; } else { $msgs=urldecode($httpParsedResponseAr["L_LONGMESSAGE0"]); /*echo "<script> window.location='somewebfile.php?msgs=2'; </script>"; exit;*/ } ?>
  5. hey guys, thanks for your help.. its not code that i wrote, it was written by someone else and i'm trying to get it compatible with php5 so taking it as i go along. taquito, are you saying the code you provided will not work at all? I'm not sure what you mean... redarrow, thanks for pointing out the outdated code, but again i'm trying to get this resolved for php5, so i guess there are some codes i can write better, but i still need it to be backwards compatible with php4, as the server is still on php4.
  6. hi, i tried the above code, but it didn't seem to make a difference, i still get the same error. Line 288 - //***********************CODE FOR PICTURE UPLOAD************************************ Line 304 - if (!str_contains(str_replace(".jpeg","",str_replace(".jpg","",str_replace(".gif","",str_replace(".png","",$fileName))),".")))
  7. so my first line of code should be replaced by the following? $Disfilename = realpath("listmycar.php"); if (file_exists($Disfilename)) { $mypath = $Disfilename; } sorry, i'm still learning php, i took over the code from someone else, so guidance is much appreciated!
  8. Hello, i have php 5 installed locally, and php 4 on the server where i host a site. On the server (with php 4) the code below works, but when i try the code locally on php 5, i get the following error "Fatal error: Only variables can be passed by reference in C:\Abyss Web Server\htdocs\query.php on line 304" if i take the code below out of the file query.php, everything works fine.. any idea how i can make this code compatible with both php4 and php5? Any help is appreciated, thanks in advance! //***********************CODE FOR PICTURE UPLOAD************************************ $mypath=realpath("listmycar.php"); $mypath=str_replace("listmycar.php","",$mypath); $mypath=str_replace("\\","/",$mypath); $mypath=str_replace("admin","files",$mypath); $upload_folder=$mypath."Auction_pics/"; for ($i = 1; $i < 11; $i++) { if (pdbfx("addfileX".$i)!='' && pdbfx("DELETEFILE".$i)!='1') $fileNameX[$i]=pdbfx("addfileX".$i); if (is_uploaded_file($_FILES['addfile'.$i]['tmp_name'])) { //Get the Filename and the File Type $fileName = $_FILES['addfile'.$i]['name']; $fileType = $_FILES['addfile'.$i]['type']; $fileName=strtolower($fileName); if (!str_contains(str_replace(".jpeg","",str_replace(".jpg","",str_replace(".gif","",str_replace(".png","",$fileName))),"."))) { if (str_contains($fileName,".jpg") || str_contains($fileName,".gif") || str_contains($fileName,".png")) { $fileName=str_replace(".","@",strtolower($fileName)); $fileext=split("@",$fileName); $fileext=$fileext[1]; $fileName="AUCTION-".$auction_id."-".genpasswordalpha(2)."-".genpasswordnum(16).".".$fileext; $fileNameX[$i]=$fileName; move_uploaded_file($_FILES['addfile'.$i]['tmp_name'],$upload_folder.''.$fileName); if ($_FILES['addfile'.$i]['size'] > 250000){ $size = GetImageSize($upload_folder.''.$fileName); $width = $size[0] ; if ($width>470) $width=470; createmagic($fileName,$width); } if ($_FILES['addfile'.$i]['size'] > 40000000){ $size = GetImageSize($upload_folder.''.$fileName); $width = $size[0] ; $height = $size[1] ; $newwidth=($width-($width/30)); $newheight=($height-($height/30)); createthumb('Auction_pics/'.$fileName,'Auction_pics/'.$fileName,$newwidth,$newheight); } //createthumb('Auction_pics/'.$fileName,'Auction_pics_T/'.$fileName,80,60); //createthumb('Auction_pics/'.$fileName,'Auction_pics_B/'.$fileName,200,150); //createthumb('Auction_pics/'.$fileName,'Auction_pics_B/'.$fileName,470,353); //if($i==1) { //createthumb('Auction_pics/'.$fileName,'Auction_pics_M/'.$fileName,200,150); //} } } } } //***************END OF FOR LOOP FOR 10 PICTURES**********************************
  9. hello, i am trying to setup a cron job with a path and string, example "php /path/to/file/filename.php?string=1" the cron job returns an error that no input file was specified... however, if i run the file with the following command http://www.mydomain.com/filename.php?string=1 then the string works as intended... any way to get this working with cron?
  10. genius! it had to be a lower case UM.. err um. thanks for your help..
  11. hi fenway, thanks again for your prompt reply. Even after the code above, i get "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/k/l/i/klickcarcom/html/_admin/unpaid_accounts.php on line 56" Perhaps it would be easier if you could see the whole code.. here it is: <?php session_start();?> <?php include("../includes/config.inc"); include_once("../settings/settings.php"); include("../includes/func.php");?> <?php if (empty($_SESSION["admin"])) redirectS("index.php?e=1"); $tmon = date("m"); $tday= date("d"); $tyr= date("Y"); $nextmonth = time() - (30 * 24 * 60 * 60); $fmon = date('m', $nextmonth); $fday= date('d', $nextmonth); $fyr= date('Y', $nextmonth); $sql="select distinct ca.leading_bidder from car_auctions AS ca inner join user_master AS um on ( um.user_name = ca.leading_bidder ) inner join user_details AS ud using (user_id) where ca.auction_closed=1 and ca.buyer_fees>0 and ca.buyer_fees_charged_status<>1 and ud.user_status=2 "; $rec=mysql_query($sql); $rs=mysql_fetch_array($rec); if(!$rs) {} else{ do { $lead=$rs["leading_bidder"]; if($idlist!="") { $idlist=$idlist .","; } $idlist=$idlist."'".$lead."'"; }while($rs=mysql_fetch_array($rec)); } $sql2="select distinct ca.user_id from car_auctions AS ca inner join user_master AS um using (user_id) inner join user_details AS ud on ( ud.user_id = um.user_id AND ud.user_status=2 ) where ca.auction_closed=1 and seller_fees_charged_status<>1 and winning_bidder<>'' AND seller_fees<>0 and (seller_fees>0 OR UM.user_discount=100)"; $rec2=mysql_query($sql2); $rs2=mysql_fetch_array($rec2); if(!$rs2) {} else{ do { $user_id=$rs2["user_id"]; if($idlist2!="") { $idlist2=$idlist2 .","; } $idlist2=$idlist2."'".$user_id."'"; }while($rs2=mysql_fetch_array($rec2)); } ?> <?php include("includes/header.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .myform { font-family:Arial, Helvetica, sans-serif; font-size:12; } --> </style> </head> <script type="text/javascript"> function validate() { if(document.frm1.f_day.value=="") { alert("Select From Day "); document.frm1.f_day.focus(); return false; } else if(document.frm1.f_month.value=="") { alert("Select From Month "); document.frm1.f_month.focus(); return false; } else if(document.frm1.f_year.value=="") { alert("Select From Year "); document.frm1.f_year.focus(); return false; } else if(document.frm1.t_day.value=="") { alert("Select To Day "); document.frm1.t_day.focus(); return false; } else if(document.frm1.t_month.value=="") { alert("Select From Month "); document.frm1.t_month.focus(); return false; } else if(document.frm1.t_year.value=="") { alert("Select From Year "); document.frm1.t_year.focus(); return false; } else if(document.frm1.f_year.value>document.frm1.t_year.value) { alert("From Date Cannot be greater then To Date "); return false; } else if(document.frm1.client.value=="") { alert("Select client "); document.frm1.t_year.focus(); return false; } return true; } </script> <body> <form name="frm1" action="invoice_detail.php" method="post"> <table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="50"><span style="font-weight: bold">Search Unpaid Accounts </span></td> </tr> <tr><td><?php if($_GET["err"]=="1"){ ?><div><font color="#FF0000"><b>No Records Found</b></font></div><?php } ?></td></tr> <tr height="25" class="myform"> <td >From: <select name="f_month" class="myform"> <option value="">Month</option> <? for($i=1; $i<=12; $i++){?> <option value="<?=$i?>"<? if($fmon==$i) { echo "selected";} ?>><?=$i?></option> <? }?> </select> <select name="f_day" class="myform"> <option value="">Day</option> <? for($i=1; $i<=31; $i++){?> <option value="<?=$i?>"<? if($fday==$i) { echo "selected";} ?>> <?=$i?> </option> <? }?> </select> <select name="f_year" class="myform"> <option value="">Year</option> <? for($i=2006; $i<=(date(Y)+0); $i++){?> <option value="<?=$i?>"<? if($fyr==$i) { echo "selected";} ?>><?=$i?></option> <? } ?> </select> To: <select name="t_month" class="myform"> <option value="">Month</option> <? for($i=1; $i<=12; $i++){?> <option value="<?=$i?>"<? if($tmon==$i) { echo "selected";} ?>> <?=$i?> </option> <? }?> </select> <select name="t_day" class="myform"> <option value="">Day</option> <? for($i=1; $i<=31; $i++){?> <option value="<?=$i?>"<? if($tday==$i) { echo "selected";} ?>> <?=$i?> </option> <? }?> </select> <select name="t_year" class="myform"> <option value="">Year</option> <? for($i=2006; $i<=(date(Y)+0); $i++){?> <option value="<?=$i?>"<? if($tyr==$i) { echo "selected";} ?>> <?=$i?> </option> <? } ?> </select></td> </tr> <tr height="25"><td class="myform">Client: <select name="client"><option>Select Client</option> <?php $sql="SELECT distinct u.user_id,ud.user_dealer_name from user_details ud,user_master u where u.user_id=ud.user_id and ud.user_status=2 and u.user_name in(".$idlist.") ORDER BY user_dealer_name ASC"; $rs=mysql_query($sql); $rec=mysql_fetch_array($rs); if($rec) { do { ?> <option value="<?=$rec["user_id"]?>"> B- <?=$rec["user_dealer_name"]?></option> <?php } while($rec=mysql_fetch_array($rs)); } $sql4="SELECT distinct u.user_id,ud.user_dealer_name from user_details ud,user_master u where u.user_id=ud.user_id and ud.user_status=2 and u.user_id in(".$idlist2.") "; $rs4=mysql_query($sql4); $rec4=mysql_fetch_array($rs4); if($rec4) { do { ?> <option value="<?=$rec4["user_id"]?>"> S- <?=$rec4["user_dealer_name"]?></option> <?php } while($rec4=mysql_fetch_array($rs4)); } ?> </select> </td></tr> <tr><Td align="center" colspan="2"><input type="submit" value="Search" onclick="return validate();" /></Td></tr> </table> </body> </html> <?php include("includes/footer.php"); ?>
  12. hi fenway, thanks for your reply.. with the code you sent, i see it still has a sub query, but i tried it anyway and it still gives the same error (error in mySQL syntax) where as the first solution you provided didn't have any subqueries..
  13. fenway.. i really am stuck. I have no real clue how to apply your code. Honestly, i don't know much about php/mysql and string implementation. I had asked someone to write the code, and they gave me a mysql 5 solution.. where i had mysql 4.0 on the host.. they can't seem to do it either. Since you have provided a working code for the first request.. could you please provide the code for the second one? Pretty please? I took your advice, where you said "Your latest query doesn't use JOINs" so i tried to follow your code without using Inner JOIN but i really have no clue what i'm doing.. so your assistance would be REALLY appreciated
  14. hi fenway, thanks for explaining the code... i'm still having issues with the code. So instead of using inner join, i used "USING".. but i still get a syntax error here is the code i tried: SELECT DISTINCT ca.user_id FROM car_auctions AS ca, user_master UM WHERE CA.user_id = UM.user_id AND CA.auction_closed =1 AND seller_fees_charged_status <>1 AND winning_bidder <> '' AND seller_fees <>0 AND CA.user_id USING user_id AS ud FROM user_details ud, user_master u WHERE u.user_id = ud.user_id AND ud.user_status =2 AND ( seller_fees >0 OR UM.user_discount =100 ) any suggestions?
  15. whoa fenway! Thanks! that piece of code.. i don't think i could have figured all those changes at all myself, but it worked. Could you explain the code above.. I have another (last) query that i tried to play around with using your example but it still gives an error that code is select distinct CA.user_id from car_auctions AS CA,user_master UM where CA.user_id=UM.user_id and CA.auction_closed=1 and seller_fees_charged_status<>1 and winning_bidder<>'' AND seller_fees<>0 AND CA.user_id in (SELECT ud.user_id from user_details ud,user_master u where u.user_id=ud.user_id and ud.user_status=2) and (seller_fees>0 OR UM.user_discount=100) thanks in advance!
×
×
  • 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.