How to apply word wrap using zend_pdf library, I am using MyPDFTable lib as an extension for zendPdf lib.
I have used following code.
<?php
// include auto-loader class
require_once 'Zend/Loader/Autoloader.php';
// register auto-loader
$loader = Zend_Loader_Autoloader::getInstance();
try {
// set up database access parameters
$params = array ('host' => '127.0.0.1',
'username' => 'user',
'password' => 'pass',
'dbname' => 'world');
// configure adapter and query database
$db = Zend_Db::factory('PDO_MYSQL', $params);
$stmt = $db->query('SELECT Name, Code, Region FROM country LIMIT 0, 150');
// create PDF
$pdf = new My_Pdf_Document('example.pdf', '.');
// create page
$page = $pdf->createPage();
// define font resource
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// set font
$page->setFont($font, 24);
// create table
$table = new My_Pdf_Table(3);
// iterate over record set
// set up table content
while ($record = $stmt->fetch()) {
$row = new My_Pdf_Table_Row();
$cols = array();
foreach ($record as $k => $v) {
$col = new My_Pdf_Table_Column();
$col->setText($v);
$cols[] = $col;
}
$row->setColumns($cols);
$row->setFont($font, 14);
$row->setBorder(My_Pdf::TOP, new Zend_Pdf_Style());
$row->setBorder(My_Pdf::BOTTOM, new Zend_Pdf_Style());
$row->setBorder(My_Pdf::LEFT, new Zend_Pdf_Style());
$row->setCellPaddings(array(10,10,10,10));
$table->addRow($row);
}
// add table to page
$page->addTable($table, 0, 0);
// add page to document
$pdf->addPage($page);
// save as file
$pdf->save();
echo 'SUCCESS: Document saved!';
} catch (Zend_Pdf_Exception $e) {
die ('PDF error: ' . $e->getMessage());
} catch (Exception $e) {
die ('Application error: ' . $e->getMessage());
}
?>
You will find this code on http://devzone.zend.com/1776/creating-pdf-documents-with-zend-framework/ In topic "Turning The Tables".
This tutorial talks about the same problem you faced. They have provided a custom solution also!
http://www.ibm.com/developerworks/opensource/tutorials/os-php-zend5/section4.html
Related
So, I'm novice at best with php, but I've figured out how to set up and send transactional emails with sendinblue.
But for whatever reason, I can't seem to set the attributes.
This is really the only line of the code that I can't seem to get to work.
$sendEmail['attributes'] = array('FIRSTNAME' => "STEVE");$sendEmail['attributes'] = array('FIRSTNAME' => "STEVE");
I've also tried
$sendEmail['params'] = array('FIRSTNAME' => "STEVE");
and
$params['attributes'] = array('FIRSTNAME' => "STEVE");
...and probably 127 variations of the above, but I can't seem to get it it to work.
I also can't seem to figure out how to create a contact with php...
What is the "create contact" equivilent of this line of code:
$sendEmail = new \SendinBlue\Client\Model\SendEmail();
?
Like I said, my emails asre sending, but where I expect them to read "Dear STEVE," they read "Dear ,"
BELOW IS THE FULL CODE:
<?php
# Include the SendinBlue library\
require_once('../vendor/autoload.php');
# Instantiate the client\
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'MY API KEY HERE');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer');
// Configure API key authorization: partner-key
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('partner-key', 'MY API KEY HERE');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('partner-key', 'Bearer');
$apiInstance = new SendinBlue\Client\Api\SMTPApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$templateId = 2; // int | Id of the template
$sendEmail = new \SendinBlue\Client\Model\SendEmail(); // \SendinBlue\Client\Model\SendEmail |
$sendEmail['emailTo'] = array("test#example.com");
$params['attributes'] = array('FIRSTNAME' => "STEVE"); //THIS IS THE LINE OF CODE THAT ISN'T WORKING.
//$mail->setFrom('info#myeasy.wedding', 'My Easy Wedding');
try {
$result = $apiInstance->sendTemplate($templateId, $sendEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SMTPApi->sendTemplate: ', $e->getMessage(), PHP_EOL;
}
?>
You need to use sendTransacEmail() and it works with PARAM. Need to add code in template {{ params.FIRSTNAME }}
Complete API code
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'MY API KEY HERE');
$apiInstance = new SendinBlue\Client\Api\TransactionalEmailsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$sendEmail = new SendinBlue\Client\Model\SendSmtpEmail();
$sendEmail['to'] = [["email" => 'test#example.com', "name" => 'test']];
$sendEmail['templateId'] = 2;
$sendEmail['params'] = ['FIRSTNAME' => 'Test'];
try {
$response = $apiInstance->sendTransacEmail($sendEmail);
print_r($response);
} catch (Exception $e) {
echo 'Exception when calling AccountApi->getAccount: ', $e->getMessage(), PHP_EOL;
}
try to use FNAME instead of FIRSTNAME
Reference
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR API KEY');
$apiInstance = new SendinBlue\Client\Api\TransactionalEmailsApi(
new GuzzleHttp\Client(),
$config
);
$templateId = 1;
$sendEmail = new \SendinBlue\Client\Model\SendEmail()
$sendEmail['emailTo'] = array('example#example.com');
$sendEmail['emailCc'] = array('example1#example1.com');
$sendEmail['headers'] = array('Some-Custom-Name' => 'unique-id-1234');
$sendEmail['attributes'] = array('FNAME' => 'Jane', 'LNAME' => 'Doe');
$sendEmail['replyTo'] = 'replyto#domain.com';
$sendEmail['attachmentUrl'] = 'https://example.net/upload-file.pdf';
try {
$result = $apiInstance->sendTemplate($templateId, $sendEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling TransactionalEmailsApi->sendTemplate: ', $e->getMessage(), PHP_EOL;
}
?>
You can find more examples at https://developers.sendinblue.com/
I try to send attachment pdf file. I get the email but no attachmetn.
I have try to use https://github.com/sendinblue/APIv3-php-library/blob/master/docs/Model/SendSmtpEmail.mdenter
$sendSmtpEmail = new \SendinBlue\Client\Model\SendSmtpEmail();
$sendSmtpEmail['to'] = array(array('email'=>'email#email.com'));
$sendSmtpEmail['templateId'] = 39;
$sendSmtpEmail['params'] = array(
'NUMEROFACTURE'=> "12345",
'CODECLIENT' => "1234567",
'TOSEND' => "email1#email.net",
'MONTANTFACTURE'=> number_format(12, 2, ',', ' '),
);
$attachement = new \SendinBlue\Client\Model\SendSmtpEmailAttachment();
$attachement['url']= __DIR__'/facture/Facture-'.$row["ClePiece"].'.pdf';
$attachement['name']= 'Facture-'.$row["ClePiece"].'.pdf';
$attachement['content']= "utf-8";
$sendSmtpEmail['attachment']= $attachement;
$sendSmtpEmail['headers'] = array('Content-Type'=>'application/pdf','Content-Disposition'=>'attachment','filename'=>'Facture-'.$row["ClePiece"].'.pdf',"charset"=>"utf-8");
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR_API_KEY');
$apiInstance = new SendinBlue\Client\Api\SMTPApi(new GuzzleHttp\Client(),$config);
try {
$result = $apiInstance->sendTransacEmail($sendSmtpEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SMTPApi->sendTransacEmail: ', $e->getMessage(), PHP_EOL;
}
According to the SendSmtpEmailAttachment documentation, you have two ways to attach a file using a url or a content.
url | Absolute url of the attachment (no local file).
content | Base64 encoded chunk data of the attachment generated on the fly
You are wrongly assigning "utf-8" to the content. This mean you need to convert the pdf data into a base64 chunk data. First, get the pdf path in your server as $pdfdocPath. Get the pdf content using file_get_contents method and encode it using base64_encode method. Finally, split the content in small chunks using chunk_split as shown in the next snippet:
$sendSmtpEmail = new \SendinBlue\Client\Model\SendSmtpEmail();
$sendSmtpEmail['to'] = array(array('email'=>'email#email.com'));
$sendSmtpEmail['templateId'] = 39;
$sendSmtpEmail['params'] = array(
'NUMEROFACTURE'=> "12345",
'CODECLIENT' => "1234567",
'TOSEND' => "email1#email.net",
'MONTANTFACTURE'=> number_format(12, 2, ',', ' '),
);
$pdfdocPath = __DIR__.'/facture/Facture-'.$row["ClePiece"].'.pdf';
$b64Doc = chunk_split(base64_encode(file_get_contents($pdfdocPath)));
$attachement = new \SendinBlue\Client\Model\SendSmtpEmailAttachment();
$attachement['name']= 'Facture-'.$row["ClePiece"].'.pdf';
$attachement['content']= $b64Doc;
$sendSmtpEmail['attachment']= $attachement;
$sendSmtpEmail['headers'] = array('Content-Type'=>'application/pdf','Content-Disposition'=>'attachment','filename'=>'Facture-'.$row["ClePiece"].'.pdf',"charset"=>"utf-8");
Update:
I checked the APIv3-php-library source code and I found that the constructor will do the validation of name and content.
$dataEmail = new \SendinBlue\Client\Model\SendEmail();
$dataEmail['emailTo'] = ['abc#example.com', 'asd#example.com'];
// PDF wrapper
$pdfDocPath = __DIR__.'/facture/Facture-'.$row["ClePiece"].'.pdf';
$content = chunk_split(base64_encode(file_get_contents($pdfDocPath)));
// Ends pdf wrapper
$attachment_item = array(
'name'=>'Facture-'.$row["ClePiece"].'.pdf',
'content'=>$content
);
$attachment_list = array($attachment_item);
// Ends pdf wrapper
$dataEmail['attachment'] = $attachment_list;
$templateId = 39;
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR_API_KEY');
$apiInstance = new SendinBlue\Client\Api\SMTPApi(new GuzzleHttp\Client(),$config);
try {
$result = $apiInstance->sendTemplate($templateId, $dataEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SMTPApi->sendTemplate: ', $e->getMessage(), PHP_EOL;
}
$dataEmail= new \SendinBlue\Client\Model\SendEmail();
$dataEmail['emailTo'] = ['abc#example.com', 'asd#example.com'];
$dataEmail['attachmentUrl'] = "http://www.ac-grenoble.fr/ia07/spip/IMG/pdf/tutoriel_pdf_creator-2.pdf";
// if you want to use content attachment base64
// $b64Doc = chunk_split(base64_encode($data));
// $attachment_array = array(array(
// 'content'=>$b64Doc,
// 'name'=>'Facture-'.$row["ClePiece"].'.pdf'
// ));
// $dataEmail['attachment'] = $attachment_array;
//Don't forget to delete attachmentUrl
$templateId = 39;
$dataEmail = $dataEmail;
$config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR_API_KEY');
$apiInstance = new SendinBlue\Client\Api\SMTPApi(new GuzzleHttp\Client(),$config);
try {
$result = $apiInstance->sendTemplate($templateId, $dataEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SMTPApi->sendTemplate: ', $e->getMessage(), PHP_EOL;
}
According to the documentaiton SMTPApi->sendTransacEmail function gets SendSmtpEmail object. That object has restrictions for the attachment attribute:
If templateId is passed and is in New Template Language format then only attachment url is accepted. If template is in Old template Language format, then attachment is ignored.
But SMTPApi->sendTemplate function don't have this restriction.
$credentials = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', 'YOUR-KEY');
$apiInstance = new SendinBlue\Client\Api\TransactionalEmailsApi(new GuzzleHttp\Client(),$credentials);
$sendSmtpEmail = new \SendinBlue\Client\Model\SendSmtpEmail([
'subject' => 'test email!',
'sender' => ['name' => 'from name', 'email' => 'from#mail.com'],
//'replyTo' => ['name' => 'test', 'email' => 'noreply#example.com'],
'to' => [[ 'name' => 'Tushar Aher', 'email' => 'receivedto#gmail.com']],
'htmlContent' => '<html><body><h1>This is a transactional email {{params.bodyMessage}}</h1></body></html>',
'params' => ['bodyMessage' => 'this is a test!']
]);
/*$attachement = new \SendinBlue\Client\Model\SendSmtpEmailAttachment();
$attachement['url']= FCPATH.'uploads/invoice/ticket-498410.pdf';
$attachement['name']= 'ticket-498410.pdf';
$attachement['content']= "utf-8";
$sendSmtpEmail['attachment']= $attachement;*/
// PDF wrapper
$pdfDocPath = FCPATH.'uploads/invoice/ticket-498410.pdf';
$content = chunk_split(base64_encode(file_get_contents($pdfDocPath)));
// Ends pdf wrapper
$attachment_item = array(
'name'=>'ticket-498410.pdf',
'content'=>$content
);
$attachment_list = array($attachment_item);
// Ends pdf wrapper
$sendSmtpEmail['attachment'] = $attachment_list;
try {
$result = $apiInstance->sendTransacEmail($sendSmtpEmail);
print_r($result);
} catch (Exception $e) {
echo $e->getMessage(),PHP_EOL;
}
I have developed a php web service on a server with mysql database connection. It can not connect to database and does not execute codes after database connection. Also it does not show any error.
If I return something before database connection line, it is returned.
I have tested another php file with database connection and it works properly.
<?php require_once('lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('ivrmci', 'urn:ivrmciwsdl');
$server->register('upload_file', // method
array('username' => 'xsd:string','password' => 'xsd:string','encoded_filepath' => 'xsd:string','filename' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:ivrmciwsdl', // namespace
'urn:ivrmciwsdl#upload_file', // soapaction
'rpc', // style
'encoded', // use
'Uploads files to the server' // documentation
);
$server->register('inquiryMsisdnCalls', // method
array('username' => 'xsd:string','password' => 'xsd:string','callerid' => 'xsd:string','advertise_id' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:ivrmci', // namespace
'urn:ivrmci#inquiryMsisdnCalls', // soapaction
'rpc',
'encoded', // style // use
'Returns User Log' // documentation
);
function upload_file($username,$password,$encoded,$name) {
if ($username != "abc" OR $password != "123")
{
return "-2";
}
$location = "uploads/".$name; // Mention where to upload the file
//$current = file_get_contents($location); // Get the file content. This will create an empty file if the file does not exist
$current = base64_decode($encoded); // Now decode the content which was sent by the client
file_put_contents($location, $current); // Write the decoded content in the file mentioned at particular location
try
{
$db = new PDO('mysql:dbname=zzz;host=x.x.x.x',"root","1234",array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch(PDOException $e)
{
return "-3";
}
$filename = explode(".", $name);
$sql = "INSERT INTO advertise (name) VALUES ($filename[0])";
try{
$db->exec($sql);
return $db->lastInsertid();
}
catch(PDOException $e)
{
return $e->getMessage();
}
if($name!="")
{
return "File Uploaded successfully..."; // Output success message
}
else
{
return "Please upload a file...";
}
}
function inquiryMsisdnCalls($username,$password,$callerid,$contentid)
{
if ($username != "abc" OR $password != "123")
{
return "-2";
}
try
{
$db = new PDO('mysql:dbname=zzz;host=x.x.x.x',"root","1234",array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch(PDOException $e)
{
return "-3";
}
$sql = "select status from user_advertise_log where callerId=$callerid and advertise_id=$contentid";
try{
$log = $db->query($sql)->fetch(PDO::FETCH_OBJ);
return $log->status;
}
catch(PDOException $e)
{
return $e->getMessage();
}
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
I got some problem with php-sample.
I want to add users, but there were something went wrong.
Please help me!!
Here is code that I used:
<!DOCTYPE html>
<?php
require_once "vendor/autoload.php";
require_once "autoload.dist.php";
require_once "client/JasperClient.php";
require_once "client/User.php";
require_once "client/Role.php";
$client = new Jasper\JasperClient(
"localhost", // Hostname
8080, // Port
"jasperadmin", // Username
"jasperadmin", // Password
"/jasperserver-pro", // Base URL
"organization_1"
); // Organization (pro only)
$newUser = new Jasper\User("BI_User", // username
"superSTRENGTHpassw0rd", // password
"clever#email.com", // email
"Business Intelligence User", // description
"organization_1", // parent organization
"true" // enabled
);
$role = new Jasper\Role("ROLE_USER", NULL, "false");
$newUser->addRole($role);
try {
$client->putUsers($newUser);
}
catch (Exception $e) {
printf("Could not add new user: %s", $e->getMessage());
}?>
And Here is the error message that I got:
Could not add new user: Unexpected HTTP code returned: 400 Body of response:
Apache Tomcat/6.0.26 - Error report HTTP Status 400 - type Status
reportmessage description The request sent by the client was syntactically
incorrect ().Apache Tomcat/6.0.26
Ask I spent time google so much on that problem, I have found the solution.
Here is my solution whether someone are interested.
<?php
require_once "vendor/autoload.php";
require_once "autoload.dist.php";
use Jaspersoft\Client\Client;
use Jaspersoft\Dto\User\User;
use Jaspersoft\Dto\Role\Role;
function registerUsers(){
$client = new Client(
"localhost",
"8080",
"superuser",
"superuser",
"/jasperserver-pro",
"null"
);
$file_path = 'data/userlist.csv';
$handle = fopen($file_path,'r');
$array_users = array();
$i=0;
while (!feof($handle) !==false){
$line = fgetcsv($handle,1024,',');
$i++;
if($i==1) continue;
if(!empty($line)){
for($c = 0; $c < count($line); $c++){
$username = $line[0];
$password = $line[1];
$email = $line[2];
$fullname = $line[3];
$tenantId = $line[4];
$enabled = $line[5];
$user = new User($username, $password, $email,
$fullname, $tenantId, $enabled);
$role = new Role('ROLE_USER', null, 'false');
$array_users[$c] = $user;
$array_users[$c]->addRole($role);
try {
$client->userService()->addUsers($array_users[$c]);
} catch (Exception $e) {
printf('Could not add new user: %s', $e->getMessage());
}
}
}
}
}?>
And here is my csv data file:
User Name,Password,Email Address,Full Name,Tenant ID,Enable
User1,superSTRENGTHpassw0rd,clever#email.com,User One,a,true
User2,superSTRENGTHpassw0rd,clever#email.com,User One,a,true
User3,superSTRENGTHpassw0rd,clever#email.com,User One,a,true
User6,superSTRENGTHpassw0rd,clever#email.com,User One,organization_1,true
User7,superSTRENGTHpassw0rd,clever#email.com,User One,organization_1,true
User8,superSTRENGTHpassw0rd,clever#email.com,User One,b,true
User9,superSTRENGTHpassw0rd,clever#email.com,User One,b,true
User10,superSTRENGTHpassw0rd,clever#email.com,User One,c,true
User11,superSTRENGTHpassw0rd,clever#email.com,User One,c,true
I am developing an SMS Based Registration System and so far I'm at the stage of testing my system. All of a sudden, I was not able to receive any messages from my server when I tried to register via SMS it must receive a confirmation messages. Here's what i did when using PHP nusoap.
Register.php
<?php
// This will allow user to register via SMS.
error_reporting( E_ALL );
// load the nusoap libraries. These are slower than those built in PHP5 but
require_once('nusoap.php');
// create the client and define the URL endpoint
$soapclient = new nusoap_client('http://www.mnccyf.info/soap_book.php?wsdl');
// set the character encoding, utf-8 is the standard.
$soapclient->soap_defencoding = 'UTF-8';
$soapclient->call('sendSMS', array( 'uName' => '48dwi5',
'uPin' => '159597',
'MSISDN' => '09152886810',
'messageString' => 'Registered Successfully',
'Display' => '1',
'udh' => '',
'mwi' => '',
'coding' => '0' ),
"http://ESCPlatform/xsd");
?>
Inquiry.php
<?php
// This will allow user to inquire about the latest news within the organization.
error_reporting( E_ALL );
// load the nusoap libraries. These are slower than those built in PHP5 but
require_once('nusoap.php');
$soapclient = new nusoap_client('http://www.mnccyf.info/soapquery_server.php?wsdl');
// set the character encoding, utf-8 is the standard.
$soapclient->soap_defencoding = 'UTF-8';
// Call the SOAP method, note the definition of the xmlnamespace as the third in the call and how the posted message is added to the message string
$soapclient->call('sendSMS', array( 'uName' => '48dwi5',
'uPin' => '159597',
'MSISDN' => '09152886810',
'messageString' => 'Summer Camp 2013',
'Display' => '1',
'udh' => '',
'mwi' => '',
'coding' => '0' ),
"http://ESCPlatform/xsd");
?>
incoming_sms.php
<?php
require_once('nusoap.php');
function sendSMS($number,$soapclient)
{
$x=sendSMS("09152886810",$soapclient);
}
# Load XML string from input
$xml = simplexml_load_file('php://input');
# Parse the XML for parameters
$sms = array();
$nodes = $xml->xpath('/message/param');
foreach($nodes as $node)
{
$param = (array) $node;
$sms[$param['name']] = $param['value'];
}
if($sms['messageType'] == 'SMS-NOTIFICATION') {
sendSMS();
list($action, $messagetype, $source, $type) =explode (" ",$soapclient);
}elseif($sms['messageType'] == 'SMS') {
sendSMS();
list($action, $name, $age, $localchurch, $district) = explode(" ",$soapclient);
}elseif($sms['messageType'] == 'SMS') {
sendSMS();
list($action, $event,$location,$time) = explode(" ", $soapclient);
}
else {
echo "Unsupported Message Type";
}
?>
register_soapserver.php
<?php
//call library
require_once ('nusoap.php');
//using soap_server to create server object
$server = new nusoap_server;
$server ->configureWSDL('http://iplaypen.globelabs.com.ph:1881/axis2/services/Platform?
wsdl','urn:http://iplaypen.globelabs.com.ph:1881/axis2/services/Platform?wsdl');
//register a function that works on server
$server->register('reg');
// create the function
function reg()
{
$connect = mysql_connect("localhost","root","jya0312#");
if (!$connect)
{
die("Couldnt connect" . mysql_error());
}
mysql_select_db("cyfdb", $connect);
$sql = "INSERT INTO mydb(name, age,localchurch,district) VALUES ('{$_POST [name]}','{$_POST[age]}','{$_POST[localchurch]}','{$_POST[district]}')";
mysql_close($connect);
}
// create HTTP listener
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
soapquery_server.php
<?php
//call libraryrequire_once ('nusoap.php');
//using soap_server to create server object
$server = new nusoap_server;
$server ->configureWSDL('http://iplaypen.globelabs.com.ph:1881/axis2/services/Platform? wsdl','urn:http://iplaypen.globelabs.com.ph:1881/axis2/services/Platform? wsdl');
//register a function that works on server
$server->register('getquery');
// create the function
function getquery()
{
$link=mysql_connect("localhost", "root", "jya0312#") or die("Cannot connect to DB!");
mysql_select_db("cyfdb") or die("Cannot select DB!");
$sql = "SELECT event,location,time from activity";
while($r = mysql_fetch_array($sql)){
$items[] = array('event'=>$r['event'],
'location'=>$r['location'],
'date'=>$r['date']);
}
return $items;
$mysql_close($link);
}
// create HTTP listener
$server->service($HTTP_RAW_POST_DATA);
exit();
?>