|
I am using this code to send emails but when the user send something in arabic I get unreadable message like this:
تجربة من Ø§Ù„ØµÙØØ© العربية
here is my code.. please help..
<?php
$ToEmail = 'reception@rmc.bh';
$EmailSubject = 'Email from rmc.bh ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= 'Bcc: dhr@rmc.bh' . "\r\n";
$mailheader .= 'Bcc: jkh@rmc.bh' . "\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY .= nl2br($_POST["message"])."<br><br><br><hr>";
$MESSAGE_BODY .= "IP Address: ".$_SERVER["REMOTE_ADDR"]."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
header('Location: http://www.rmc.bh/thankyou.php');
?>
|
|
|
|
|
In the email header you are setting the MIME content type as HTML, using the ISO-8859-1 character set - that's the Latin-1 set, so that might explain why the Arabic is coming out wrong.
The simplest solution could be to change the header to use "charset=utf-8" instead of iso-8859-1, and also check that your application uses UTF-8 throughout (in HTTP headers, on the web page, form fields, database fields, etc.)
|
|
|
|
|
Hi,
I have skills saved in a table called skills in mysql with field name called skill_name.
I want to retrieve the skills and display like a cloud so one will have small font and next one will have larger font, etc..
something like this image:
http://www.rmc.bh/temp.jpg[^]
can anyone guide please..
|
|
|
|
|
|
Hi,
I wantt o know how can I have a facebook-like or linkedin-like modal dialog they used for properties and alerts?
Thanks,
Jassim
|
|
|
|
|
Modal box in html is clever combination of images. If you can figure out how to create that modal box, then rest is easy.
you can call the page with the modal box, It will have to have some javascript code to show the modal box properly., rest is up to you..
|
|
|
|
|
I am developing Google app (with oauth 1.0)that retrieve google contatcs but i got error : signature_invalid please help me Thx in advance
function GetRequestToken()
{
$consumer = 'YOUR_CONSUMER_KEY';
$secret = 'YOUR_CONSUMER_SECRETE';
$callback = 'http://localhost/Gcontacts/welcome/redirection';
$sign_method = 'HMAC-SHA1';
$version = '1.0';
$scope = 'https://www.google.com/m8/feeds/';
$path = "/accounts/OAuthGetRequestToken";
$mt = microtime();
$rand = mt_rand();
$nonce = md5($mt.$rand);
$time = time();
$url = 'https://www.google.com/accounts/OAuthGetRequestToken';
$post = array(
'oauth_callback' => $callback,
'oauth_consumer_key' => $consumer,
'oauth_nonce' => $nonce,
'oauth_signature_method' => $sign_method,
'oauth_timestamp' => $time,
'oauth_version' => $version,
'scope' => $scope
);
$post_string1 = '';
foreach($post as $key => $value)
{
$post_string1 .= $key.'='.($value).'&';
}
$post_string1 = trim($post_string1, '&');
$key_part = $this->urlencodeRFC3986($secret);
$key = $key_part;
$base_string = $this->calculateBaseString($scope, "GET", $post);
echo $base_string;
$signature = base64_encode(hash_hmac('sha1', $base_string, $key,true));
$post_string1 .= 'oauth_signature'.'='.urlencode($signature);
$post['oauth_signature'] = $signature;
$header[] = 'POST'.$path.'?scope='.$scope.' HTTP/1.1';
$header[] = 'Content-Type: application/x-www-form-urlencoded';
$header[] = 'Accept: */*';
$header[] = $this->calculateHeader($post).', Content-Type: application/x-www-form-urlencoded ,Host: www.google.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'scope='.$scope);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
curl_close($ch);
}
private static function urlencode_rfc3986($value)
{
if(is_array($value)) return array_map(array('Welcome_model', 'urlencode_rfc3986'), $value);
else
{
$search = array('+', ' ', '%7E', '%');
$replace = array('%20', '%20', '~', '%25');
return str_replace($search, $replace, urlencode($value));
}
}
function calculateBaseString($url, $method, array $parameters)
{
$url = (string) $url;
$pairs = array();
$chunks = array();
uksort($parameters, 'strcmp');
foreach($parameters as $key => $value)
{
if(is_array($value)) $parameters[$key] = natsort($value);
}
foreach($parameters as $key => $value)
{
if(substr_count($url, $key . '=' . $value) == 0) $chunks[] = self::urlencode_rfc3986($key) . '%3D' . self::urlencode_rfc3986($value);
}
$base = $method . '&';
$base .= urlencode($url);
$base .= (substr_count($url, '?')) ? '%26' : '&';
$base .= implode('%26', $chunks);
$base = str_replace('%3F', '&', $base);
return $base;
}
function calculateHeader(array $parameters)
{
$chunks = array();
foreach($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"');
$return = 'Authorization: OAuth ';
$return .= implode(',', $chunks);
return $return;
}
function urlencodeRFC3986($string)
{
return urlencode($string);
}
|
|
|
|
|
You need to be very careful while doing this sort of thing - any little errors are going to break it, and can be hard to track down. A few I've spotted are:
- You have the 'scope' parameter out of sequence when building the data to sign. Data must be ordered alphabetically by key for the oauth signature to be correct.
- You use "GET" as a parameter for calculateBaseString although you're using POST
- You miss out the & delimiter when adding the oauth_signature
- You call curl_setopt($ch, CURLOPT_POSTFIELDS twice, overwriting the OAuth signed data with a single parameter.
It's very possible there are other errors I've not spotted.
Niall
|
|
|
|
|
The problem that we want you to help us in solving it is as follows :
We have an excel sheet containing some data.
We want to import this data to a mySql database to be used by a certain application.
By importing this data through transferring it to CSV format, the data was successfully imported but the Arabic data was not displayed in the application while this data is displayed during browsing the database inside the MySql.
If the data is entered through the application and then retrieved , the Arabic data is displayed correctly.
We need to import this data (excel sheet) inside the MySql such that it is displayed correctly inside the application.
Hint :I'm use UTF-8
|
|
|
|
|
I think a CSV is ascii only. UTF-8 would be lost.
Chris J
www.redash.org
|
|
|
|
|
I traditionally live in the client app world, so minimizing lines of code is more important than performance, so my coding style is heavy on common functions, etc.
Now that I am working on a web app (PHP and mySQL), I find myself second guessing everything. Here is an example. I am working on a shopping cart for an existing site. There are multiple places where the price of a particular product is returned:
Product Page
Cart over view
Buy process page,
receipt print,
etc.
In most cases, the product data (price) is already available, but the price can vary in different circumstances. I'm considering one function that gets passed the important variables, calculated the price of the product, and returns that price. However, to do so will require polling the database each time each price is requested (in some cases that is multiple prices on one page, so multiple calls to the database while the page is loading).
So my question is really one of best practice. How much of a noticeable performance hit does each call to the database take? Is it common to try to reduce the number of mysql calls? Do you not care? should each page have its own code, and just copy paste all over, and tweek each place where common data is shown?
There is a lot of how to questions (I have posted them) but I am hoping the community here can offer some more higher level theory.
Thank you in advance!
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
I cannot answer your question directly,
Some issues first of all if you a can create common function that will be used by multiple page, then make that one function.
From my experience: making software using php sometime helps a lot. specially development time. But I have faced some issue when I cannot depend on php.
I have faced a problem with one of my Software. I had to calculate stock by daily basis, Its not simple calculation which can be based on simple (insert into stock)-sales+(return from customer), Its more complicated than that. Because we have a different kind of stock management just because of type of product. The result is php page suffers big time. it cannot show the result. most case it ran out of memory. So, I solved it by C. I developed this page using C
Another example is, report making. I take support from pdf making class MPDF(they are vanished, i cant find there site anymore). But It cannot handle big data, memory suffers. So, Now I am building them in C. Finally my point is PHP gives a great way of programming but not very good idea in every case...
|
|
|
|
|
Thanks. You say: if you a can create common function that will be used by multiple page, then make that one function.
My main question is if doing so causes multiple MySQL calls that would not otherwise be required, is that bad practice?
Thanks in advance.
*****************
"We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
|
|
|
|
|
some of the problem can be solved by single query, some of them are not possible in single queries
if possible use multiple query
|
|
|
|
|
Follow the link below:
http://codeigniter.com/forums/viewthread/202515/
|
|
|
|
|
I find that the iostat in Linux gives the average disk queue length different from Window.
Window use Little's Law, but Linux use "weighted # of milliseconds spent doing I/Os" (Last Field in /proc/diskstats) divided by the duration. I have searched in Google but I cannot find any mathematical explanation on this.
Could anyone give me some pointers? 
|
|
|
|
|
|
I hate you
Re-phrased: could someone give me some reference?
|
|
|
|
|
int x = 0;
int& rX = x;
Sorry. I too could not resist prescribing humor.
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
Hi,
I want to ask what's similar to visual studio in the PHP world to use for IDE development?
Thanks,
Jassim
|
|
|
|
|
|
I use NotePad++, excellent tool, But you wont get Intel*** support. But you will give you way better environment than vim,
With winscp you can easily edit php file from remote machine.
|
|
|
|
|
|
but all these are editors NOT IDEs so there is no components like the Label, Text, Checkbox, etc just like the way it is there in Visual Studio..
Does this mean all PHP IDEs are just Editors or I can still find real IDE?
Regards,
Jassim
|
|
|
|
|
So you prefer to drag a component from a toolbox rather than hand code? OK, try this ...
Well, then go spend a lot of money buying Microsoft Expressions, even then it might not do everything that you want. However, you could also spend some money hoping that this PHP plugin for Visual Studio, available from here http://www.jcxsoftware.com/vs.php[^], can do what you want, but as I have not had reason to use that VS plugin, thus, I could not possibly comment.
modified 1-Aug-19 21:02pm.
|
|
|
|
|