@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
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
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 r ($errors);
}
}
}
//findAccounts($Name);
displayTable();
global $errors;
if (isset($errors)) {
echo '$errors
';
}
Find Name:
@mike
its ok mike
have a wonderfull vacation
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 <strong>".$r->Id. "</strong></td>
<td>Account Name <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($e, true) . '</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>
@mike
what a suprise
i think you on vacation, nice trip ??
thanks for that your program is compile succesfully
@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.
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
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 >http://www.mikesimonds.com/salesforc...cript-t41.html
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
its ok
thanks for your help mike
have a nice vacation
Bookmarks