PHP - Convert To Ci
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 Similar TutorialsI 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. 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 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 Anyone know how to convert this to php? function IntNoise(32-bit integer: x) x = (x<<13) ^ x; return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 7fffffff) / 1073741824.0); end IntNoise function I tried, and passing numbers to it isn't working, I am always getting 1 for a result, I should be getting anything between -1 and 1 My attempt: function random($x){ $x = pow($x<<13, $x); return ( 1.0 - ( ($x * ($x * $x * 15731 + 789221) + 1376312589) & 0xFFFFFF) / 1073741824.0); } 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! Hi, I have songs that I have uploaded. There are tracks in each song. So I want my users to click download and they'll be able to download all of the tracks combined in a zip file. I have seen this hapening on several sites. Can any body tell me how that works using PHP codes / classes Regards, Faisal 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. 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 Hi In sql we have dates like this 134238 In php it shows - 19:10:11 . we can make it by using date('d.m.y', $date); where $date=134238 ; my question is how can we turn 19:10:11 in to 134238 using PHP I'm having trouble with a few pages on xcart with the charsets. The problem we're having is that we need to have both utf-8 and iso type charsets as we're getting garbled code on some pages. What I can do is set the utf-8 on all pages and then encode the garbled code into utf-8. Is there a function that does this in PHP or any modules I can use? Thanks 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 am trying to convert colors from Hex to HSL (Not HSL to Hex). I am using a PHP function for this purpose. But It's not working properly for some colors. For example for #e04c4c the HSL should be (0, 70%, 59%) which it isn't the case with the function. function hexToHsl($hex) { $red = hexdec(substr($hex, 0, 2)) / 255; $green = hexdec(substr($hex, 2, 2)) / 255; $blue = hexdec(substr($hex, 4, 2)) / 255; $cmin = min($red, $green, $blue); $cmax = max($red, $green, $blue); $delta = $cmax - $cmin; if ($delta === 0) { $hue = 0; } elseif ($cmax === $red) { $hue = (($green - $blue) / $delta) % 6; } elseif ($cmax === $green) { $hue = ($blue - $red) / $delta + 2; } else { $hue = ($red - $green) / $delta + 4; } $hue = round($hue * 60); if ($hue < 0) { $hue += 360; } $lightness = (($cmax + $cmin) / 2) * 100; $saturation = $delta === 0 ? 0 : ($delta / (1 - abs(2 * $lightness - 1))) * 100; if ($saturation < 0) { $saturation += 100; } $lightness = round($lightness); $saturation = round($saturation); //return "hsl(${hue}, ${saturation}%, ${lightness}%)"; return array($hue, $saturation, $lightness); }
This is how I used it: $templatePrimaryColor = '#e04c4c'; $templatePrimaryColor = str_replace("#", "",$templatePrimaryColor); list($h,$s,$l) = hexToHsl($templatePrimaryColor); $primaryColor = "hsl(${h}, ${s}%, ${l}%)"; This is the output: echo '<pre>',print_r(hexToHsl($templatePrimaryColor)).'</pre>'; Array ( [0] => 0 [1] => 99 [2] => 59 ) 1 Does anyone know what is the problem there? Thank you.
Hello guys. Im not familiar with PHP but I was asked to convert our Homepage which uses a Database to store tickets from 5.x to 7.3.9 . Now I get this error:
I'd appreaciate any help from you guys, tia. :) 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. Hello again How to convert size from taken from sql as the numbers and converted to MB in php? Hi, This is my first post here, i hope you guys can help me out. I'm using a flashupload to upload multiple files at once but this upload returns an error when there an image in CMYK is beeing uploaded. Now i was wondering if there was a PHP script that converts a CMYK image to a RGB image. Thanks in advance! how to convert php pages to api 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] |