PHP - Php Incrementing /w Decimal Places.
Hey, just wondering what would be the best way of adding .1 to a string.
For example: Code: [Select] $newversion = $currentversion + '0.0.1'; $newversion is taken from a db, lets say for this example it is 0.2.1 This code simply outputs 0.2 Any ideas? Thanks =) Similar TutorialsHi, I'm trying to force 2 decimal places with the following function but it 's not working. Any suggestions? Code: [Select] function ShippingCost() { $shippingCost = 4.00; number_format($shippingCost,2); return $shippingCost; } Hi.. I encountered problem in rounding of numbers into two decimal places. here is my sample code: if($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 7917 AND $TotEarn <= 12500) { $TAX = ($TotEarn - 7917); $TAX = (937.50 + ($TAX * .25)); $TAX = number_format($TAX, 2, '.', ''); } for example from this: $TAX = ($TotEarn - 7917); $TAX = (937.50 + ($TAX * .25)); the output is: 1417.615 using this: $TAX = number_format($TAX, 2, '.', ''); the output was : 1417.61 but it should be : 1417.62 Thank you i am echoing out a value which is 1.2900 but i want it to echo out 1.29 how do i do this? cheers matt Bascially i add a couple numbers up and display the sum. sometimes the number is something like this: 234.237 i want it to display : 234.24 i realize its needs "round()" in it but i dont know how to use it.. any help? Hi I am using Zen-Cart to which I have made significant changes. Two years ago I managed to change the Products Sort Order from Integer to Decimal(5,2) to store books such as 1, 1.5, 1.75, 2 etc. Regrettably we had a major server issue and I also lost the new coding. Having restored everything else whenever we enter a book series number such as 1.5 it only stores as 1. To date the zen-Cart forums have been unable to offer a solution so I am reaching out to see if anyone else can advise me of how to get this working again please.
Thanks in advance Owen
This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=311051.0 Okay, for my bbcode parser, I run through [img tags with: Code: [Select] $text = preg_replace( "#\[img\](.+?)\[/img\]#ie" , "\\regex_check_image('\\1')" , $text ); It goes to my function regex_check_image: Code: [Select] function regex_check_image($url="") { if (!$url) return; $url = trim($url); $default = "[img]".$url."[/img]"; //-- mod_sec_update_131 begin $default = "[img]".str_replace( '[', '&# 091;', $url )."[/img]"; //-- mod_sec_update_131 end $image_count++; echo $image_count; exit; if ($image_count > 6) { message('You have posted to many Images'); exit; } if (preg_match( "/[?&;\<\[]/", $url)) { message('No Dynamic Images'); exit; } if (preg_match( "/javascript(\:|\s)/i", $url )) { message('No Dynamic Images'); exit; } // Is it a legitimate image? if (!preg_match( "/^(http|https|ftp):\/\//i", $url )) { message('No Dynamic Images'); exit; } // If we are still here.... $url = str_replace( " ", "%20", $url ); return "<img src='$url' border='0' />"; } Everything works fine, but for some reason, Code: [Select] $image_count++; echo $image_count; exit; if I have like 20 [img tags with images in them, I try to debug it, and echo it out, and it only shows "1" it should show how many [img tags I have, so I can echo out if somone is trying to spam images with the [img tag, any help? I am trying to keep track of how many times a page is loaded for debugging. Here is my code but it doesn't seem to work?! Code: [Select] <?php isset($counter) ? $counter++ : $counter=1; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Page A</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <h3>Add a Comment</h3> <form action="Processing.php" method="post"> <fieldset> <!-- Comment --> <label>Comment:</label><br /> <textarea cols="50" rows="15"><?php echo $counter; ?></textarea> <br /> <!-- Submit Form --> <input type="submit" name="addComment" id="addComment" value="Add a Comment"/> </fieldset> </form> </body> </html> What am I doing wrong? Debbie I'm having troubles incrementing a date by one day using the following format: 11-17-2011 (m-d-Y) I am attempting to use the following script: Code: [Select] $time = strtotime("11-17-2011"); $final = date("m-d-Y", strtotime("+1 day", $time)); When i echo $final i get a whole different date "01-01-1970" Now if i switch the format around to the following: Code: [Select] $time = strtotime("2011-11-17"); $final = date("Y-m-d", strtotime("+1 day", $time)); and i echo $final i get the right date but in that format (2011-11-18). Is there a way i can get the date in the first format?(m-d-Y) hey guys. Hopefully someone can help me with this. I have been trying to figure out for a while now why the quiz score keeps incrementing even if i refresh the page. so far there is 2 quiz sections, firstly $_SESSION['score']; is incremented on every correct answer then this information is carried on to the second part of the quiz which increments $_SESSION['score'1]; However everytime a page is refreshed then it increments again. How can i get around this? Also note i have a questions and answers section (array of q's and a's) and a functions page. Any help would be great. Thanks in advance Lance Code: [Select] <?php session_name("Question_Test"); session_start(); $_SESSION['score']; require_once('questionsandanswers2.php'); require_once('functions.php'); if (!isset($_POST['submit'])) { $score1 = 0; $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; if (isset($_SESSION['error'])) { unset($_SESSION['error']); $num = 0; } else { $score1 = 0; $_SESSION['score1'] = $score1; $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; $num = 0; } } else { $num = (int) $_POST['num']; $postedanswers = str_replace("_"," ",$_POST['answers']); if ($postedanswers == $answers[$num]['0']) { $_SESSION['score1'] ++; $_SESSION['correct'][] = $postedanswers; } else { $_SESSION['wrong'][] = $postedanswers; } if ($num < count($questions)-1) { $num++; } else { $last = true; $_SESSION['finished'] = 'yes'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>running an array</title> <?php if (!isset($last)) { echo "<script type=\"text/javascript\" src=\"form.js\"></script>"; } ?> </head> <body> <?php if (!isset($last)){?> <h1>Detection Section</h1> <h2>Questions <?php echo $num+1; ?>:</h2> <p><strong><?php echo $questions[$num]; ?></strong></p> <form id="questionBox" method="post" action="test2.php"> <?php $pattern = ' '; $replace = '_'; $shuffledAnswers = shuffle_assoc($answers[$num]); #var_dump($newanswers); foreach ($shuffledAnswers as $answer) { $answer2 = str_replace($pattern,$replace,$answer); echo "<li><input type=\"radio\" id=\"$answer2\" value=\"$answer2\" name=\"answers\" />\n"; echo "<label for=\"$answer2\">$answer</label></li>\n"; } ?> <input type="hidden" name="num" value="<?php echo $num; ?>" /> <input type="submit" id="submit" name="submit" value="Submit Answer" /></p> </form> <?php } else { $_SESSION['finalscore'] = $_SESSION['score'] + $_SESSION['score1']; echo "your final score is:</h2>\n <h3>{$_SESSION['finalscore']}/20</h3><h4>Verdict:</h4>"; if($_SESSION['finalscore'] <= 5) echo "<p id=\"verdict\"><span>S</span>everely <span>H</span>indered <span>I</span>n the <span>T</span>est!</p>\n"; if(($_SESSION['finalscore'] > 5) && ($_SESSION['finalscore'] <= 10)) echo "<p id=\"verdict\"><span>C</span>ould <span>R</span>ead <span>A</span>nd <span>P</span>ractice more.</p>\n"; if(($_SESSION['finalscore']) && ($_SESSION['finalscore'] <= 15)) echo "<p id=\"verdict\"><span>A</span>cronyms a<span>R</span>e <span>S</span>o <span>E</span>asy!</p>\n"; if($_SESSION['finalscore'] > 15) echo "<p id=\"verdict\"><span>S</span>uper <span>A</span>cronym <span>S</span>pecialist</p>"; echo "<p id=\"compare\"><a href=\"test2.php\">Next Section! <img src=\"images/arrow.png\" /></a></p>"; } ?> </body> </html> Hey guys, I have set a quiz up that pulls questions and answers from an array, every correct answer,.... score increments; however it is within a loop. Something must be wrong with the loop as it keep incrementing however i cant see why. Any help would be great, The main aim what i am trying to do is have 5 questions answered and go to different page (different topic for 5 more questions) however keep the on going score. Hope this makes sense. If not ill try and clear it up. Thanks for all your help guys in advance, i appreciate it also not, i have a functions.php, questionsandanswers.php Code: [Select] <?php session_name("Question_Test"); session_start(); echo $_SESSION['score']; require_once('questionsandanswers.php'); require_once('functions.php'); if (!isset($_POST['submit'])) { $score = 0; $_SESSION['score'] = $score; $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; if (isset($_SESSION['error'])) { unset($_SESSION['error']); $num = 0; } else { $score = 0; $_SESSION['score'] = $score; $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; $num = 0; } } else { $num = (int) $_POST['num']; $postedanswers = str_replace("_"," ",$_POST['answers']); if ($postedanswers == $answers[$num]['0']) { $_SESSION['score'] ++; $_SESSION['correct'][] = $postedanswers; } else { $_SESSION['wrong'][] = $postedanswers; } if ($num < count($questions)-1) { $num++; } else { $last = true; $_SESSION['finished'] = 'yes'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>running an array</title> <?php if (!isset($last)) { echo "<script type=\"text/javascript\" src=\"form.js\"></script>"; } ?> </head> <body> <h1>Protection Section</h1> <?php if (!isset($last)){?> <h2>Questions <?php echo $num+1; ?>:</h2> <p><strong><?php echo $questions[$num]; ?></strong></p> <form id="questionBox" method="post" action="test1.php"> <?php $pattern = ' '; $replace = '_'; $shuffledAnswers = shuffle_assoc($answers[$num]); #var_dump($newanswers); foreach ($shuffledAnswers as $answer) { $answer2 = str_replace($pattern,$replace,$answer); echo "<li><input type=\"radio\" id=\"$answer2\" value=\"$answer2\" name=\"answers\" />\n"; echo "<label for=\"$answer2\">$answer</label></li>\n"; } ?> <input type="hidden" name="num" value="<?php echo $num; ?>" /> <input type="submit" id="submit" name="submit" value="Submit Answer" /></p> </form> <?php } else { echo "your final score is:</h2>\n <h3>{$_SESSION['score']}/20</h3><h4>Verdict:</h4>"; if($_SESSION['score'] <= 5) echo "<p id=\"verdict\"><span>S</span>everely <span>H</span>indered <span>I</span>n the <span>T</span>est!</p>\n"; if(($_SESSION['score'] > 5) && ($_SESSION['score'] <= 10)) echo "<p id=\"verdict\"><span>C</span>ould <span>R</span>ead <span>A</span>nd <span>P</span>ractice more.</p>\n"; if(($_SESSION['score'] > 10) && ($_SESSION['score'] <= 15)) echo "<p id=\"verdict\"><span>A</span>cronyms a<span>R</span>e <span>S</span>o <span>E</span>asy!</p>\n"; if($_SESSION['score'] > 15) echo "<p id=\"verdict\"><span>S</span>uper <span>A</span>cronym <span>S</span>pecialist</p>"; echo "<p id=\"compare\"><a href=\"test2.php\">Next Section! <img src=\"images/arrow.png\" /></a></p>"; } ?> </body> </html> Hi all,
I'm having trouble attempting to increment values in an array...
$current = 5;
$next = array( IronMineList.php: Code: [Select] <?php include('buildingfile.php'); ?> <?php $dbhost = 'localhost:3306'; $dbuser = 'root'; $dbpass = 'root'; $dbname = 'aosdb'; $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $query="SELECT * FROM IMPrints"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; $n=1; $j=0; $b=1; while($i<$num) { $name = mysql_result($result, $i, 'name'); $work = mysql_result($result, $i, 'workers'); $effi = mysql_result($result, $i, 'efficiency'); $cost = mysql_result($result, $i, 'cost'); $iron = mysql_result($result, $i, 'iron'); $copp = mysql_result($result, $i, 'copper'); $silv = mysql_result($result, $i, 'silver'); $titan = mysql_result($result, $i, 'titanium'); $gold = mysql_result($result, $i, 'gold'); $uran = mysql_result($result, $i, 'uranium'); $plat = mysql_result($result, $i, 'platinum'); $diam = mysql_result($result, $i, 'diamonds'); $oil = mysql_result($result, $i, 'oil'); $water = mysql_result($result, $i, 'water'); include('Iron.php'); $i++; $b++; $j++; $n++; } ?> Iron.php: Code: [Select] <?php $dbhost = 'localhost:3306'; $dbuser = 'root'; $dbpass = 'root'; $dbname = 'aosdb'; $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $queryj = "SELECT name FROM IMPrints"; $resultj = mysql_query($queryj); $Column = mysql_result($resultj, $j); $queryp = "SELECT * FROM IMBuilt WHERE idcol = $idcol"; $resultp = mysql_query($queryp); $Base = mysql_fetch_row($resultp); if(isset($_POST[""])) { if($_POST[""]) { $Badd = $Base[$b]+$_POST[""]; $queryi="UPDATE IMBuilt SET $Column=$Badd WHERE idcol = $idcol"; mysql_query($queryi); } } $queryf = "SELECT * FROM IMBuilt WHERE idcol = $idcol"; $resultf = mysql_query($queryf); $Basic = mysql_fetch_row($resultf); echo $i; ?> <p class="bd" id="built">| Built: <?php echo $Basic[$n]; ?> |</p> <form class="bd" method="post" action="IronMineList.php"><input type="text" name='[]'><input type="submit" value="Build"></form> What those 2 php documents do is display a list of iron mines a player in my game can build. It is supposed to create 1 form for each blueprint so that a player can add only to the number of that blueprint on their colony. The displays work perfectly. It creates 1 div that properly displays the stats of each mine in the database table. It also creates one form for each div. The problem I have is, I can only make the forms add 1 to all the buildings on a colony. The name='' value of the form and the $_POST[''] values do not increment with the rest of the code. I need a way to make each form apply only to the div which displays a specific mine. So where $i=0 the first form should only alter the value in imbuilt for the stats that are displayed by the rest of the div created for $i=0. Hi all - hoping somebody can see this clearer than me... Goal: to create a very simple shopping cart page that receives $_POST info and stores it as an array in a session variable so items will be displayed in cart on clients return to shopping cart page. Problem: I can get the array to display the first item that I add to the shopping cart but each susequest item just overwrites the first because it is using the same session variable name. How do I store the next product info in a DIFFERENT session variable and display it on the shopping cart page without writing over the first? I have two pages with products on them which need to submit orders to the shopping cart page. They use a simple form with these fields: <form method="post" action="cartaction.php"> <p> <input type="submit" name="submit" value="Buy" /> <input type="hidden" name="cartaction" value="add" /> <input type="hidden" name="item" value="coppercasserole" /> </p> </form> This is what I have so far on the cartaction page which can display the first product added to the cart: <?php //If form is submitted, call the function and save all data into the array $_SESSION['form'] if($_POST['submit'] == "Buy"){ setSessionVars(); } function setSessionVars() { if ( !isset($_SESSION['cart']) ) $_SESSION['cart'] = array(); $item = array(); foreach($_POST as $fieldname => $fieldvalue) { $item[$fieldname] = $fieldvalue; } $_SESSION['cart'] = $item; echo "<table> <tr> <td>" .'<img src="images/'.$item['item'].'.jpg"' . "<td/> <td>" . $item['item'] . "</td> <td>" . '<input type="text(30)" name="value" value="1" /> <input type="submit" name="puchasednum" value="Update This One Item" />' . "</td> </tr> </table>"; } ?> I am new to PHP and have hit a brick wall as to how to display each product array as a new session variable in the shopping cart. I would like to keep it as simple as possible as I am getting easily confused! Is there a way that I can increment the session variable with something like this: <?php //session counter $counter = count($_SESSION['cart']); if (($_POST['name'] !="")){ $counter = $counter + 1; $_SESSION['cart'][$counter] = array(); } ?> Or can I pass a field as a product ID and use this somehow to create a new session variable for each product or clear the post variables somehow? Any help would be much appreciated? Thanks i have a slider that shows 2 images at a time. i did a query and got all my images names from the database to be in an array so i can go form index zero to the last image incrementing by +1 but not working. what it is doing now is displaying index[0] and index[1] in the first set of 2 images in the second set is displaying index[1] and index [2] in the third set is displaying index[2] and index[3] and so on... here's my query Code: [Select] require_once('connections.php'); mysql_select_db($dbname, $db); $sql = "SELECT * FROM table WHERE image IS NOT NULL LIMIT 6"; //limiting to six for testing only, will remove afterwords $results = mysql_query($sql, $db) or die(mysql_error()); $row = mysql_fetch_assoc($results); // $result2 = mysql_query("SELECT * FROM table WHERE image IS NOT NULL LIMIT 6"); $storeArray = Array(); while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) { $storeArray[] = $row2['image']; } ?> here's the html/php Code: [Select] <?php $index = 0;?> <?php do { ?> <div class="slide"> <div class="slidePromo"> <div class="promoImg"><a href="#"><img src="<?php echo $storeArray[$index];?>"/></a> </div> </div> <!--end slide--> <div class="slidePromo"> <div class="promoImg"><a href="#l"><img src="<?php echo $storeArray[++$index];?>"/></a></div> </div> </div> <!--end slide--> <?php } while ($row = mysql_fetch_assoc($results)); ?> Basically I'm trying to set up a shopping cart using PHP & MySql (oh really!?) and I've gotten to the point where I need to insert the bought products into a database. Currently, at the checkout, there is a session which stores data for all of the products which have been added into the cart. From here I am just trying to create an order id code that is only relevant to this session. So in the database it would end up looking something like this: order_id = 001, product_id = 2, order_quantity = 3 order_id = 001, product_id = 4, order_quantity = 2 order_id = 001, product_id = 1, order_quantity = 5 order_id = 002, product_id = 2, order_quantity = 3 order_id = 002, product_id = 4, order_quantity = 2 order_id = 002, product_id = 1, order_quantity = 5 So I would be able to pull these results later by selecting the order relevant to the order_id. At least I think this is the easiest option for me. Every product which is put into the cart has a $_SESSION name of 'product_x', 'x' being the id associated with that product Any help? I'm building a website in which the user can upload 3 photos of the same product (from different angles). what i want is that the user only selects those 3 iamges, writes a description and when they press upload the system creates an album named "1" with the 3 images in it. the next time the new folder name will be "2" I tried storing them on a mysql database but i read it makes it too heavy and the queries take longer. so i'll just save the path there. thanks! For every search, I get ZERO RESULTS, and I don't understand what I'm doing wrong. Code: [Select] <?php require('places_class.php'); $types = $_POST['type']; $location = $_POST['place']; $radius = $_POST['radius']; $gplaces = New GooglePlaces; $gplaces->SetLocation("$location"); $gplaces->SetRadius($radius); $gplaces->SetTypes("$types"); $results = $gplaces->Search(); print_r($results); ?> That's when the form is submitted, I checked the variables, and they are echoing out correctly. Then I thought I'd hard-code the values in, same results Code: [Select] <?php require('places_class.php'); $gplaces = New GooglePlaces; $gplaces->SetLocation("40.5267,81.4778"); $gplaces->SetRadius(50); $gplaces->SetTypes("food"); $results = $gplaces->Search(); print_r($results); ?> Here is the class Code: [Select] <?php class GooglePlaces { private $APIKey = ""; public $OutputType = "json"; //either json, xml or array public $Errors = array(); private $APIUrl = "https://maps.googleapis.com/maps/api/place"; private $APICallType = ""; private $IncludeDetails = false; //all calls private $Language = 'en'; //optional - https://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1 //Search private $Location; //REQUIRED - This must be provided as a google.maps.LatLng object. private $Radius; //REQUIRED private $Types; //optional - separate tyep with pipe symbol http://code.google.com/apis/maps/documentation/places/supported_types.html private $Name; //optional //Search, Details, private $Sensor = 'false'; //REQUIRED - is $Location coming from a sensor? like GPS? //Details & Delete private $Reference; //Add private $Accuracy; public function Search() { $this->APICallType = "search"; return $this->APICall(); } public function Details() { $this->APICallType = "details"; return $this->APICall(); } public function Checkin() { $this->APICallType = "checkin-in"; return $this->APICall(); } public function Add() { $this->APICallType = "add"; return $this->APICall(); } public function Delete() { $this->APICallType = "delete"; return $this->APICall(); } public function SetLocation($Location) { $this->Location = $Location; } public function SetRadius($Radius) { $this->Radius = $Radius; } public function SetTypes($Types) { $this->Types = $Types; } public function SetLanguage($Language) { $this->Language = $Language; } public function SetName($Name) { $this->Name = $Name; } public function SetSensor($Sensor) { $this->Sensor = $Sensor; } public function SetReference($Reference) { $this->Reference = $Reference; } public function SetAccuracy($Accuracy) { $this->Accuracy = $Accuracy; } public function SetIncludeDetails($IncludeDetails) { $this->IncludeDetails = $IncludeDetails; } private function CheckForErrors() { if(empty($this->APICallType)) { $this->Errors[] = "API Call Type is required but is missing."; } if(empty($this->APIKey)) { $this->Errors[] = "API Key is is required but is missing."; } if(($this->OutputType!="json") && ($this->OutputType!="xml") && ($this->OutputType!="json")) { $this->Errors[] = "OutputType is required but is missing."; } } private function APICall() { $this->CheckForErrors(); if($this->APICallType=="add" || $this->APICallType=="delete") { $URLToPostTo = $this->APIUrl."/".$this->APICallType."/".$this->OutputType."?key=".$this->APIKey."&sensor=".$this->Sensor; if($this->APICallType=="add") { $LocationArray = explode(",", $this->Location); $lat = trim($LocationArray[0]); $lng = trim($LocationArray[1]); $paramstopost[location][lat] = $lat; $paramstopost[location][lng] = $lng; $paramstopost[accuracy] = $this->Accuracy; $paramstopost[name] = $this->Name; $paramstopost[types] = explode("|", $this->Types); $paramstopost[language] = $this->Language; } if($this->APICallType=="delete") { $paramstopost[reference] = $this->Reference; } $result = json_decode($this->CurlCall($URLToPostTo,json_encode($paramstopost))); $result->errors = $this->Errors; return $result; } if($this->APICallType=="search") { $URLparams = "location=".$this->Location."&radius=".$this->Radius."&types=".$this->Types."&language=".$this->Language."&name=".$this->Name."&sensor=".$this->Sensor; } if($this->APICallType=="details") { $URLparams = "reference=".$this->Reference."&language=".$this->Language."&sensor=".$this->Sensor; } if($this->APICallType=="check-in") { $URLparams = "reference=".$this->Reference."&language=".$this->Language."&sensor=".$this->Sensor; } $URLToCall = $this->APIUrl."/".$this->APICallType."/".$this->OutputType."?key=".$this->APIKey."&".$URLparams; $result = json_decode(file_get_contents($URLToCall),true); $result[errors] = $this->Errors; if($result[status]=="OK" && $this->APICallType=="details") { foreach($result[result][address_components] as $key=>$component) { if($component[types][0]=="street_number") { $address_street_number = $component[short_name]; } if($component[types][0]=="route") { $address_street_name = $component[short_name]; } if($component[types][0]=="locality") { $address_city = $component[short_name]; } if($component[types][0]=="administrative_area_level_1") { $address_state = $component[short_name]; } if($component[types][0]=="postal_code") { $address_postal_code = $component[short_name]; } } $result[result][address_fixed][street_number] = $address_street_number; $result[result][address_fixed][address_street_name] = $address_street_name; $result[result][address_fixed][address_city] = $address_city; $result[result][address_fixed][address_state] = $address_state; $result[result][address_fixed][address_postal_code] = $address_postal_code; } return $result; } private function CurlCall($url,$topost) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $topost); $body = curl_exec($ch); curl_close($ch); return $body; } } ?> And yes, I do have the correct API Key, I just took it out Can anybody see what the issue is? I'm working on a dating website for tablets, pretty simple stuff, mostly the purpose on my end aside from hoping to make money from traffic / photos is learning about sockets, dragging and in this case automatic payment system.
The ideal plan is that a person is limited to their verification photo and a free photo file upload (fake women haha), and then for just a meager price of $0.20 each, an extra photo slot. Ideally they are not limited to how many photos they can post hence I created a table of just photos with a username, then incrementing number of photos.
Anyway, the plan is (despite how absurd it might seem), the person buys a photo slot, which they can freely modify, it's just a photo slot, for $0.20 and this is done through paypal and their credit card information is "stored" (yeah sketchy) for future purchase convenience.
I'm just looking for some input about this, you don't have to write the code, I haven't gotten to this part yet but if anyone has experience with automatic payment system and php/sql database cause-and-effect sort of automation...
If this thread is deleted I'll understand.
I did say absurd like "Who is going to buy a photo slot?" but it's not about that, the site isn't about "how many photos" you have or "profiles" really it's a lazy dating site, just skip, skip, skip, ooohhh, message, sort of thing and additionally if a person is so inclined, sees that there are more photos of this person... I think it's a pretty good idea having a mandatory selfie that people have to take to prove they are not a bot.
This is also useful for people to "verify" this person, so they see the mandatory photo selfie then compare it to the uploaded photos which may have obviously been altered. Yeah it doesn't sound like a sound "business plan" like who wants to "be themselves" but as I said, it is primarily a learning experience on my part. And an excuse to use my tablet that I recently purchased.
|