PHP - Can't Get Money_format To Work
If I put this in a new HTML document:
Code: [Select] <?php $number = 1234.56; // let's print the international format for the en_US locale setlocale(LC_MONETARY, 'en_US'); echo money_format('%i', $number) . "\n"; // USD 1,234.56 ?> as per the PHP manual, I get: Fatal error: Call to undefined function money_format() in C:\wamp\www\accounts\test.php on line 7 Line 7 is: echo money_format('%i', $number) . "\n"; I have tried setting different locales and same result. Any ideas on what I need to do to get it to work? Similar Tutorialshow do I set money format to NO decimal places? echo money_format('%(#10n', $reQ['capitalrequested']); Hi, I have this money related function: function getMoneyUS( $pricesUS ) { setlocale( LC_MONETARY, 'en_US.UTF-8' ); return money_format( '%n', $pricesUS ); } Now, after the update to 7.4, it is showing in the logs as deprecated. The issue is money_format. I tried with NumberFormatter::formatCurrency but I either get an error or empty results. Examples I'm finding are not functions that can be applied multiple times, but for fixed values only. Examples like this: $fmt = numfmt_create( 'de_DE', NumberFormatter::CURRENCY ); echo numfmt_format_currency($fmt, 1234567.891234567890000, "EUR")."\n"; Or this: $fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY ); echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n"; I could not adapt them to my function. I understand that I do not need setlocale anymore, but this NumberFormatter only. But the exact working replacement is a challenge for me. I tried removing variable $fmt and replacing the fixed amount with my $priceUS, always some error or no result. Tried a number of different things but can't seem to get the decimal to show the 0 if the decimal is only a single digit. Currently using: Code: [Select] $conversion = number_format("$conversion",2); Thanks This one requires lots of up front information: I have a page, for this example that I will call page.php. It takes get parameters, and for this example I'll call the parameter "step". So I have a URL like this: page.php?step=1 This page has a form with an action of page.php?step=1. The code on the page validates the posting information. If the information is bad, it returns the user to page.php?step=1; if it is good, it takes the user to page.php?step=2 via header( "location:page.php?step=2" ). So redirection is done by relative path, not full URLs. This all works as expected. Now what I've done is set .htaccess to be HTTPS for this page, via this code: # Turn SSL on for payments RewriteCond %{HTTPS} off RewriteCond %{SCRIPT_FILENAME} \/page\.php [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] This works (initially). However, once you try to post the form, it just redirects back to the step=1 version of the page. I really don't know how or why that would be. I'm not sure how else I can explain this or what other information you may have. But it's frustrating to not get a page working in HTTPS that works in HTTP. Very odd. Any suggestions? (I don't even really know the best location to figure out when/why it's redirecting back to the original page.) Hi.., I use below method to export data to excel. header('Content-type: application/ms-excel'); header('Content-Disposition: attachment; filename=abc.xls'); if I run the script from the server. (http://localhost/export.php) it is work. (pop-up window if i want save or open the file) but if i run the script from the client (http://192.168.1.5/export.php) it is not work. (nothing happen) any idea how to solve this? require_once 'includes/upload.class.php'; $upload = new uploads(); $details = $upload->getFileInformation($id); <?php echo $details['upload_desc']; ?> then here the class. require_once 'db.class.php'; class uploads extends database { private $uploadData; function uploadFile() { public function getFileInformation($id) { $this->uploadData = $this->readData("uploadfiles", "upload_id", $id); return $this->uploadData; } But it wont work! Some of you may have seen one of my many posts about email issues. Some users don't get them, and I have determined it is probably because we are marked as spam.
We are a service that grades sales team members on their phone skills. Listening to pre-recorded calls, grading and uploading them to our site, and then another part of our business looks them over and sometimes leaves a message that then get's forwarded to this persons work email.
I have determined there is ways to get marked as spam as default by not having an opt out link. This is not an option, these sales members employer has opted in, and the emails are going to work related accounts hosted at that employer. Also, if one of these staff members is not so bright, or disgruntled they may mark us as spam anyways. The bottom line is that we have very little control over whether we are or are not marked as spam.
So we want to start looking into sending text messages and this is where I start to question how good of an idea this is.
First off, if it was me, and the messages where being sent to a device that my employer did not provide, I would in no way want work related text messages coming to me. Unless there is a vested interest in getting them. IE, I'm the boss at this place and am always on the clock. What if you are on the bottom? It's just a job for you.
What if it is a pre-paid device, text messages cost money. What then? What if they don't even have, or want a cell phone?
The short of it is this. If I'm at a job that is just another job, and this employer tells me that I have to get these messages. I'm going to look for another job. I see the organizations having continuous issues and complaints from their employees. Thus us as a business having issues keeping clients.
What am I getting into here? What are your opinions on this matter? What are your recommendations as to alerting users of something on our site that we can rest assured are being received 100% of the time?
Thanks!
Nick
i need help trying to get this delete feature to work its not deleting from the database (by the way i took out my database names and passwords at the top of the file) is it possible someone could help me, ive been working on this for like a week and cant figure out the problem. thanks! you can email me at spr_spng@yahoo.com picture 2.png is showing what it looks like Code: [Select] <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="database_name"; // Database name $tbl_name="table_name"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <style> /*table affects look of the whole table look */ table { margin-left: auto; margin-right: auto; border: 1px solid #330000; border-collapse:collapse; width:70%; border-width: 5px 5px 5px 5px; border-spacing: 1px; border-style: outset outset outset outset; border-color: #330000 #330000 #330000 #330000; border-collapse: separate; background-color: #330000; #800517 f535aa #330000 school color #9A0000 school color2 #991B1E school color3 #CCCC99 school color4 #9A0000 } /*th is table header */ th { text-align: left; height: 2.5em; background-color: #330000; color: #FC0; font-size:1.5em; } /*td is table data or the cells below the header*/ td { text-align: left; height:1.0em; font-size:1.0em; vertical-align:bottom; padding:10px; border-width: 5px 5px 5px 5px; padding: 8px 8px 8px 8px; border-style: outset outset outset outset; border-color: #9A0000 #9A0000 #9A0000 #9A0000; background-color: #CCCC99; -moz-border-radius: 0px 0px 0px 0px; } </style> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Pick Which Rows you want to delete, Then press delete.</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF">delete</td></tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this // edited if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> Hi there, As the question says i tried several things but i can't work it out and my knowledge about php isn't that well. So I wanted to use a \ in order to stop PHP from registering my quotes. For some reason it does not seem to work. I am running PHP version 5.3.8. What am I doing wrong? Code: [Select] <?php $path = "www.DOMAINHERE.com/images/showlogos/".$showNAME."_logo.jpg"; if (file_exists($path)){ echo "YES"; ?> <a href="index.php"><img src="/images/showlogos/<?=$showNAME?>_logo.jpg" width="190" height="62" /></a><br /><br /> <?php } else { echo "NO!"; echo $path; } ?> the result is echoing out NO! which means the file doesnt exist... however when i c+p the echo'd $path into my address bar, it shows the image.. Thanks Hi, me again; i'm curious why this don't work and what would in it's replace; echo "<b>".$row['name'].['id']."</b><BR>"; basically what I'm trying to do is that it read like this Your in game name is ['name'] with id set to ['id'] I figure if I can get the name and id beside each other I can figure out how to the add the your in game name is and with id set to part myself sorry guys don't mean to be a bother Well, for those of you who use facebook, if you move pages from messages, to feed, to events or anything like that, you will notice the entire page doesn't load. At first, I though there must be some Ajax involved but then I realised that the page url is changing with new GET variables. So what is going on? What are they doing? I'm sorry if this maybe is an obvious understanding for you, but i can't understand one thing with URL's. If i create my page called "index.php" and put it in a folder called "folder" then the URL in the address bar would be: http://www.website.com/folder/index.php But then i deside to add a few more pages with like next and previous links to scroll through them. I put those pages in a folder called "pages" within the folder "folder". Now the URL's would something look like this! http://www.website.com/folder/pages/page1.php http://www.website.com/folder/pages/page2.php etc... Thats the only way i know URL's are created and look like. But now too my question.. This is a few URL's i've seen on a site and every URL leeds to a new page but there is no slashes indicating new folders? How do you do that? Here is some examples of how the URL's could look like: http://www.website.com/index.php http://www.website.com/index.php?p=new http://www.website.com/index.php?p=new&page=121 http://www.website.com/merge.php http://www.website.com/merge.php?id=20381 And every URL was a comnpletly new page? Hi I am having trouble with a login code which keeps producing a true value even when the password is incorrect. Just spent 4 hours writing code and I think I've gone a bit coo coo: Code: [Select] <h1>Login</h1> <p>If you are an existing member please login below. If you are new to this site please register to obtain your unqiue login and password by <a href="register.php">clicking here.</a></p> <?php require_once('common.php'); $error = '0'; if (isset($_POST['login'])){ // Get user input $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; // Try to login the user $error = loginUser($username,$password); } ?> <?php if ($error != '') {?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform"> <table width="100%"> <tr><td>Username:</td><td> <input name="username" type="text" /></td></tr> <tr><td>Password:</td><td> <input name="password" type="password" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="login" value="Login" /></td></tr> </table> </form> <a href="register.php">Register</a> <?php } if (isset($_POST['login'])){ ?> <table width="100%"><tr><td><br/> <?php if ($error == '') { echo "<h1>Welcome $username! <br/>You are logged in!</h1><br/><br/>"; echo '<a href="browse_index.php"><h2>Now you can start shopping! ---CLICK HERE---</h2></a>'; } else echo $error; ?> <br/><br/><br/></td></tr></table> <?php } ?> Code for Common.php: ?php function loginUser($user,$pass){ $errorText = ''; $validUser = false; // Check user existance $pfile = fopen("users.txt","r"); rewind($pfile); //$counter=0; while (!feof($pfile)) { $line = fgets($pfile); $temp = explode(':', $line); if ($temp[5] == $user) { // User exists, check password if (trim($data[0]) == trim(md5($pass))){ $validUser= true; $_SESSION['userName'] = $user; //$counter = $counter + 1; //echo $data; } break; } } fclose($pfile); if ($validUser != false) $errorText = "Invalid username or password!"; if ($validUser == true) $_SESSION['validUser'] = true; else $_SESSION['validUser'] = false; return $errorText; } function logoutUser(){ unset($_SESSION['validUser']); unset($_SESSION['userName']); } function checkUser(){ if ((!isset($_SESSION['validUser'])) || ($_SESSION['validUser'] != true)){ header('Location: login.php'); } } ?> Hello, I am trying to make this work. what i am trying to do is to make a function that changes a variable back and forth. for example, I need to have a variable $bgcolorplace that is set to 1, as soon as the function is executed the variable $bgcolorplace changes to 0. The next time the function executes, variable should turn to 1 again. This pattern should repeat forever only when the function is executed. I am trying to use this to change the background color of a generated HTML code which will be on the webpage. Here is my script. <?php $input=($_GET['inputText']); //get info from JS $ItemNum='Item'.$input; //make a var with contents "Item" + the info from JS to display later $bgcolorplace; //var that keeps track of what color to make the next background $bgcolor; //keeps the color of the background for this execution function changebgcolor(){ if ($bgcolorplace=="0"){ $bgcolorplace="1"; //$bgcolor="444444" echo("0 to 1<br/>".$bgcolorplace."<br/>");//display which part of code is executed 1 to 0 or 0 to 1(can never get the script to run this part), this line is temp/test code }else{ $bgcolorplace="0"; //$bgcolor="ffffff" echo("1 to 0<br/>".$bgcolorplace."<br/>"); //display which part of code is executed 1 to 0 or 0 to 1(It works), this line is temp/test code } } //this next section I have temporarily commented for testing purposes, this section works fine /*$out="<tr bgcolor=#'".$bgcolor."' id='".$input."'><td align='center' width='5%'>".$input."</td><td align='center' width='30%'>bible</td><td align='center' width='50%'>Softcover</td><td align='center' width='5%'>45</td><td align='center' width='5%'>1</td><td align='center' width='5%'>45</td></tr>";*/ if ($input=='123'){ changebgcolor(); //echo($out); }else{ echo('none'); } ?> I get a responds of this everytime 1 to 0 1 this means that the function is being processed, but the value of $bgcolorplace is always a 1, it never changes to 0 like I am trying to inside the IF Else Statement. The commented Items are just my code that I have temp disabled while I try to figure out why my IF Else statement doesnt work. Help is much appreciated, and thank you in advanced. Here is my code: <?php class ScheduleRecord { private $month; private $day; private $year; private $hour; private $minute; private $type; private $employeeNumber; public function __construct($employeeNumber, $type, $month, $day, $year, $hour, $minute) { $this->employeeNumber = $employeeNumber; $this->type = $type; $this->month = $month; $this->day = $day; $this->year = $year; $this->hour = $hour; $this->minute = $minute; } public function getType() { return $this->type; } public function getEmployeeNumber() { return $this->employeeNumber; } public function getMonth() { return $this->month; } public function getDay() { return $this->day; } public function getYear() { return $this->year; } public function getHour() { return $this->hour; } public function getMinute() { return $this->minute; } public function getType() { return $this->type; } } $shcRec = new ScheduleRecord(3, "DayIn", 04, 04, 04, 04, 04); echo $shcRec ->getEmployeeNumber(); ?> error: The page cannot be displayed because an internal server error has occurred. the last line seems to be the problem. Hi everybody *asian accent*, im trying to figure out how to display xml in php i know how to do things like <condition> <conditionId>4000</conditionId> <conditionDisplayName>Very Good</conditionDisplayName> </condition> for each blah blah as $item $condition = $item->condition->conditionId echo $condition; BUT........how do i get these values in XML to display in php this <searchResult count="2"> I want to get the value of count to display help please Ok strange one. I have an image upload script. It works fine and the image uploads and puts its name in my database. I also then post the name to the next page. Here is the image uploader <?php if (isset($_POST['insert_image'])) { $folder = "../../images/image_box/"; move_uploaded_file($_FILES["photo"]["tmp_name"] , "$folder".$_FILES["photo"]["name"]) or die(mysql_error()); //connect to database include('../../Connections/database.php'); $photo = $_FILES["photo"]["name"]; $qInsert = "INSERT INTO `photos` (`photo_name`) VALUES ('".$photo."')"; $rInsert = mysql_query($qInsert) or die(mysql_error()); //Tells you if its all ok if ($rInsert) { $url = "add_image_to_album.php?image_name='".$photo."'" or die(mysql_error()); header("Location: ".$url.""); } else { $errors = "There was an error inserting the image into the database"; } } ?> Notice I then post the image name to the next page. Now on the next page I have only this <?php include('../../Connections/database.php'); session_start();?> <?php echo '".$_GET['image_name']."' ;?> But there is an error at line one but I have tested the connection and its fine so its erroring displaying for example; landscape.png Does it have something to do with the .png in the name? If so how do i solve this? |