1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help please.. PHP

Discussion in 'General Programming Chat' started by lumpia, Sep 1, 2011.

  1. lumpia

    lumpia Registered Member

    Joined:
    Jan 21, 2009
    Messages:
    98
    Likes Received:
    7
    I am getting this error.
    "Parse error: syntax error, unexpected T_DOUBLE_ARROW in CODE on line 85 Errors parsing "
    I bolded where it thinks the error is:
    Can someone help please???


    <?php

    require_once 'appinclude.php';


    $dbhost = 'db.db.1and1.com';
    $dbuser = 'db';
    $dbpass = 'b';
    $dbname = 'db';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    mysql_select_db($dbname, $conn);

    function query($q) {
    global $conn;
    $result = mysql_query($q, $conn);
    if (!$result) {
    die("Invalid query -- $q -- " . mysql_error());
    }
    return $result;
    }

    //====================================
    // Add a new user data
    //====================================
    function add_user( $user ) {

    query("INSERT INTO `wusers` (`userid`) VALUES ( $user )");

    }
    //====================================
    // Check if user exists
    //====================================
    function check_user( $u ) {

    $rs = query("SELECT * FROM wusers WHERE userid = $u");

    list($total_rows) = mysql_fetch_array($rs);

    if( $total_rows > 0 ) return true;
    else return false;

    }

    //====================================
    // Show Gifts
    //====================================
    function show_gifts() {

    $imgdir = 'gifts';
    $allowed_types = array('png','jpg','jpeg','gif');

    $a_img = array();
    $dimg = opendir($imgdir);
    while( $imgfile = readdir($dimg) )
    {
    if( in_array(strtolower(substr($imgfile,-3)),$allowed_types) )
    {
    $a_img[] = $imgfile;
    sort($a_img);
    reset ($a_img);
    }
    }

    return $a_img;

    }

    //====================================
    // SEND GIFTS
    //====================================
    function send_gift( $from, $to, $gift ) {

    global $facebook;

    $total_send = count($to);

    for( $x=0; $x<$total_send; $x++ ) {

    query("INSERT INTO gifts (`giftfrom`, `giftto`, `gname`) VALUES( $from, $to[$x], \"$gift\" )");

    try
    {
    // Send notification
    $facebook=>api_client->notifications_send($to[$x], 'sent you a gift using <a href="http://apps.facebook.com/love_gifts/">Love Gifts</a>. <a href="http://apps.facebook.com/YOUR_APP/">Check your gift</a>.');



    }
    // Publish feed story
    $feed_title = '<fb:userlink uid="'.$from.'" shownetwork="false"/> sent a gift to <fb:name uid="'.$to[$x].'"/> using <a href="http://apps.facebook.com/love_gifts/">Love Gifts</a>.';

    $feed_body = 'Check out <a href="http://apps.facebook.com/love_gifts/"> <fb:name uid="'.$to[$x].'" firstnameonly="true" possessive="true"/> Love Gifts</a>.';

    $facebook->api_client->feed_publishActionOfUser($feed_title, $feed_body);
    } catch (Exception $e) {
    error_log($e->getMessage());
    }
    // end of for

    }

    //====================================
    // Show Sent Gifts
    //====================================
    function show_sent_gifts( $u ) {

    $result = query("SELECT * FROM `gifts` WHERE `giftfrom` = $u ORDER BY `gid` DESC LIMIT 0,6");

    list($total_gift) = mysql_fetch_array($result);

    if( $total_gift > 0 ) {

    $output = '<H3><fb:name uid='.$u.' useyou=false /> sent the following gifts:</H3>';
    $output .= '<table border=0 cellpadding=2><tr>';

    $res = query("SELECT * FROM `gifts` WHERE `giftfrom` = $u ORDER BY `gid` DESC LIMIT 0,6");
    $counter = 0;

    while( $row = mysql_fetch_array($res) ) {

    $output .= "<td><img src=http://giftapp.sur23.com/lover_gifts/gifts/$row[gname]><BR><font color=#336633>Sent to <fb:name uid=$row[giftto] useyou=false /></font><BR>";

    $counter++;
    if( $counter == 3 ) $output .= "</tr><tr>";
    }

    $output .= '</tr></table>';
    }
    else {
    $output = '<H3>Send gifts to your friends <a href=http://apps.facebook.com/lov_gifts/>now</a>.</H3>';
    }

    return $output;

    }

    //====================================
    // Show Sent Gifts
    //====================================
    function show_received_gifts( $u ) {

    $result = query("SELECT * FROM `gifts` WHERE `giftto` = $u ORDER BY `gid` DESC LIMIT 0,6");

    list($total_gift) = mysql_fetch_array($result);

    if( $total_gift > 0 ) {

    $output = '<H3><fb:name uid='.$u.' useyou=false /> received the following gifts:</H3>';
    $output .= '<table border=0 cellpadding=2><tr>';

    $res = query("SELECT * FROM `gifts` WHERE `giftto` = $u");
    $counter = 0;

    while( $row = mysql_fetch_array($res) ) {

    $output .= "<td><img src=http://giftapp.sur23.com/lover_gifts/gifts/$row[gname]><BR><font color=#336633>Received from <fb:name uid=$row[giftfrom] useyou=false /></font><BR>";

    $counter++;
    if( $counter == 3 ) $output .= "</tr><tr>";
    }

    $output .= '</tr></table>';
    }
    else {
    $output = '<H3><fb:name uid='. $u .' useyou=false /> haven\'t received any gifts yet. <br>Send him a <a href=http://apps.facebook.com/love_gifts/><B>Love Gift</B> now</a>.</H3>';
    }

    return $output;

    }

    ?>
     
  2. xenon2010

    xenon2010 Regular Member

    Joined:
    Apr 27, 2010
    Messages:
    231
    Likes Received:
    48
    Occupation:
    web and desktop apps programmer
    Location:
    prison
    Home Page:
    dude don't write the whole codes... no one will ever try to read that..
    just post the error and the line contains that error.. we might can help you with something
     
  3. Narrator

    Narrator Power Member

    Joined:
    Oct 5, 2010
    Messages:
    507
    Likes Received:
    396
    Occupation:
    Internet Marketing
    Location:
    /dev/null
    Should it be
    PHP:
    // Send notification
    $facebook->api_client->notifications_send($to[$x], 'sent you a gift using <a href="http://apps.facebook.com/love_gifts/">Love Gifts</a>. <a href="http://apps.facebook.com/YOUR_APP/">Check your gift</a>.');
    $facebook->api_client instead of $facebook=>api_client