l95theses Posted May 6, 2008 Share Posted May 6, 2008 This is my script that is not finishing, and I'm getting error code for the credit card transaction part where is commented by ~'s <?php $link = mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); $sql = "SHOW TABLES FROM ***"; $result = mysql_query($sql); echo "<center><table border='1' background=bg.gif width=390>"; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $date = date("n/j/Y"); $time = 12; $date2 = explode("/",$date); $dateday = ($date2[1]-1); while ($row = mysql_fetch_row($result)) { $checker = explode("_",$row[0]); $checker = $checker[0]; if($checker!="backup") { if($row[0]!="login" & $row[0]!="login2") { $rowboat = str_replace("543210","-",$row[0]); $rowboat = str_replace("_","/",$rowboat); $rowboat = str_replace("012345"," ",$rowboat); $rowboat2 = explode("-",$rowboat); $rowboat2 = $rowboat2[1]; $rowboat3 = explode("/",$rowboat2); if($dateday==$rowboat3[1] & $time>=12 & $date2[0]==$rowboat3[0] & $date2[2]==$rowboat3[2]) { // get users to send to next function and amounts // ~~~~~ Declaring variables.. ~~~~~ $result5 = mysql_query("SELECT * FROM $row[0]"); $row5 = mysql_fetch_array($result5) or die(mysql_error()); $result2 = mysql_query("SELECT * FROM $row[0] WHERE courseid='lookhere'"); $row2 = mysql_fetch_array($result2) or die(mysql_error()); $fields = mysql_list_fields("***", $row[0], $link); $count = mysql_num_fields($fields); $current = $row['current']; // ~~~~~ end declaration for ( $counter = 6; $counter <= ($count-1); $counter += 1) { $spliter = mysql_field_name($fields, $counter); $spliter2 = str_replace("_",":",$spliter); $amount3 = mysql_query("SELECT * FROM login WHERE login='$row2[$spliter]'"); $amount2 = mysql_fetch_array($amount3) or die(mysql_error()); $amount = $amount2['current_bid']; if(isset($row2[$spliter])) { // clearing current bids out of user's accounts mysql_query("UPDATE login SET current_slot=NULL WHERE login='$row2[$spliter]'") or die(mysql_error()); mysql_query("UPDATE login SET current_bid=NULL WHERE login='$row2[$spliter]'") or die(mysql_error()); mysql_query("UPDATE login SET current_course=NULL WHERE login='$row2[$spliter]'") or die(mysql_error()); // credit card transactions for everyone in the closing course. //-- using our $amount2 variable that is an array to grab personal information to submit to the credit card query. $ccnumber = $amount2['ccnumber']; $expdate = $amount2['expdate']; $cardcode = $amount2['cardcode']; $firstname = $amount2['firstname']; $lastname = $amount2['lastname']; $address = $amount2['address']; $city = $amount2['city']; $state = $amount2['state']; $zip = $amount2['zip']; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $cap = array(); $cap['x_login'] = "***"; $cap['x_tran_key'] = "***"; $cap['x_version'] = "3.1"; $cap['x_delim_char'] = "|"; $cap['x_delim_data'] = "TRUE"; $cap['x_test_request'] = "FALSE"; $cap['x_relay_response'] = "FALSE"; $cap['x_type'] = "AUTH_ONLY"; $cap['x_method'] = "CC"; $cap['x_relay_response'] = "FALSE"; $cap['x_card_num'] = "4007000000027"; $cap['x_exp_date'] = "0309"; $cap['x_card_code'] = "123"; $cap['x_amount'] = "1.20"; $cap['x_first_name'] = "John"; $cap['x_last_name'] = "Smith"; $cap['x_address'] = "1234 West Main St."; $cap['x_city'] = "Some City"; $cap['x_state'] = "CA"; $cap['x_zip'] = "12345"; foreach( $cap as $key => $value ) $fields .= "$key=" . urlencode( $value ) . "&"; //////////////////////////////////////////////////// $ch = curl_init("https://test.authorize.net/gateway/transact.dll"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); $resp = curl_exec($ch); curl_close ($ch); //////////////////////////////////////////////////// $resp = explode("|",$resp); if ($resp[3]=="This transaction has been approved.") { echo "<table border=1><tr><td>Approved</td></tr></table>"; } else { echo "<table border=1><tr><td>".$resp[3]."</td></tr></table>"; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // end credit card transactions // last thing to do is to rename the table so it's closed on the website. if($counter <= ($count-1)) { $newname = "backup_".$row[0]; mysql_query("RENAME TABLE $row[0] TO $newname") or die(mysql_error()); echo "we renamed the table too"; } } } echo "</table>"; } echo "<table border=1><tr><td>"; echo "<a href=spliter.php?course=".$row[0].">".$rowboat."</a>"; echo ", <a href=spliteram.php?course=".$row[0].">am</a>"; echo ", <a href=spliterpm.php?course=".$row[0].">pm</a>"; echo "</td></tr></table>"; } } } echo "anything after that loop is not executing causing some problems with the credit card script. I don't know why."; echo "also I don't want static variables to be used after the loop. So I can't just end the php tag and start a new one."; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.