Jump to content

countrydj

New Members
  • Posts

    5
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

countrydj's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Guys... I have a lot of site written in mysql/php from a long time ago. In those days, the opening of a php script was <? . Then it changed to <?php There was no need to go back and change all the old coding. Everything wirked OK. However, yesterday, the old <? stopped working and I had to change ALL <? to <?php. The only thing that changed was that I moved my name servers to a new location. The webserver wasn't touched. Can anybody tell me why this would happen without warning? Thanks, John C
  2. Hi Guys... I want to collect ip numbers from submitted forms and store them into a text file. this is what I've got up to now: # get the submitters IP address $remote_ip = getenv(REMOTE_ADDR); $ip_file = fopen("inbritain-ip-file.txt",'a') or die("Unable to open file!"); fwrite($ip_file, $remote_ip); fclose($ip_file); This works fine and collects the ip numbers, BUT it adds then on to the end of the file. e.g. 88.97.199.15088.97.199.15088.97.199.15088.97.199.150 I need them in a list. e.g. 88.97.199.150 88.97.199.150 88.97.199.150 88.97.199.150 etc. I can't figure out how to get the code to do that. Has anybody got any ideas? Thanks, John C
  3. I have a small web site for advertising businesses in Lancashire (England) Local services and facilities in Lancashire, UK. The database has two tables: topics and vendors. The topics table holds all the types of business, and is OK. The vendors table holds all the businesses (e.g. Joe Blogs. Joiner, Adress, etc) and is faulty: Incorrect key file for table 'vendors'; try to repair it Code: mysql> check table vendors; +----------------------+-------+----------+----------------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +----------------------+-------+----------+----------------------------------------------------------+ | inlancashire.vendors | check | Error | Incorrect key file for table 'vendors'; try to repair it | | inlancashire.vendors | check | error | Corrupt | +----------------------+-------+----------+----------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> Code: mysql> repair table vendors; +----------------------+--------+----------+----------------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +----------------------+--------+----------+----------------------------------------------------------+ | inlancashire.vendors | repair | Error | Incorrect key file for table 'vendors'; try to repair it | | inlancashire.vendors | repair | error | Corrupt | +----------------------+--------+----------+----------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> This does not repair the table I also tried: Code: myisamchk vendors Checking MyISAM file: vendors Data records: 3029 Deleted blocks: 0 - check file-size - check record delete-chain - check key delete-chain - check index reference - check data record references index: 1 - check record links and Code: myisamchk -r vendors - recovering (with sort) MyISAM-table 'vendors' Data records: 3029 - Fixing index 1 and then Code: myisamchk vendors Checking MyISAM file: vendors Data records: 3029 Deleted blocks: 0 - check file-size - check record delete-chain - check key delete-chain - check index reference - check data record references index: 1 - check record links 'myisamchk -r vendors' indicated that it was fixing the table, but it didn't. I have been Googling this problem for quite a few hours now, and cannot find a solution. Can anybody help ???
  4. Hi kts... Many thanks for replying to my post. I feel pretty stupid now. Here is my updated products part of the script: $output[] = '<input type="hidden" name="item_number_1" value="1">'; $output[] = '<input type="hidden" name="item_name_1" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_1" value="'.$trade.'">'; $output[] = '<input type="hidden" name="quantity_1" value="'.$qty.'">'; $output[] = '<input type="hidden" name="item_number_2" value="2">'; $output[] = '<input type="hidden" name="item_name_2" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_2" value="'.$trade.'">'; $output[] = '<input type="hidden" name="quantity_2" value="'.$qty.'">'; $output[] = '<input type="hidden" name="item_number_3" value="3">'; $output[] = '<input type="hidden" name="item_name_3" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_3" value="'.$trade.'">'; $output[] = '<input type="hidden" name="quantity_3" value="'.$qty.'">'; $output[] = '<input type="hidden" name="item_number_4" value="4">'; $output[] = '<input type="hidden" name="item_name_4" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_4" value="'.$trade.'">'; $output[] = '<input type="hidden" name="quantity_4" value="'.$qty.'">'; $output[] = '<input type="hidden" name="item_number_5" value="5">'; $output[] = '<input type="hidden" name="item_name_5" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_5" value="'.$trade.'">'; $output[] = '<input type="hidden" name="quantity_5" value="'.$qty.'">'; $output[] = '<input type="hidden" name="item_number_6" value="6">'; $output[] = '<input type="hidden" name="item_name_6" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_6" value="'.$trade.'">'; $output[] = '<input type="hidden" name="quantity_6" value="'.$qty.'">'; $output[] = '<input type="hidden" name="item_number_7" value="7">'; $output[] = '<input type="hidden" name="item_name_7" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_7" value="'.$trade.'">'; $output[] = '<input type="hidden" name="quantity_7" value="'.$qty.'">'; $output[] = '<input type="hidden" name="item_number_8" value="8">'; $output[] = '<input type="hidden" name="item_name_8" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_8" value="'.$trade.'">'; $output[] = '<input type="hidden" name="quantity_8" value="'.$qty.'">'; I have also included a quantity in the item now. However, it still doesn't work. I have tested this with 1 item in the cart and it sends 8 items, all the same, to paypal. I have tested this with 2 items in the cart and it sends 8 items, all the same, to paypal. But this time it picks out the LAST item in the cart. I have tested this with 5 items in the cart and it sends 8 items, all the same, to paypal. Once again it only picks out the last item. I don't know how to do it, but it seems to me that the script needs to loop one item at a time and then list them as item 1, item 2 etc in the paypal form being sent to paypal. Hopefully somebody will be able to advise me.
  5. Hi Guys... I'm stuck again with my shopping cart. I have everything working now, except for payments via Paypal. I have a Paypal link at the bottom of my cart.php which goes to paypal.php Here is paypal.php: foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $trade = number_format($trade, 2); $subtotal = $trade*$qty; $subtotal = number_format($subtotal, 2); //echo "<br><br>Quantity = ".$qty."<br>Product = ".$product."<br> Trade = ".$trade."<br><br>"; $output[] = '<form id="paypal_form" class="paypal" action="../../../paypal/payments.php" method="post">'; $output[] = '<input name="cmd" type="hidden" value="_cart" />'; $output[] = '<input type="hidden" name="upload" value="1">'; $output[] = '<input name="no_note" type="hidden" value="1" />'; $output[] = '<input name="lc" type="hidden" value="UK" />'; $output[] = '<input name="currency_code" type="hidden" value="GBP" />'; // $output[] = '<input name="bn" type="hidden" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />'; $output[] = '<input name="first_name" type="hidden" value="First" />'; $output[] = '<input name="last_name" type="hidden" value="Second" />'; $output[] = '<input name="payer_email" type="hidden" value="an@email.co.uk" />'; //########################### products ################################ $output[] = '<input type="hidden" name="item_number_1" value="1">'; $output[] = '<input type="hidden" name="item_name_1" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_1" value="'.$trade.'">'; $output[] = '<input type="hidden" name="item_number_2" value="2">'; $output[] = '<input type="hidden" name="item_name_2" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_2" value="'.$trade.'">'; $output[] = '<input type="hidden" name="item_number_3" value="3">'; $output[] = '<input type="hidden" name="item_name_2" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_2" value="'.$trade.'">'; $output[] = '<input type="hidden" name="item_number_4" value="4">'; $output[] = '<input type="hidden" name="item_name_2" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_2" value="'.$trade.'">'; $output[] = '<input type="hidden" name="item_number_3" value="5">'; $output[] = '<input type="hidden" name="item_name_2" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_2" value="'.$trade.'">'; $output[] = '<input type="hidden" name="item_number_4" value="6">'; $output[] = '<input type="hidden" name="item_name_2" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_2" value="'.$trade.'">'; $output[] = '<input type="hidden" name="item_number_3" value="7">'; $output[] = '<input type="hidden" name="item_name_2" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_2" value="'.$trade.'">'; $output[] = '<input type="hidden" name="item_number_4" value="8">'; $output[] = '<input type="hidden" name="item_name_2" value="'.$product.'">'; $output[] = '<input type="hidden" name="amount_2" value="'.$trade.'">'; } $output[] = '<div align=center><button type="submit" style="background-color:#eae0a8; border:0; width:140px; "><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px; border="0""></div>'; $output[] = '</form>'; $output[] = '</td>'; $output[] = '</tr>'; $output[] = '</table>'; //############################## END OF FORM ################################ } else { $output[] = '<p><b><font size=4 color=#ff0000><center>Your shopping cart is empty.</font></b></center></p>'; } return join('',$output); If I fill in the variables manually, it works fine. e.g. $output[] = '<input type="hidden" name="item_number_1" value="1">'; $output[] = '<input type="hidden" name="item_name_1" value="[color="Red"]Cuddly Toy[/color]">'; $output[] = '<input type="hidden" name="amount_1" value="[color="red"]10.95[/color]">'; However, if I send the top form above to paypal, it only passes 2 items and they are both the same except for the item number and they are both from the last item in the cart. THe form is passed to payments.php: <?php // Database variables $host = "localhost"; //database location $user = "db_user"; //database username $pass = "db_passwd"; //database password $db_name = "db_name"; //database name // PayPal settings $paypal_email = 'sandbox_paypal_email '; $return_url = 'http://iso2000.co.uk/payment-successful.htm'; //This is a test site $cancel_url = 'http://iso2000.co.uk/payment-cancelled.htm'; $notify_url = 'http://iso2000.co.uk/paypal/payments.php'; // Include Functions include("functions.php"); //Database Connection $link = mysql_connect($host, $user, $pass); mysql_select_db($db_name); // Check if paypal request or response if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"])){ // Firstly Append paypal account to querystring $querystring = "?business=".urlencode($paypal_email)."&"; // Append amount& currency (?) to quersytring so it cannot be edited in html //The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable. $querystring .= "item_name=".urlencode($item_name)."&"; $querystring .= "amount=".urlencode($item_amount)."&"; //loop for posted values and append to querystring foreach($_POST as $key => $value){ $value = urlencode(stripslashes($value)); $querystring .= "$key=$value&"; } // Append paypal return addresses $querystring .= "return=".urlencode(stripslashes($return_url))."&"; $querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&"; $querystring .= "notify_url=".urlencode($notify_url); // Append querystring with custom field //$querystring .= "&custom=".USERID; // Redirect to paypal IPN header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring); exit(); }else{ // Response from PayPal } ?> I can't find anything helpful by Googling. I've been testing and trying for a couple of days. Can anybody advise me to get my cart items passed to Paypal.
×
×
  • 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.