Converting A Number With PHP ?
I have a bit of script that will convert a number from one currency to another: Code: <body onload="euroconv()">
<script language="JavaScript">
function euroconv() {
document.convert.temp.value=Math.round(document.convert.result.value)* 2;
}</script>
<form name="convert">
<input size="6" name="result" value="40">
<input size="6" name="temp"></form>
This executes client-side I assume, and I need to convert a value that is given to me by PHP on the page server-side. I still want to format the number with PHP ( number_format($value) ) before I display it, so I need to do everything server-side.
I need to do with PHP what I am doing with the JavaScript here.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Replace Hex Number Or Decimal Number In A String ?
String may contain alphanumeric values. What is the bestway to replace a hex number such as 0x122aaa and decimal number such as 5678 with a string "blah" Example: I want to replace below-- wr_thru1 data or mask mismatch!! for addr=0x00000b73a0540 & mdfid:11 with wr_thru1 data or mask mismatch!! for addr=hexVal & mdfid:decVal
Order Number Or Tracking Number
I need to create some kind of random number within a persons session that can be inserted into a customer id column for their orders, customer, and credit card tables. Unless their is a better way to link a customers information together between a few tables besides using auto increment. Things could get screwed up for me if I use auto increment, especially if someone submits their information but does not actually place an order. My question is " How can I create a random order number that can be used within a persons session and will stay the same throughout the whole program for that one person? "
Database Stores Default Number Everytime, But I Havent Set A Default Number??
Im having some problems with my database. Everytime i store a number which is longer than 10 numbers the script or database puts this number into the database: 2147483647. Its does this everytime no mather how i write the numbers and nomather how long the number is, it just needs to be over 10. I have set any default value in the database and to be sure i havent i tried deleting the table, but same thing happends again???
Converting 1 Into 01
Ok this is probably pretty easy, but since my english knowledge seems to insufficient to find this problem on php.net, I have to ask here! I have a date (let's say a day) and I get this as eg. 1 2 ... 7 or 9 I just want this number to always have two digits! 01 02 ... 07 or 09 see my problem?
Converting ASP To PHP
I just tried out asp2php - a program that converts asp to php more or less successfully. There were a few parse errors I managed to get rid of in the converted script. But I have a line that is giving me my last parse error and I have no idea what is causing the problem. Can anybody help?
Converting From Tcl To Php
I am trying to convert the following tcl code to php. each line of the file I'm reading is formatted like this: United States|1|3 I know how to open a file and read it line by line but I don't know how to split each line and assign the 3 items to variables in php. while {[gets $ip eachline] > -1} { set country_data [split $eachline "|"] lassign $country_data country_name air_letter_zone air_post_zone }
Converting Db Value
I have a textarea and would like to allow users to enter an html coded link, store it in the DB, all of this works fine. However I would then like to pull out of the DB the section and if it contains a html coded link turn it into an actual link and added target="_blank" to it. How can this been done. The data coming out make contain other information that will also need to be displayed.
Converting An Ai To Jpg?
Is it possible to convert an .ai file to another format (jpg, gif, or png) with either the GD Library? With ImageMagick using MagickWand?
Converting % To Dec.
I'm writing a CSI program for a body shop and need to be able to take % from the data they receive. This works well: EI: $yes = "30"; $total = "170"; $newtotal = ($yes * 100) / $total; echo"$newtotal%"; Answer is: 17.647058823529411764705882352941% How can I get the answer to just get: 17.6%? Any ideas to limit this string?
Converting Dates
I have a little problem and am looking for a quick fix if there is one! I have a series of dates in this format: 15-Sep-1999 I need to reformat them to go into an sql database ie: 1999-09-15 Any ideas? I could do it by using strpos(), substr() and a big if else, but was wondering if there is a quicker way.
Date Converting
I am retrieving a date from mysql (using the mysql date format YYYY-MM-DD format). Is there an easy way to convert a date in that format: YYYY-MM-DD to this format: MM-DD-YYYY
Converting New Lines To <br>
I have some data contained in a mySQL table that contains line breaks. It's a snail-mail address. How can I have it so that when the data is recalled via PHP it puts a <br> where the newline is so that the data appears on a new line?
Converting Images In PHP
I am using one PHP class which converts gif,png,swf images into Jpg and other format. When i use this class on a single php page, it works fine but as soon as i include this class in between my webpage i get error like: Warning: imagejpeg() [function.imagejpeg]: Unable to open 'test.jpg' for writing in /home/domain/public/includes/func/class.php on line 148 If i call this class on a single page where there is no other PP tags, it works like charm.
Converting Seconds
i need a way to convert seconds into a thing like MySQL server has been up 1 day 34 min and 34 seconds. does anyone have any code or idea on how i would start this.
HTML Converting
How can I convert HTML into a form that PHP can work with it. For example if I have a HTML code that looks like: <textarea rows="2" name="S1" cols="20"></textarea> How can I change the " into single ' ? <textarea rows=ƈ' name='S1' cols=ཐ'></textarea>
PHP Newbie - Converting From ASP
I'm making the switch from ASP to PHP, and I'd appreciate it if someone could tell me the equivalent of the following. I'm basically looking for keywords to look up, but examples would be nice too. Any good PHP resources for ASP people like me? cheers. Response.Buffer and Response.Flush Response.ContentType = "text/HTML" Response.AddHeader "Pragma", "no-cache" Response.CacheControl = "no-cache" Response.Expires = 0 If Len($title) = 0 Then $title = "the default" and finally, this one: $TheDate = Right("20" & Year(Now()), 4) & "-" & Right("0" & Month(Now()), 2) & "-" & Right("0" & Day(Now()), 2) & " " & Right("0" & Hour(Now()), 2) & ":" & Right("0" & Minute(Now()), 2) & ":" & Right("0" & Minute(Now()), 2)
Converting ?PID=whatever To Directories?
I've got a product directory with a product detail page for all products. The way the product page is displayed in the address bar is productdetail.php?PID=# Would it be feasible for a newbie like me to do so that instead of putting in the question mark it's in directories similar to Amazon?
Converting Time
What I would like to do is take a user inputed time such as: 1:30 PM and convert it to: 13:00:00 to put into a MySQL db. but I just can't seem to figure it out.
Converting Numbers
I am using the base_convert() function to convert numbers between binary, hexadecimal, decimal, etc... It works great, but I have problems converting numbers with .'s Like this number: 15.20 decimal will be 1111 as binary... is there any way to include the rest of the number in the convertion?
Converting HTML To PHP
A friend and I are converting a site from *.html to *.php. The site already recognizes the *.php files - and the most current version of PHP is running on the server (*.nix). We plan to leave the *.html files in place, due to their inclusion in search engine databases and user bookmarks. Here are my questions, that I would appreciate your help with: 1). Are there any problems or issues that I should be concerned with, considering that I might have both an index.php and an index.html in the directories at the same time (unless there is a better way)? 2). Is there any search-engine-friendly way to add refresh statements (meta or javascript) to some of my html files? If so, please share code example. [I'd only add the refreshes to those pages that are a part of the main site structure - i.e. index.html files in the directories.] 3). If I have to go the parsing html as php method... Is the "AddType application/x-httpd-php .html" statement valid to be in the "current version of PHP's" httpd.conf file? Or, does it need to be like this "AddType application/x-httpd4-php .html" (with the Ɗ' included)? Also, is that all that is needed to make PHP parse *.html as *.php? [By the way, I am somewhat aware of the .htaccess method.] 4). Does anyone have any examples of how speed is affected by having the *.html files parsed as PHP files? If so, please share.... [Speed is of big concern...] I appreciate your help with this. I need to upgrade this site and there are hundreds of pages that are currently in the search engines that I do not want to interfere with. I know that I can keep the html pages and have them parsed as php, but I have already built much of the new site (with many links) with php extensions. So, I planned to drop the new site in the directories with the old site. Pages that are not a part of the main structure (main, products, contact, news, .... and other index.html pages, I will just change the links in them to point to the new index.php pages -- but the main index.html will have to remain and have links updated and/or refresh code). I really need to find some straight-forward help with this, so that I can do it in a way that will not hinder the site's standing in the search engines.
Converting Some Old CGI To PHP Problem.
I'm working on converting some really old code (written in Perl I believe) into PHP and having some issues with one part. I know how to do it in PHP one way, but some code in the old Perl script has me thinking there's a more efficient way... Can anyone translate this old Perl code into PHP? PHP Code:
Converting Certain Newlines To <br />s
I have a site wherein the clients can update the individual pages by editing the text of that page in a <textarea>. Then, when the page is displayed, all of the newlines ( ) are converted to HTML line breaks (<br />). However, I have come across some instances where I do not want to convert the newlines, such as the following: <table> <tr> .... </tr> </table> Obviously, I would not want this to be <table><br /> <tr><br /> .... </tr><br /> </table><br /> Can anyone suggest a method for achieving this? I've tried different mixtures of regular expressions, but my skills with those are just not up to par.
Converting Algorithms
I've ben scanning some sites that demostrate several algorithms and their uses with Java. In essence they are text, though complicated. Do you think their could be any benefits in turning these sources into PHP code and use them in PHP scripts? I've seen these algorithms in both C and Java, accomblishing str replacements, text highlighting, and even more remarkable tasks.
Converting Pdf To Html
I am working on a script that opens email attachments and copies the contents into the body of the email in html format. Does anyone know if there is a way to convert pdf files to html on the fly, using php?
Converting Timezones In PHP 4.x
I am using PHP 4.x and MySQL. The database has the list of countries, cities and timezones. I would like to convert the time from one zone to another zone [e.g. if the time in Moscow is 4:00 AM on Sept 8, what is the time in NY]. It is not that difficult to convert but I was wondering if the language itself supports the conversion which I would prefer using.
Formulas/converting From JS?
I have a program which converts Excel spreadsheets to Javascript and allows interactivity. However it can't convert it to PHP, which is obviously better for users to view (in case J/S is turned off). How would I go about converting some of this created code (example JS below), or is there an easier way to get PHP to do the calculations itself? I am aware of an excel-server product but this is too expensive and doesnt actually produce any code. I'm not suggesting someone convert this (also as its only an example), but the code seems quite complicated for a junior PHP person. Any thoughts on what I could do? (code created by spreadsheet converter) <script language="javascript"> var co = new Object; function recalc_onclick(ctl) { if (true) { co.pA7D=eeparseFloat(document.formc.pA7D.value);ca lc(co);document.formc.pA7E.value=eedisplayFloat(co .pA7E); };}; var eeisus=0;var eetrue="TRUE";var eefalse="FALSE";var eedec=".";var eeth=",";var eedecreg=new RegExp("[.]","g");var eethreg=new RegExp(",","g"); var row1xD2D5=new Array(4);for(var jj=0;jj<4;jj++){row1xD2D5[jj]=0};var row1xE2E5=new Array(4);for(var jj=0;jj<4;jj++){row1xE2E5[jj]=0};function calc(data){var cA7D=data.pA7D;row1xD2D5[0]=(10);row1xE2E5[0]=(1);row1xD2D5[1]=(20);row1xE2E5[1]=(2);row1xD2D5[2]=(30);row1xE2E5[2]=(3);row1xD2D5[3]=(40);row1xE2E5[3]=(4);var cA7E=(lookup3vv((cA7D),row1xD2D5,0,3,row1xE2E5,0,3 ));data.pA7E=cA7E;}; function myIsNaN(x){return(isNaN(x)||(typeof x=='number'&&!isFinite(x)));};function eeparseFloat(str){str=String(str).replace(eedecreg ,".");var res=parseFloat(str);if(isNaN(res)){return 0;}else{return res;}};function eedisplayFloat(x){if(myIsNaN(x)){return Number.NaN;}else{return String(x).replace(/./g,eedec);}};function lookup3vv(key,kvect,kfrom_start,kto_start,vvect,vf rom_,vto_){var current=0;var from_=kfrom_start;var to_=kto_start+1;while(true){current=(from_+to_)>>1;if(kvect[current]==key)break;if(from_==to_-1)break;if(kvect[current]<key){from_=current;}else{to_=current;}};while(curr ent<kto_start){if(kvect[current]==kvect[current+1]){current++;}else{break;};};if(key<kvect[current])return Number.NaN;return vvect[vfrom_+current-kfrom_start]}; </script>
Converting Sql Db To Plaintext Db
How can I convert a php script that uses an sql database so that it can use a simple text file (or multiple text files, but NOT sql) instead?
Converting Gif To Jpeg
I cant seem to be able to output the output as a file which I can then move to "/directoryforjpegs/". Code:
Converting To Php5? Meh?
I feel like a reall dumbass in this area of website building.. I have no clue about any php or anything and thats why im posting in this Newbies section. I really hope to learn a little about php someday but for now I have 1 need. I am trying to convert a php proxy to php5. Now if that is completely ridiculous and that was a REALLY retarded question that makes no since at all then please stop reading here and just post why that doesnt make since because I really do no nothing about php except its a computer language thats confusing as ########## (for me). Now if that wasnt a stupid question then good! i get 1 thing! So then how would I go about converting a giant php proxy script into php5? This person on irc said this when i asked: [03:45] (SlashLife): Then call your PHP file .txt and make it being parsed by PHP4. then he called me stupid and kick banned me (wtf?). Im not sure if he was just making fun of my stupidity or if he was really telling me something that would help me but i really didnt get.
Converting Smilies
I am not sure how to convert : ) smilies to . I already have it so the user clicks on the smiley. It inserts into the textbox, but not sure how to display it after it is called back from mysql. Anybody have any ideas on how to start this or can point me into the right direction where I can read on how this is done.
Converting To Coldfusion
I'm a Coldfusion developer and I'm trying to convert some PHP code to Coldfusion. I'm having trouble diciphering some of the code:
Converting Dates
I am trying to convert a date in the format of 12-Jan-2006 etc. to 2006-01-01.
Converting A PDF To Images
I am trying to create a way so that a user can upload a PDF file, and my code will automatically take the cover of the PDF (Page 1) and convert it to an image to use as a PDF preview in another page. I have searched the web for a short period of time and found many ways to do the Image-->PDF conversion, but no articles on how to reverse the process. Has anyone else come across this problem and found a way to do this or a more clever approach to previewing a PDF (without having to manually upload a separate image file when the PDF is uploaded)?
Converting HTML To A PDF
I am looking for some advice on converting HTML to a PDF file. I used to use HTMLDOC (easysoftwareproducts.com) on my personally hosted server, because I could install it. However, most web-hosting sites do not allow that. I found FPDF (Free PDF) PHP library, that allows you to manually draw in text, lines, rectangles, etc. While that is NICE, I am looking for something that my users can create custom templates in HTML and add [TAGS] for populating with database fields. I wish I could use WORD or something, but HTML should be OK for most.
Converting Between Time Format
When I retrieve a date from MySQL, the time format is in military (23:59:59). What should I do to make it in regular 12:00:00 format?
Converting Variable Into Code?
This might be obvious, but I'm wondering how I can convert a variable containg html/php-code into actual code, i.e. something similiar to include() One way to do it would be to save the variable to file, and then include this, but there must be an easier way, right?
Converting HTML Characters With PHP
In PHP4 there is a function called: get_html_translation_table (HTML_ENTITIES); which enables you to leave some HTML-code as it is, like ë for instance.
Converting Line Breaks To <br /> And <p> </p>
I'm working on a blogging platform, and I'm struggling with the final output (what the end users/web visitor sees). I've got to the stage where the data stored in the database in 100% correct. My problem is converting line breaks to <br /> and <p></p>. An example database stored entry: <h2>A Testing title!</h2> A list: <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> Another paragraph. This is how I'd like it to be displayed to viewers: <h2>A Testing title!</h2> <p>A list:</p> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> <p>Another paragraph.</p> I've tried: nl2br and replacing double '<br />' to '</p><p>', but this messes up the HTML lists and sometimes H tags. What I really want is a nl2br function that doesn't work between block level elements.
Converting Www Text To A Link
Does anyone know how i could check some inputted text and see if it had a www.url.com in it and if so wrap it with: <a href="http://www.url.com">www.url.com</a> It would need to do .com .co.uk .ie etc I think its something to do with regular expression but im not sure.
Converting String To DATETIME
What is the best way to go about inserting a DATETIME into my MySQL database via PHP? The scenario is that I have a form where the user will enter a date and time and submit. I want this form to insert a valid DATETIME value into my database. I know how to convert my DATETIME values into Unix timestamps for use in my PHP code, but I'm not understanding how to best handle it the other direction. Given that the user would be inputting field values as follows: $month $day $year $hour(24) $minutes how do I best construct that into a valid DATETIME value that will go into my INSERT statement?
Converting MySQL Timestamp
I was wondering if it was possible to convert a MySQL Timestamp to a regular date format. I've tried time($row->date) and echoed the $row->date variable but it has no effect on the format. I found this time($row->date) thing at php.net but it didn't do anything that I wanted. I'm trying to display a readable date from a MySQL Timestamp.
Converting A Date To A Weekday
Would like to create a function that takes a date (for example: 20031009) as input and returns its weekday (thursday) as output.
Converting From Javascript To Php - Two Questions
I have two questions re converting from Javascript to php. 1. Testing for NS4 browsers is easy with Javascript using "if (document.layers) {...whatever...}". Is it possible to use the same test in php? 2. Is it possible to include Javascript within a php include? For example: <?php require("../foobar.inc");?> where foobar.inc is: xhtml and text... <script type="text/javascript"> if (document.layers) {document.write("HI THERE");} </script> more xhtml and text... Can this be made to work?
Converting MySQL Dates
I need to convert a MySQL date "2007-03-08", into "March 8th, 2007". Normally I would use MySQL to accomplish this task but I have to use PHP. Here's my code: echo date("F jS, Y", $row['date']); But this returns "December 31st, 1969". I'm not sure what's going on here.
Converting Date Formats?
I have some dates in a MySQL database that are in a 'Y-m-d' format. Is there a way to have PHP read these dates and convert them to a 'd-M-Y' format?
|