PHP - Is There A Way To Convert Bitcoin To Satoshie And Vice Versa?
Apparently it's bad to use floats when working with bitcoin. But the API i'm using doesn't really give an option to convert Bitcoin to Satoshie or vice versa. https://www.block.io/api/simple/php So I'm trying to figure out a way to do that function with PHP. Here is the code I found that converts from Satoshie to Bitcoin. My question is, how do I convert from Bitcoin to Satoshie. function convertToBTCFromSatoshi($value) { $BTC = $value / 100000000 ; return $BTC; } function formatBTC($value) { $value = sprintf('%.8f', $value); $value = rtrim($value, '0') . ' BTC'; return $value; } echo formatBTC(convertToBTCFromSatoshi(5000));
Similar TutorialsOk so say I have php do some calculations for me Code: [Select] $Value1 = 300; $Value2 = 100000; $FirstRatio = $Value1 / $Value2; $Value3 = 8000; $Value4 = 6000000; $SecondRatio = $Value3 / $Value4; $FirstRatio = 0.003 $SecondRatio = 0.0013 How would I go about doing these calculations and then sorting $FirstRatio and $SecondRatio and then it would take the highest ratio ($FirstRatio) and it would echo the value? I'm using this bitcoin price ticker that is using Mt.Gox but they're no longer in service unfortunately. I'm trying to replace Mt.Gox with blockchain or something similar. Can anyone please help me fix this? Please everyone i need your help here... How can i create a Bitcoin/E-cash deposit and withdrawal info on my website...please this is really urgent.... I have an image tagged here...that's example of what i need..
Hi, I'm very new to PHP and i'm trying to delevop an app using flash as the front end via PHP and a mySQL database on my server/host. I currently have two php scripts that I am referencing. The first is used as a login and the second is used to retrieve table data. Both scripts work fine when tested in flash but when I upload the flash file to my server and test online the first (login) refuses to work. The php files are already uploaded to the server and the mySql database is created on my server. I was wondering if there was anything in the script that might be causing this. I can't see why and my brain is starting to degrade rapidly. Can someone have a quick look and tell me if there's something in this script that's preventing this from working online please? my flash variables a user and pass This is the login script that won't work online: <? //this pulls the variables from the flash movie when the user //hits submit. Use this when your global variables are off. //I don't know how to toggle global variables, so I just put //it in all the time ;) $user=$_POST['user']; $pass=$_POST['pass']; //connect to database mysql_pconnect("*****","********","******") or die ("didn't connect to mysql"); mysql_select_db("******") or die ("no database"); //make query $query = "SELECT * FROM jingle WHERE recipient = '$user' AND password = '$pass' "; $result = mysql_query( $query ) or die ("didn't query"); //see if there's an EXACT match $num = mysql_num_rows( $result ); if ($num >=1){ print "status=You're in&checklog=1"; } else { print "status=Sorry, but your user name and password did not match a user name/password combination in our database. Usernames and passwords are entered in from a different file. Thank you for visiting test login script!!&checklog=2"; } ?> and this is the script the does work online: <? /* Retrieves score data from highscores table and returns data and status to Flash errorcode: 0: successful select 1: can't connect to server 2: can't connect to database 3: can't run query */ // fill this in with the right data for your server/database config $server = "*****"; $username = "******"; $password = "******"; $database = "*******"; // get current user $user=$_GET['user']; $pass=$_GET['pass']; // mysql_connect: Open a connection to a MySQL Server // Returns a MySQL link identifier on success, or FALSE on failure. if (!mysql_connect($server, $username, $password)) { $r_string = '&errorcode=1&'; // mysql_select_db: Sets the current active database on the server that's associated // with the specified link identifier. Every subsequent call to mysql_query() // will be made on the active database. // Returns TRUE on success or FALSE on failure. } elseif (!mysql_select_db($database)) { $r_string = '&errorcode=2&'; // mysql_query: Sends a query (to the currently active database // For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a // resource on success, or FALSE on error. // For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query() // returns TRUE on success or FALSE on error. } else { $qr = mysql_query("SELECT * from jingle WHERE recipient = '$user' AND password = '$pass'"); if (!qr || mysql_num_rows($qr)==0) { $r_string = '&errorcode=3&msg='.mysql_error().'&'; } else { $r_string = '&errorcode=0&n='.mysql_num_rows ($qr); $i = 0; while ($row = mysql_fetch_assoc ($qr)) { while (list ($key, $val) = each ($row)) { $r_string .= '&' . $key . $i . '=' . stripslashes($val); } $i++; } // add extra & to prevent returning extra chars at the end $r_string .='&'; } } echo $r_string; ?> Thanks in advance Olá,
I have this codE:
$cb = 'str_replace("' . $this->LE . '", "", "<$1>");'; $encoded_value[$key] = preg_replace("/<([^>]+)>/e", $cb, $encoded_value[$key]);error: "PHP message: PHP Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead How can i transform this code to preg_replace_callback ? thanks How can I echo this as seconds? $date_at_timezone = new DateTimeZone('Asia/Shanghai'); $date = new DateTime(); $date->setTimezone($date_at_timezone); echo $date->format('l dS F Y h:i:s A') . "Asia/Shanghai<br>"; I have come across a little feature I need to create to be able to upload .doc files and convert them to .pdf using PHP. I was wondering if anyone had any idea how I would go about achieving this, I am not asking for the code, I'm just asking on how it could be accomplished...I've searched Google and other PHP related forums but none have the answer to which I am looking for. Any ideas or suggestions are greatly appreciated. Regards, PaulRyan. I have the following code in javascript, I would like to rewrite it in PHP, if someone can help thank you very much. my code: http://pastebin.com/Jnt8RiYj Hi Coders,
any body can convert the following code into codeigniter.
if($_GET['type'] == 'country'){ $result = mysql_query("SELECT name FROM country where name LIKE '".strtoupper($_GET['name_startsWith'])."%'"); $data = array(); while ($row = mysql_fetch_array($result)) { array_push($data, $row['name']); } echo json_encode($data); }Thanks Hi, I want to place the following HTML statement inside an echo statement, i.e. in PHP I want to output an image that is also a link. <a href="#"><img src="Somefolder/animage.jpg" width="125" height="156" alt="some image" /></a> All ideas will be greatly appreciated. how to convert php pages to api Hey guys I'm having a bit of a problem trying to convert this string to UTF-8 encoding Quote 組ですが、 中には5- 6本のおす すめ番組の エッセンス が、ぎっし り詰まって います。 I've used $strTem = mb_convert_encoding($strTem, "UTF-8", "auto"); and while that detects the correct current encoding it doesnt change it at all and utf8_encode doesnt work at all, dont know what to use. Thanks Hello all, I'm having a problem with people uploading News Articles into my news database. Right now, some of them must be using a weird font to type up their stories, because when they copy/paste their story from Word to the PHP form, it makes the ' turn into the little empty boxes. Also, the same thing is happening to bullets. Any idea how to make ther ' show up correctly, and the bullets to either show, or to convert their bullets to dashes. thanks. Hi, I have been pulling my hair out for the last week trying to figure this out and am just stuck. I have a set of PDF's (roughly 3,000) that I will need to convert to JPG's. I can do this using a batch through photoshop, but after it is done, I will need all new PDF's that are uploaded to be converted to a large JPG and a thumbnail JPG. Through my research it has appeared that the best way to do this is by using GraphicsMagick, with GhostScript. I am trying to get this to work with: Windows 2008 rc2 IIS 7 PHP 5.3.3 Non-Thread Safe GraphicsMagick-1.3.12-Q8 GhostScript 9.00 php_gmagick_nts.dll from http://valokuva.org/builds/ After I got everything installed on the server, it works fine through command line. I can convert a PDF to a jpg with no problems using something like: gm convert test.pdf[0] test.jpg However, when I use this PHP script: <?php //Instantiate a new Gmagick object $image = new Gmagick('C:\inetpub\siteDir\test.pdf[0]'); //Make thumbnail from image loaded. 0 for either axes preserves aspect ratio $image->thumbnailImage(100, 0); header( "Content-Type: image/jpeg" ); echo $image; ?> I get the following error: thrown in C:\inetpub\siteDir\drawings.php on line 13 #1 {main} #0 C:\inetpub\siteDir\drawings.php(13): Gmagick->__construct('C:\inetpub\sit....') Stack trace: [17-Oct-2010 18:40:46] PHP Fatal error: Uncaught exception 'GmagickException' with message 'Postscript delegate failed (C:\inetpub\siteDir\test.pdf)' in C:\inetpub\siteDir\drawings.php:13 I have tried doing this as well: <?php exec('gm convert C:\\inetpub\\siteDir\\test.pdf[0] C:\\inetpub\\siteDir\\test.jpg'); ?> If I do that in the command line on the server, it works without any problems. When I do that in the PHP script, I get no errors, but the conversion doesn't happen either. Does anyone have any ideas? Is there a better method for doing this? Am I just missing something? Any help would be greatly appreciated. Thanks! Hello again How to convert size from taken from sql as the numbers and converted to MB in php? Hi, I was wondering if anyone has experience with using php to convert a powerpoint presentation on a Linux OS with Apache web server. The idea would be that a user uploads a powerpoint file that is converted server-side to individual png/jpg files for each slide so that a subset of these slides can be shown as a preview in an image slider. Does anyone know if this can be done on a Linux OS with Apache web server? I came across some solutions for windows versions of php (http://www.php.net/manual/en/com.requirements.php). Hope anyone can help me. I have a new project coming up, and one of the functions that this person wants is to convert word documents/pdf/html etc. to the ePub format. I've googled, but i haven't been able to find any code references for getting this accomplished...has anyone had any experience with this? Any suggestions? Any help would be appreciated! Also, I wouldn't mind an API if there even is one... I have some words are written by UTF-8. I want to use PHP to convert them to NCR DECIMAL. This is my words. After Convert: Sorry my bad English. Thanks advance This is TEXT FILE my Source. (attach File) [attachment deleted by admin] Hello I'm building a backend to allow a client to upload images to his site. But my client has a lot of images in tiff format so i'd like to be able to convert tiff to jpg and only after that upload the image. i'm using the command move_uploaded_file to upload the original image and then i'm resizing the image and creating a new one and delete the original. now i want to add to my script a way to convert the original tiff to jpeg, resize save and delete the original here is my code that it's working fine: Code: [Select] if ($_FILES['foto']['name'] == "") { $dir = "images/spacer.gif"; } else { $size = 124; // the thumbnail height $filedir = 'img/ambientes/'; // the directory for the original image $thumbdir = 'img/ambientes/'; // the directory for the thumbnail image $prefix = 'small_'; // the prefix to be added to the original name $maxfile = '200000'; $mode = '0666'; $userfile_name = $_FILES['foto']['name']; $userfile_tmp = $_FILES['foto']['tmp_name']; $userfile_size = $_FILES['foto']['size']; $userfile_type = $_FILES['foto']['type']; if (isset($_FILES['foto']['name'])) { $prod_img = $filedir.$userfile_name; $prod_img_thumb = $thumbdir.$prefix.$userfile_name; move_uploaded_file($userfile_tmp, $prod_img); chmod ($prod_img, octdec($mode)); $sizes = getimagesize($prod_img); $aspect_ratio = $sizes[0]/$sizes[1]; if ($sizes[0] <= $size) { $new_width = $size; $new_height = abs($new_width*$aspect_ratio); }else{ $new_width = $size; $new_height = abs($new_width/$aspect_ratio); } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image'); ImageCopyResampled($destimg, $srcimg, 0, 0, 0, 0, $new_width, $new_height, $sizes[0], $sizes[1]) or die('Problem In resampling'); ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving'); $uploadfile = $prod_img_thumb; imagedestroy($destimg); $fh = fopen($prod_img, 'w') or die("can't open file"); fclose($fh); unlink($prod_img); $dir = $uploadfile; } } anyone can help me? |