1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

print string

Discussion in 'PHP' started by latehorn, Jul 22, 2006.

  1. #1
    Everything in the code works until this print string
    
    print '<script>window.location="https://www.paypal.com/xclick/business=' . urlencode($paypal_email) . '&item_name=' . urlencode("Link") . '&item_number=' . urlencode(1) . '&amount=' . urlencode($sql->price) . '&no_shipping=1&return=' . paypalURL($full_url_to_the_path. "/add_link") . '&no_note=1&currency_code=' . urlencode($currency) . '&lc=' . urlencode($paypal_country_code) . '&notify_url=' . paypalURL($paypal_notify_url) . '&custom=' . $newid . '&on0=Url&os0=' . paypalURL($url) . '"</script>';
    Code (markup):
    What the heck is the problem?
     
    latehorn, Jul 22, 2006 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #2
    That's quite a string... might be easier to read like this...
    print '<script>window.location="https://www.paypal.com/xclick/business=' 
    	. urlencode($paypal_email) 
    	. '&item_name=' 
    	. urlencode("Link") 
    	. '&item_number=' 
    	. urlencode(1) 
    	. '&amount=' 
    	. urlencode($sql->price) 
    	. '&no_shipping=1&return=' 
    	. paypalURL($full_url_to_the_path. "/add_link") 
    	. '&no_note=1&currency_code=' 
    	. urlencode($currency) 
    	. '&lc=' 
    	. urlencode($paypal_country_code) 
    	. '&notify_url=' 
    	. paypalURL($paypal_notify_url) 
    	. '&custom=' 
    	. $newid 
    	. '&on0=Url&os0=' 
    	. paypalURL($url) . ';"</script>';
    Code (markup):
    I added a semi colon at the end... but what exactly is the error you're getting?
     
    sarahk, Jul 22, 2006 IP
  3. DrMalloc

    DrMalloc Peon

    Messages:
    130
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ran it on my own machine, works fine with the paypalURL functions changed to print, i'm guessing the problem is not with the string itself.
     
    DrMalloc, Jul 22, 2006 IP
  4. latehorn

    latehorn Guest

    Messages:
    4,676
    Likes Received:
    238
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok, I post the whole code thing then..

    <? include("config.php");
    
    $sql = mysql_query("SELECT price, numbern, duration_number, duration_type, manual_or_not FROM ".$prefix."linksale_prefs WHERE ID=1") or die(mysql_error(). " e75859397634908398479306497857428747");
    $sql = mysql_fetch_object($sql);
    
    
    if ($_POST['anchor'] && $_POST['URL'])
    {
       $gid = mysql_fetch_assoc(mysql_query("select max(id) as maxid from ".$prefix."links where url = '" . addslashes($_POST['url']) . "' limit 1"));
       $newid = $gid['maxid'];
       $anchor = mysql_real_escape_string($_POST['anchor']);
       $url = mysql_real_escape_string($_POST['URL']);
       // $time_submitted=mysql_real_escape_string($_POST['URL']);
       $ip = $_SERVER['REMOTE_ADDR'];
       mysql_query("INSERT INTO ".$prefix."links (hreftext, url, time_submitted, ip) VALUES ('$anchor', '$url', NOW(), '$ip')") or die(mysql_error(). "e74538746284562994528452846");
       print "cff";
    print '<script>window.location="https://www.paypal.com/xclick/business=' 
    	. urlencode($paypal_email) 
    	. '&item_name=' 
    	. urlencode("Link") 
    	. '&item_number=' 
    	. urlencode(1) 
    	. '&amount=' 
    	. urlencode($sql->price) 
    	. '&no_shipping=1&return=' 
    	. paypalURL($full_url_to_the_path. "/add_link") 
    	. '&no_note=1&currency_code=' 
    	. urlencode($currency) 
    	. '&lc=' 
    	. urlencode($paypal_country_code) 
    	. '&notify_url=' 
    	. paypalURL($paypal_notify_url) 
    	. '&custom=' 
    	. $newid 
    	. '&on0=Url&os0=' 
    	. paypalURL($url) . ';"</script>';
    }
    
    ?>
    Code (markup):
    All I get is a blank page with ''cff". The database adding went just fine.. the only thing that don't work is the paypal string.
     
    latehorn, Jul 22, 2006 IP
  5. PinoyIto

    PinoyIto Notable Member

    Messages:
    5,863
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    260
    #5
    try this

    
    <? include("config.php");
    
    $sql = mysql_query("SELECT price, numbern, duration_number, duration_type, manual_or_not FROM ".$prefix."linksale_prefs WHERE ID=1") or die(mysql_error(). " e75859397634908398479306497857428747");
    $sql = mysql_fetch_object($sql);
    
    
    if ($_POST['anchor'] && $_POST['URL'])
    {
       $gid = mysql_fetch_assoc(mysql_query("select max(id) as maxid from ".$prefix."links where url = '" . addslashes($_POST['url']) . "' limit 1"));
       $newid = $gid['maxid'];
       $anchor = mysql_real_escape_string($_POST['anchor']);
       $url = mysql_real_escape_string($_POST['URL']);
       // $time_submitted=mysql_real_escape_string($_POST['URL']);
       $ip = $_SERVER['REMOTE_ADDR'];
       mysql_query("INSERT INTO ".$prefix."links (hreftext, url, time_submitted, ip) VALUES ('$anchor', '$url', NOW(), '$ip')") or die(mysql_error(). "e74538746284562994528452846");
       print "cff";
    $link = "Link";
    $fullpath = $full_url_to_the_path. "/add_link"
    
    print '<script>window.location="https://www.paypal.com/xclick/business=' 
    	. urlencode($paypal_email) 
    	. '&item_name=' 
    	. urlencode($link) 
    	. '&item_number=' 
    	. urlencode(1) 
    	. '&amount=' 
    	. urlencode($sql->price) 
    	. '&no_shipping=1&return=' 
    	. paypalURL($fullpath) 
    	. '&no_note=1&currency_code=' 
    	. urlencode($currency) 
    	. '&lc=' 
    	. urlencode($paypal_country_code) 
    	. '&notify_url=' 
    	. paypalURL($paypal_notify_url) 
    	. '&custom=' 
    	. $newid 
    	. '&on0=Url&os0=' 
    	. paypalURL($url) . '";</script>';
    }
    
    ?>
    
    Code (markup):
     
    PinoyIto, Jul 22, 2006 IP
  6. PinoyIto

    PinoyIto Notable Member

    Messages:
    5,863
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    260
    #6
    I have also try this code at my server and it works

    
    <? include("config.php");
    
    $sql = mysql_query("SELECT price, numbern, duration_number, duration_type, manual_or_not FROM ".$prefix."linksale_prefs WHERE ID=1") or die(mysql_error(). " e75859397634908398479306497857428747");
    $sql = mysql_fetch_object($sql);
    
    
    if ($_POST['anchor'] && $_POST['URL'])
    {
       $gid = mysql_fetch_assoc(mysql_query("select max(id) as maxid from ".$prefix."links where url = '" . addslashes($_POST['url']) . "' limit 1"));
       $newid = $gid['maxid'];
       $anchor = mysql_real_escape_string($_POST['anchor']);
       $url = mysql_real_escape_string($_POST['URL']);
       // $time_submitted=mysql_real_escape_string($_POST['URL']);
       $ip = $_SERVER['REMOTE_ADDR'];
       mysql_query("INSERT INTO ".$prefix."links (hreftext, url, time_submitted, ip) VALUES ('$anchor', '$url', NOW(), '$ip')") or die(mysql_error(). "e74538746284562994528452846");
       print "cff";
    
    print "<script>window.location=\"https://www.paypal.com/xclick/business=" 
    	. urlencode($paypal_email) 
    	. "&item_name=" 
    	. urlencode(\"Link\") 
    	. "&item_number=" 
    	. urlencode(1) 
    	. "&amount=" 
    	. urlencode($sql->price) 
    	. "&no_shipping=1&return=" 
    	. paypalURL($full_url_to_the_path. \"/add_link\") 
    	. "&no_note=1&currency_code=" 
    	. urlencode($currency) 
    	. "&lc=" 
    	. urlencode($paypal_country_code) 
    	. '&notify_url=' 
    	. paypalURL($paypal_notify_url) 
    	. "&custom=" 
    	. $newid 
    	. "&on0=Url&os0=" 
    	. paypalURL($url) . "\";</script>";
    }
    
    ?>
    
    Code (markup):
     
    PinoyIto, Jul 22, 2006 IP
    latehorn likes this.
  7. coderlinks

    coderlinks Peon

    Messages:
    282
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Being the paranoid fool I am :D , I don't think you should leave the paypal redirection stuff to the client. He can just modify the URL, using Opera's Source Editing function. He can change the amount to... say $0.01 . I don't know if you are verifying it or anything. You COULD use cURL (http://www.php.net/curl ) to fetch the paypal URL and display it. That way, any bad guys won't be able to tamper with your system :D .

    Just my $0.02 :D.
    Thomas
     
    coderlinks, Jul 22, 2006 IP
    latehorn likes this.
  8. latehorn

    latehorn Guest

    Messages:
    4,676
    Likes Received:
    238
    Best Answers:
    0
    Trophy Points:
    0
    #8
    PinoyIto , thanks but it doesn't work

    coderlinks, I can check up the payed amount on my paypal file later on anyway.. however.. thanks for the advice!
     
    latehorn, Jul 23, 2006 IP