Obama '08

               
   

Go Back   Mike Simonds > Salesforce > Salesforce Coding Discussions

This is a discussion on Salesforce PHP form Help within the Salesforce Coding Discussions forums, part of the Salesforce category; @mike can you help me again ?? i had a problem when

Reply
 
LinkBack (8) Thread Tools Rate Thread
  #1  
Old 08-07-2007, 02:38 AM
Junior Member
 
Join Date: Aug 2007
Posts: 10
Salesforce PHP form Help

@mike
can you help me again ??
i had a problem when i want search data from database, i cann't sending a variable to select menu
here is my coding :





i write it on one page it's call find.php
thanks,
randy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2  
Old 08-07-2007, 08:46 AM
Administrator
 
Join Date: May 2007
Posts: 248
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike

Sarma I was able to move just this one thread and create a new thread by being an admin on my own site, go figure, lol

Listen I will look into your question today or tomorrow, not sure I will get a chance though, I am getting ready to go on vacation.


Thanks
Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 08-07-2007, 07:26 PM
Junior Member
 
Join Date: Aug 2007
Posts: 10

PHP Code:

include ('header.inc');
require_once (
'./soapclient/SforcePartnerClient.php');
require_once (
'./soapclient/SforceHeaderOptions.php');
require_once (
'AccountsAction.php');

session_start();

if (!isset(
$_SESSION['sessionId'])) {
    
header('Location: login.php');
    exit;
}

$mySforceConnection;
$myUserInfo;
function 
findAccounts($Name) {
    
$query "SELECT Name FROM Account WHERE Name =" '$name';
    
//    $queryOptions = new QueryOptions(500);
    //    $response = $connection->query(($query), $queryOptions);
    //    return $response->records;
}

function 
displayTable() {
    global 
$mySforceConnection;
    
$accts findAccounts($Name);
    if (
$accts) {
        print (
'There are currently ' count($accts) . ' accounts:
'
);
        print 
'';
    }
}


if (isset (
$_POST['FindClick'])) {
    if (!
$_POST['findName'])
        {
            global
$errors;
            
$errors = ('Please fill name to search.');
        }
        else
        {
            
$_POST['findName'] = trim($_POST['findName']);
            try
            {
                
$result findAccounts($_POST['findName']);
        }
            catch (
exception $e)
            {
                print 
($errors);
            }
        } 
}
//findAccounts($Name);
displayTable();


global 
$errors;
if (isset(
$errors)) {
    echo 
'$errors
'
;
}




  
  
    
  

Find Name

Quote:
Originally Posted by mike View Post
Sarma I was able to move just this one thread and create a new thread by being an admin on my own site, go figure, lol

Listen I will look into your question today or tomorrow, not sure I will get a chance though, I am getting ready to go on vacation.


Thanks
Mike
@mike
its ok mike
have a wonderfull vacation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 08-08-2007, 08:41 AM
Administrator
 
Join Date: May 2007
Posts: 248
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike

Sarma

Try this code, it worked for me: You will need your saleforce login, password and the account name:


PHP Code:
<?php

ini_set
("soap.wsdl_cache_enabled""0");
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);

require_once (
'./includes/soapclient/SforcePartnerClient.php');
require_once (
'./includes/soapclient/SforceHeaderOptions.php');

if (isset(
$_POST['submit']))
{
    
$user trim($_POST['user']);
    
$pass trim($_POST['pass']);
    
$account_name htmlspecialchars(trim($_POST['a_name']));





    
//Go get the accounts by $account_name
    
try
    {
            
//salesforce  wsdl
          
$wsdl './includes/soapclient/partner.wsdl.xml';

          
//connect to salesforce
          
$client = new SforcePartnerClient();
          
$client->createConnection($wsdl);
          
$loginResult $client->login($user$pass);

          
$accounts get_accounts($client$account_name);

          if (
$accounts)
          {
            echo 
"<table>\n";

              echo 
"<tr>\n";
              foreach (
$accounts as $r)
              {
                    
$r = new SObject($r);
                    echo 
"<td>Account Id&nbsp;<strong>".$r->Id"</strong></td>&nbsp;&nbsp;
                          <td>Account Name&nbsp;<strong>" 
.$r->fields->Name."</strong></td>\n";
              }
              echo 
"</tr>\n";
            echo 
"</table>\n";
          }
          else
          {
            echo 
"No Account Found By That Name";
          }
          exit;



    }
    catch (
exception $e)
    {
        
// This is reached if there is a major problem in the data or with
        // the salesforce.com connection. Normal data errors are caught by
        // salesforce.com
        
echo '<pre>' print_r($etrue) . '</pre>';
        return 
false;
        exit;
    }

}

/* functions */

function get_accounts($connection$name)
{
  
$query "SELECT Id, Name FROM Account WHERE Name =  '$name'";

  
$queryOptions = new QueryOptions(500);
  
$response $connection->query(($query), $queryOptions);
  
$accounts $response->records;

  return 
$accounts;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Get Account From Salesforce.com</title>
</head>
<body>
  <center><img src="http://www.salesforce.com/us/assets/developer/adn_logo.gif" alt="" border="0"></center>
  <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
      <table width="100%" align="center">
        <tr>
          <td align="right">* Salesforce Username: </td>
          <td align="left"><input name="user" type="text" maxlength="50" align="right"></td>
        </tr>
        <tr>
          <td align="right">* Salesforce Password </td>
          <td align="left"><input name="pass" type="password" maxlength="50"></td>
        </tr>
        <tr>
          <td align="right">* Account Name To Search: </td>
          <td align="left"><input name="a_name" type="text" maxlength="50" align="right"></td>
        </tr>
        <tr>
          <td align="center" colspan="2"><input type="submit" name="submit" value="Check Account"></td>
        </tr>
      </table>
    </form>
  </body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 08-08-2007, 09:14 PM
Junior Member
 
Join Date: Aug 2007
Posts: 10

@mike
what a suprise
i think you on vacation, nice trip ??

thanks for that your program is compile succesfully
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 08-09-2007, 01:29 AM
Junior Member
 
Join Date: Aug 2007
Posts: 10

@mike

for add, update and delete data to database, can we use some syntax like this :

INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)

UPDATE tableName SET column_name = new_value WHERE columns1 = [FONT=verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif]"1"[/font]

DELETE FROM tableName WHERE column1 = '1'

this syntax ussually i use for insert, update and delete with visual basic 6, but it can use for php, you can see it at
PHP MySQL Delete From

in php, can i call a mesagge box ?
like in vb6, coz i want to confirm first before delete data

thanks,
randy

Last edited by sarma; 08-09-2007 at 03:37 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7  
Old 08-09-2007, 10:48 AM
Administrator
 
Join Date: May 2007
Posts: 248
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike
Smile Nope!!

Quote:
Originally Posted by sarma View Post
@mike

for add, update and delete data to database, can we use some syntax like this :

INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)

UPDATE tableName SET column_name = new_value WHERE columns1 = [FONT=verdana,geneva,lucida,'lucida grande',arial,helvetica,sans-serif]"1"[/font]

DELETE FROM tableName WHERE column1 = '1'

this syntax ussually i use for insert, update and delete with visual basic 6, but it can use for php, you can see it at
PHP MySQL Delete From

in php, can i call a mesagge box ?
like in vb6, coz i want to confirm first before delete data

thanks,
randy
No Sarma you cannot update items in your Salesforce instance performing SQL statements such as this. The best advice that I could give you is to create scripts that will download your data from Salesforce into local DB tables (I have done this for Oracle and MySQL), manipulate the data locally then use select statements to create insert, update, and upsert script back into your org's instance of salesforce. I have examples of how to create backup scripts on this site

Hope that helps

~Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8  
Old 08-09-2007, 08:48 PM
Junior Member
 
Join Date: Aug 2007
Posts: 10

Quote:
Originally Posted by mike View Post
No Sarma you cannot update items in your Salesforce instance performing SQL statements such as this. The best advice that I could give you is to create scripts that will download your data from Salesforce into local DB tables (I have done this for Oracle and MySQL), manipulate the data locally then use select statements to create insert, update, and upsert script back into your org's instance of salesforce. I have examples of how to create backup scripts on this site

Hope that helps

~Mike
@mike
where can i found your example of how to create backup scripts ??
so that i can make a program without connection to the internet
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9  
Old 08-09-2007, 09:28 PM
Administrator
 
Join Date: May 2007
Posts: 248
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike

No you will always have to have some sort of Internet connection when working with salesforce's API, that is a given

It depends on what type of database you are using, I have two tutorials, one uses Oracle and one uses MySQL >Salesforce – PHP To MySQL Database Replication Script


I think I remember reading somewhere that you are using MS Sql, if that is true, ADOdb works with that, you would just need to create your tables in your local MS SQL database or use MySQL (it's free)

I dont work with MS SQL at all and never have, but it cannot be too hard to setup a script to work

Hope that helps

I am leaving on vacation tomorrow for 15 days, I wont be around to answer stuff after tomorrow morning (my time, -6 GMT)

Sorry if that is not enough and I do really appreciate you participating in my little community

I hope that I have been some help with your work

All the best,
Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10  
Old 08-12-2007, 09:03 PM
Junior Member
 
Join Date: Aug 2007
Posts: 10

its ok
thanks for your help mike
have a nice vacation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.mikesimonds.com/salesforce-php-form-help-t46.html
Posted By For Type Date
Community - ask Salesforce Code Example #1 - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 08-21-2008 09:42 PM
Community - ask Salesforce Code Example #1 - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 07-18-2008 05:16 PM
Equity Home Loan Refinance - requirements equity, loan maryland This thread Refback 11-16-2007 09:52 AM
Re: ask Salesforce Code Example #1 - Perl, PHP, Python & Ruby Development This thread Refback 09-28-2007 10:47 PM
Community - Re: ask Salesforce Code Example #1 - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 08-24-2007 05:27 PM
Re: ask Salesforce Code Example #1 - Perl, PHP, Python & Ruby Development This thread Refback 08-18-2007 01:46 PM
Community - Re: ask Salesforce Code Example #1 - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 08-08-2007 07:42 PM
Community - ask Salesforce Code Example #1 - Perl, PHP, Python & Ruby Development - Salesforce.com Community This thread Refback 08-08-2007 08:55 AM



Powered by vBulletin


SEO by vBSEO 3.2.0 RC8 ©2008, Crawlability, Inc.

1 2 3 4 5