SQL PHP Problem

Discussion in 'PHP' started by ZDigital, Nov 25, 2009.

  1. #1
    I'm having a problem with this. When I run it and then browse the SQL table afterwords it does not run the SQL query.

    Help please

    <?
    require_once('back/facebook.php'); 
    include_once('back/functions.php');
    
    
    $apikey = 'xxx';
    $secret = 'xxx';
    $facebook = new Facebook($apikey, $secret);
    
    $connsql = mysql_connect(localhost, faceradio, xxx) 
      or die ('Error connecting to mysql');
    mysql_select_db("faceradio", $connsql);
    
    $uid = $facebook;
    $facebook->api_client->notifications_send($uid, 'testing 123', 'app_to_user');
    mysql_query("INSERT INTO 'users' ('uid') VALUES ('$uid'), $connect")
    	or die ('error ' mysql_error());
       
    
    ?>
    Code (markup):
     
    ZDigital, Nov 25, 2009 IP
  2. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    May be you meant this?
    <?
    mysql_query("INSERT INTO `users` (`uid`) VALUES ('$uid')", $connsql)
    ?>
    Code (markup):
     
    stOK, Nov 25, 2009 IP
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    Yea its coz of wrong placement of "
     
    Bohra, Nov 25, 2009 IP
  4. uzairjawed

    uzairjawed Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    $uid = $facebook;
    PHP:
    The error is above.

    you are copying Object of facebook class in $uid..

    since i have developed facebook application. I guess you are missing here $facebook->require_login() call

    i.e

    $uid = $facebook->require_login();
    PHP:
     
    uzairjawed, Nov 25, 2009 IP
  5. matrocka

    matrocka Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    uzair has it on the mark.
     
    matrocka, Nov 25, 2009 IP
  6. ZDigital

    ZDigital Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    This is what I have now, but it quit sending the notifications and I'm still not getting the stuff inserted into the SQL table

    <?
    require_once('back/facebook.php'); 
    include_once('back/functions.php');
    
    
    $apikey = 'xxx';
    $secret = 'xxx';
    $facebook = new Facebook($apikey, $secret);
    $uid = $facebook->require_login();
    
    $connsql = mysql_connect(localhost, faceradio, xxx);
    mysql_select_db("faceradio", $connsql);
    
    
    $facebook->api_client->notifications_send($uid, 'testing 123', 'app_to_user');
    mysql_query("INSERT INTO 'users' ('uid') VALUES ('$uid')", $connsql);
       
    
    ?>
    PHP:
     
    ZDigital, Nov 25, 2009 IP
  7. uzairjawed

    uzairjawed Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #7
    var_dump($uid);
    PHP:
    do this after

    $uid = $facebook->require_login();
    PHP:
    and check whether its printing your facebook Id or not


    replace
    mysql_select_db("faceradio", $connsql);
    PHP:
    with
    mysql_select_db("faceradio", $connsql) or die("uzair"); 
    PHP:


    Replace
    $connsql = mysql_connect(localhost, faceradio, xxx);
    PHP:
    with
    $connsql = mysql_connect("localhost", "faceradio", "xxx") or die("connection error");
    PHP:
    Replace
    mysql_query("INSERT INTO 'users' ('uid') VALUES ('$uid')", $connsql);
    PHP:
    with
    mysql_query("INSERT INTO `users` (`uid`) VALUES ($uid)", $connsql);
    PHP:
    its just for debugging so do print the values over here if this dont solves your problem ..
     
    uzairjawed, Nov 25, 2009 IP
  8. ZDigital

    ZDigital Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The problem with dumping the variables is this is just the Post Authorize page that facebook pings after adding the application
     
    ZDigital, Nov 25, 2009 IP
  9. japanninja

    japanninja Active Member

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    50
    #9
    The problem is with your query.

    You should not use single quotes for column names.

    Change this:
    
    mysql_query("INSERT INTO `users` (`uid`) VALUES ($uid)", $connsql);
    
    Code (markup):
    To:
    
    mysql_query("INSERT INTO users (uid) VALUES ('$uid')", $connsql);
    
    Code (markup):
     
    japanninja, Nov 26, 2009 IP
  10. ZDigital

    ZDigital Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Ok i tried running it and I got this


     
    ZDigital, Nov 26, 2009 IP
  11. japanninja

    japanninja Active Member

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    50
    #11
    Please post the code in facebook.php
     
    japanninja, Nov 26, 2009 IP